For those that like to cut to the chase, here's a little bit of Logix to take a look at. If you find this makes little sense, try the documentation.
Logix is (or rather, can be) just like Python, for example (this is the Logix interactive top-level):
[base]: isinstance(10, int) True
In Logix, syntax can be extended at any time using
defop
. How about (just by way of an
example) a nice infix syntax to replace that isinstance
function:
[base]: defop 50 expr "isa" expr func ob typ: : return isinstance(ob, typ)
We just added a new infix operator isa
to the language,
implemented as a regular function (note the func
keyword).
Now we can do (note we're still just typing at the interactive prompt):
[base]: 'a' isa str True
How about adding C's "? :
" operator? That can't
be implemented as a function, since it evaluates its arguments conditionally.
Fortunately, Logix has full procedural macros. Note the use of lisp-like
quasiquoting.
[base]: defop 10 expr "?" expr ":" expr macro test iftrue iffalse:
: return `if \test: \iftrue else: \iffalse [base]: 3 > 2 ? "yes" : "no" 'yes'
Using defop
, entire languages can be created - either from
scratch, or by extending and combining existing languages. To see how, try the
documentation.