Sugar

Ingvar von Schoultz ingvar-v-s at comhem.se
Wed Sep 3 19:39:13 PDT 2008


Yuh-Ruey Chen skrev:
> Ok, it really does sound like a hygienic macro system for |x(y) {...}|
> and |x {...}| statements and expressions. Call it what you want, those
> are definitely a type of macro. Since I like hygienic macros, I'm pretty
> sympathetic to them.

I'm no expert, but I've always understood macros to involve
text substitution, the macro definition specifying source code
that replaces the invocation. The sugar keywords only have
unusual arguments, but unusual as they are, they are passed
in a regular, run-of-the-mill function call, without any text
substitution.

The fact that the until() parenthesized expression becomes a
function body (or maybe one of your Ruby blocks) doesn't mean
that it involves text substitution. Despite odd syntax, it's
just a function or Ruby block, just like the code block below
is a function or Ruby block, to be passed as an argument.

> Or even
> better, make your own language and interpreter to test your ideas out.
> I'm already tempted to do so :)

And I've already started!  :-D  Sort of.

I'm adding sugar keywords to JavaScript in a server-side test
arrangement. I got tired of talking about abstract ideas here,
always wondering if my explanations were clear. I longed for
something concrete that people can test.

I think this can be useful even if the sugar keywords aren't
considered for es-harmony. When discussing classes etc. you
can use this testbed to implement classes as easily defined
sugar, and then test the resulting classes to see how they
behave, and decide if you like working with them.

In addition to the sugar keywords, the testbed will also
feature your Ruby blocks. The two complement each other very
nicely.

Unfortunately, implementing this is somewhat time-consuming.
I hope I'll have time. I'm pretty confident that I'll get
there within a reasonable time span.

-- 
Ingvar von Schoultz


More information about the Es-discuss mailing list