masak / alma

ALgoloid with MAcros -- a language with Algol-family syntax where macros take center stage
Artistic License 2.0
137 stars 14 forks source link

Express most built-ins as macros #536

Open masak opened 4 years ago

masak commented 4 years ago

We're happy when most built-in functions can be expressed as "pure 007", as opposed to extranatural substrate (currently Perl 6, in general whatever). There's a tendency to explain as many built-ins as possible within the system being defined, 007.

So also for terms, operators, and statements. This issue tracks that.

Some things are really simple, such as infix:<+>. No problem; it just maps to an op in the VM layer. Ditto for many other operators.

Some things are tricky or impossible to define without running into circularity issues. Expressions as such. Function calls. Function declarations. In some of these cases we might get pretty far, in the sense of seeming to provide an in-system explanation. But in another sense we probably have to give up and breathe metacircular magic into those things in order for them to work.

masak commented 4 years ago

By the way, @raiph, this is very close to what I once referred to as an Algoloid that uses macros to define itself.

In a way, it's nothing exciting. Just a bigger metacircular loop than Lisp typically has. One could define most of the core statements of 007 in terms of each other, or bottoming out as instructions on the VM layer. Instructions on the VM layer could then be interpreted by an interpreter written in pure 007. The whole metacircular loop would bottom out by having a VM written in some portable language, such as C.