lua-users home
lua-l archive

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

On Sat, Feb 06, 2010 at 09:57:46AM -0800, Mark Hamburg wrote:
> On Feb 5, 2010, at 12:49 PM, Majic wrote:
> > Personally, I like how verbose Lua is...  makes things (at a glance to
> > new programmers) pretty self-explanatory. :>
> There's an interesting balance between approachability and avoiding
> having meaning hidden with syntax. Converting syntax into special
> characters frequently leads to cryptic constructs. On the other hand
> is easier to read than x[ "foo" ].
> This discussion keeps coming up because if you write code that
> frequently involves essentially short lambda-expressions, then
> "function" and "end" start to take up an excessive portion of the visual
> weight. 

So here's an idea.  The programmers who want a short lambda expression
are probably have significant programming experience.  And so, they
are probably using an editor that is popular for programmers.  And
those editors tend to be highly customizable and programmable

So would it be possible to have the editor itself fold the existing

	... function (x, y) return x + y end ...

into this:

	... |x, y| x + y ...

automatically?  The standard form would be what is stored in the text
source code file, but the short form is what you would see.

I don't think the folding would require complicated parsing, because
you'd only want the folding done for short anonymous functions that are
only on one line anyway.  Anything longer than that, and you don't
really need it to be folded anyway.

Anyone who _really_ wants the short lambda can apply the power patch
for their own code, or just use MetaLua.  But this would be a way for
those people who didn't want to take either of those steps.

Best regards,