Sunday, September 29, 2024

Namespaces, revisited.

I conservatively extended namespaces, but that took an internal overhaul of how scopes are treated. Shorthands are syntactic sugar for full-blown expressions.
using System
The above is sugar for:
using System (c0, c1, c2, ...)
Where c0, c1, c2, ... are all combinators in the System workspace. And that is sugar for:
using ε = System (c0, c1, c2, ...)
Which is again sugar for a number of renames.
using ε = System (c0 = c0, c1 = c1, c2 = c2, ...)
The renames all introduce bound names into the current scope. E.g.,
using Sys = System (p = print)
This will bind 'Sys::p' to 'System::print'.

Docstrings

I added docstrings to the Egel language some time ago. You can add documentation to either a file or a combinator.
@"""A multiline docstring for a file"""

def f =
    @"this is the fabulous 'f' combinator"
    [X -> 42]
Given docstrings, you can now ask for that interactively in the REPL.
>> help 'f'
{"this is the fabulous 'f' combinator"}
'Help' will do a best-match against all combinator definitions.