Syntax built upon macros

Mike Austin <>
Sun, 30 Nov 2008 18:31:01 -0800

          From comp.compilers

Related articles
Syntax built upon macros (Mike Austin) (2008-11-30)
| List of all articles for this month |

From: Mike Austin <>
Newsgroups: comp.compilers
Date: Sun, 30 Nov 2008 18:31:01 -0800
Organization: at&t
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
operators, etc.

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.
An example:

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):

object <list>
      method sort: block, dir: dir
          # sort list

var list = <list> create
list sort: (a, b -> a < b), dir: #asc


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.