Blocks from strings
Brian T Rice
water at tunes.org
Thu Jan 1 03:19:30 UTC 2004
On Wed, 31 Dec 2003, Lex Spoon wrote:
> Brian T Rice <water at tunes.org> wrote:
> > This is a general comment, not just to Lex, about this kind of issue.
> > In Slate, we deal with this using syntax-level methods. For example,
> Ah, yes macros are a lovely intermediate level between string->block and
> holey-block -> block, assuming you are in a dialect -- *the* dialect? :
> ) -- that has them.
Well, that's why I thought better of it and explained how to retrofit
Smalltalk with them (in my self-reply). (But the "macro" term is
mis-applied - explained below.)
> Still, wouldn't you agree that it's better to use the less powerful tool
> when possible? Macros introduce a layer of code between the code you
> see in a browser and the code that actually executes, thus making
> debugging more difficult. Also, since macros are so powerful, it seems
> easier to accidentally do something really bizarre.
Well, you'll notice that I don't emphasize these as macros. They're
meta-syntactic, but that's it: just methods like anything else. The
examples that I most emphasize in the manual and probably will in general
are communication macros: adding annotations like type expectations and
comments to specific pieces of syntax is an initial example.
And to flavor this with a little pedanticism, strings are /more/ powerful
than syntax methods, because syntax methods have the "training wheels"
that make you follow at least some syntax rules. They're just more
powerful in the sense that you can do more complex things without worrying
about shooting yourself in the foot.
A syntax highlighting or pretty-printing system or other IDE feature does
nothing for you inside of a string. Also, the use-case that the question
had was a run-time code-generator, not a macro, so there's no magical
difference between source code and method; it's just meta-syntactic.
> IMHO, an aweful lot of Lisp macros should instead be higher order
> functions, and the only reason it isn't done that way seems to be
> because it is annoying to write down L A M B D A so much. In Smalltalk,
> happily, that temptation is not around because the block syntax is so
Yes, and Slate has no use for macros-as-syntax-assistants. Smalltalk
subject-verb-object-preposition-etc syntax works well enough. When I
translate Lisp code to Slate (and I do), I never need "macros" in Slate.
Their use is totally different: a matter of using syntax objects as
communications medium between the user and compiler.
This /is/ offtopic, of course, but that's my fault. Still, this is not
inconceivable, and a little friendlier than strings. :) It's one reason
that I picked a totally unused character for the syntax to make it clear
when using it. And of course it's a toggleable capability if you want to
arrange it that way.
Brian T. Rice
LOGOS Research and Development
More information about the Squeak-dev