|I've always been very happy to see Common Lisp's with-open-file shortened to w/infile in arc, and so on. When I built wart I preserved these names. But when I added infix to wart I could no longer support slashes inside symbols. I ended up with names like w_infile. Yuck. This is even worse than replacing the much-loved hyphens with underscores.|
What to do? Well, I've been experimenting with a way to replace the underscore with.. spaces. Purely using macros. Basically, I am now defining macros like the following:
And now I can call them like so:
mac2 (with :nils vars ... body)
`((fn ,vars ,@body))
mac2 (with :tmpfile f ... body)
`(let ,f (tmpfile)
(before (system:join "rm " ,f)
Without breaking the usual semantics of with
with nils (x y)
(list x y) # => (nil nil)
mac2 is meant to be read as "define a two-word macro". It's basically syntactic sugar for the following:
with (x 1 y 2)
x+y # => 3
What do people think of this idea? Some thoughts occur to me:
mac (with $nils ... rest) :case ($nils = 'nils)
`((fn ,vars ,@body))
1. This feature bakes compose even more deeply to a first-class macro. In calls like:
There's no way to implement compose as a function anymore without teaching its result about the specializations of its constituents.
(prn:with nils ..)
But since I define (compose f g) as the macro `(,f (,g ,@$args)), everything works.
2. I'm using keyword args in the definition of multi-word macros to evoke pattern-matching, showing what parts of a call are 'constants'. (Perhaps I need to move to a pattern-matching rather than function-name-based lookup for calls?) However, I can't use keyword symbols in calls lest I cause weird errors later:
How important does it seem to delineate the constant parts of the call with keyword syms? Is it worth creating a second namespace of sigils (ha!) for constant symbols? Or does 'with nils' seem intuitive? I tend to think so since an fexpr lisp weakens the idea of all params being eval'd anyway.
with :nils (x y z) # Couldn't ever extend 'with' to use a param called 'nils'