[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...)
- From: Doug Rogers <doug.rogers@...>
- Date: Thu, 03 Dec 2009 21:32:12 -0500
Norman Ramsey wrote:
> > And other line noise looks like line noise only if you've never seen C.
> Come on, David---be fair. ...
> I agree that Lua's goal is not to *maximize* information density.
> I believe Lua's goal is *appropriate* information density: there
> should be enough keywords to guide beginners, but for experts, there
> is not too much syntactic noise. And I do think that in the case of
> anonymous functions, Lua's design is out of balance...
I'm with you, Norman. I would love to have a concise form for function
definition. I've found '|args|expr' to be beautiful and sufficient for
my experiments with gsl-shell; so much so that I miss it when I come
back to plain Lua, even when writing scripts or larger programs as
opposed to an interactive shell. If this particular form suffers from
ambiguities or surprises then perhaps some other form will work.
I can see David's point about adding precedence levels (implicitly or
not), but clearly there's a balance to be reached. My personal opinion
is that this syntactic sugar would be nearly as useful as the colon
operator - possibly more so for me. And I think Lua would remain in
balance with this feature.
I'm generally not a fan of adding features to Lua. I initially found
metatables (especially putting all the operator functions in them) to be
too much of an excessive change! I mean, why not just use prototyping
tables and explicitly fill them? (Don't answer that rhetorical question!)
The features I've really missed over the years are the bit-wise
operators, hexadecimal escape sequences, and hexadecimal numbers. It has
taken a long time, but now we have hexadecimal numbers. It looks like
we'll have bit-wise functions as a standard library in 5.2, possibly
even hexadecimal escape sequences. All are trivial - yet they *do* add
to the code base. I always applied a patch for these features because
they were so much of a benefit to my work, and the patch was so simple
that there was no question about where the balance tipped.
But we can all try this feature in our own way. Eventually the authors
will determine what goes in 5.2. Although I like this mod, I'm not
holding my breath for it.
The good news for you, David, is that the more verbose form will still
be available. And the good news for us is that, even if it is not in
5.2, it's easy enough to add. We just won't be able to share scripts.
But even that might not be true. If 5.2 includes a standard interface
for token filters, or for the components necessary for Metalua, then
there will be no more griping about simple syntax mods. We'll just use a
Lua-only module that provides the syntactic sugar we crave. (Yes, and we
might suffer the explosion of weird looking "code" seen in the abuse of
macros or templates.)
I apologize for the essay, but I wanted to add one more comment.
I've learned much from this list. I've also seen the authors themselves
grow as they have encountered new ideas from this mailing list (among
other places, of course). They've learned about proper lexical scoping
for proper closures, about how to make a VM that will operate more
quickly on modern CPUs, about properly encapsulating the Lua state, etc.
And along the way I think they were been bitten by the functional
That bug spreads a good kind of disease! I'm not a believer in the
mantra that all languages lead to LISP, but I do think that LISP's
simplicity (more than its proximity to lambda calculus) makes it a prime
environment in which to determine the *essential* elements of a
programming paradigm or feature. So there are many lessons to be learned
and many techniques to be applied by studying LISP, Scheme, Haskell, etc.
This proposed feature is just another one to be evaluated by them. But I
believe that the authors are in a better position now to determine
whether this form is worthy of inclusion in Lua proper, or whether some
even more general feature will be included that provides '|args|expr' as
a simple Lua add-on. Or neither. After all, there will eventually be a
I'm willing to wait.
PS - The short post: +1
The information contained in this email transmission may contain proprietary and business
sensitive information. If you are not the intended recipient, you are hereby notified that
any review, dissemination, distribution or duplication of this communication is strictly
prohibited. Unauthorized interception of this e-mail is a violation of law. If you are not
the intended recipient, please contact the sender by reply email and immediately destroy all
copies of the original message.
Any technical data and/or information provided with or in this email may be subject to U.S.
export controls law. Export, diversion or disclosure contrary to U.S. law is prohibited.
Such technical data or information is not to be exported from the U.S. or given to any foreign
person in the U.S. without prior written authorization of Elbit Systems of America and the
appropriate U.S. Government agency.