June 26th, 2024

First Class Contexts – Rye Language

Rye Language introduces first-class contexts for scoping Rye words, creating parent-child relationships. Context paths access values, restricting direct changes for control. Evaluation and isolation mechanisms enhance structured code organization.

Read original articleLink Icon
First Class Contexts – Rye Language

Rye Language introduces the concept of first-class contexts, which act as scopes for Rye words and are treated as dictionary structures. Contexts can be created using functions like context and extends, allowing for the creation of specific parent-child relationships. Context paths are used to access values within a context, and direct changes to values inside a context are restricted in Rye to maintain control over modifications. Evaluation in a context can be done using functions like do and do\in, enabling code execution within a specified context. Rye also provides mechanisms like private and isolate functions to manage context isolation and execution. Builtin contexts like math are available for math operations, and functions can be defined within specific contexts using fn\in. The Rye Console allows for navigation and interaction with contexts similar to navigating directories on a computer. Overall, Rye's context-oriented approach allows for structured code organization and controlled access to functions and variables within different contexts.

Related

F (2006)

F (2006)

F is a functional concatenative language with K3 list operations and Joy's dip combinator. It enforces one-time assignment, supports floating-point and symbolic datatypes, and emphasizes function-valence and -charge theories. The language is purely functional, prohibiting side-effects and reassignment, with various primitives for arithmetic, logic, and list operations. F also provides interactive commands for debugging and manipulation, focusing on simplicity, efficiency, and functional programming paradigms.

Binrw

Binrw

The tool binrw simplifies binary parsing and serialization with a declarative approach, offering readability and maintainability. It supports common tasks, generics, custom parsers, predefined types, and is safe for various environments.

As you learn Forth, it learns from you (1981)

As you learn Forth, it learns from you (1981)

The Forth programming language is highlighted for its unique features like extensibility, speed, and efficiency. Contrasted with Basic, Forth's threaded code system and data handling methods make it versatile.

Cognate: Readable and concise concatenative programming

Cognate: Readable and concise concatenative programming

Cognate is a concise, readable concatenative programming language emphasizing simplicity and flexibility. It supports operators as functions, stack evaluation, control flow statements, list manipulation, recursion, and mutable variables through boxes.

Continuations by Example

Continuations by Example

Continuations are powerful in control-flow constructs, enabling exceptions, search, threads, generators, and coroutines. They capture remaining computation steps, aiding in non-deterministic choices and efficient iteration over data structures.

Link Icon 3 comments
By @jadengeller - 4 months
It's hard for me to tease apart the differences between Rye "first class context", deprecated JS "with" statement, Scala/Idris/Agda implicit arguments, and I guess also just effect systems generally?

it feels like there're all features for ergonomic dependency injection, but maybe that's a lot of programming

By @jauntywundrkind - 4 months
> If a word in a context is bound to a function it evaluates it, if not it returns the value bound to it.

One of my favorite compositional patterns! I wish we saw this .ore, not just in contexts but everywhere.

It's something I saw Ansible inventories do that I absolutely loved. Point at an inventory, and Ansible will run it & use the output as inventory, or will otherwise use the contents.

I wish more languages had stuff like this. I just skeeted today that JS should have an optional function invocation syntax. myVar.??(). Run myVar if it's a function else use its value.