[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: how expressive are they?



Avi Bryant wrote:
> > Yeah.  Now if only we could come up with a system that would allow us to
> > factor out all those brackets and colons - perhaps some kind of
syntactic
> > transformation...??
>
> Why?  On this small scale, I think Smalltalk's syntax hits the sweet spot.

I think that on this small scale, it may hit a sweet spot within the
limitations of Smalltalk's syntax.  However, since your examples were
intended as representative of larger examples, I was doing the same sort of
thing.  Imagine bigger examples, where it would matter more: where some
things might need to be blocks, and others wouldn't, and the reasons for the
distinction would be determined by the objects being invoked, so may not be
obvious or easy to remember for the caller.  Now you have syntax-heavy
expressions in which the syntax is only relevant or meaningful at a lower
level than where it has to be used.

> The brackets can't be factored out, because I might have a pre-existing
> block that I wanted to pass in (as opposed to a block literal).

Nothing prevents a language from having a block-based conditional form as
well as a syntactic one.  If we have macros, we can even build one or the
other ourselves - which somewhat contradicts your next point:

> I think macros are wonderful, but on a large scale (embedding DSLs,
> describing many function or class definitions in a few lines, implementing
> object systems), not as a way to make individual expressions more concise.

I see it being about more than just conciseness.  Beyond the most basic
issues of disambiguation, I want to know why the syntax is there, and in
most cases, if the answer is not something along the lines of "to make the
code more comprehensible, easier to use, easier to remember...", then I
think there's something wrong.

In these examples, it seems to me that the syntax is there to create
constructs that don't actually exist in the underlying language, and the
user has to create these constructs on each usage.  Reuse of syntactic
constructs is what macros are for.  I agree, that in the case of conditional
statements, Smalltalk more or less gets away with it.  But I think it's
suspect nonetheless, and I don't believe it scales.

Anton