|Syntax built upon macros firstname.lastname@example.org (Mike Austin) (2008-11-30)|
|From:||Mike Austin <email@example.com>|
|Date:||Sun, 30 Nov 2008 18:31:01 -0800|
|Keywords:||parse, design, question|
|Posted-Date:||01 Dec 2008 07:00:55 EST|
Happy post Thanksgiving all...
I've just started to write a parser for my interpreter and runtime,
and I'm looking for suggestions on designing a simple macro system. I
like languages that have a simple yet flexible syntax, such as
Smalltalk or LISP, but I also like the niceties of a more syntax rich
language with array bracket operators, module definitions, assignment
I've found Dylan to be the best example for macros, where you can
essentially create your own syntax on top of existing functions.
Indeed, this is how much of the syntax you see in Dylan is built. The
problem is, it took me weeks (months?) before I could even write
macros without help from irc#dylan.
On the other hand, I don't plan to have so much syntactic sugar that
it becomes a beast. In that case, maybe a macro system is overkill.
Raw syntax - create a new object "<list>" that extends "<object>", and adds a
method "foo". ("->" is a lambda expression, closed by ";"):
<object> create: #<list>, ->
<method> create: #sort, (#dir),
a, b -> a * b
That's horrid! :) Something like this would be more pleasing to the eye (for
each their own):
method sort: block, dir: dir
# sort list
var list = <list> create
list sort: (a, b -> a < b), dir: #asc
Return to the
Search the comp.compilers archives again.