lua-users home
lua-l archive

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


Technically, since function whatever() ... end is just syntactic sugar
for whatever = function () .. end, perhaps just using () should become
a way to denote a function?  Since {} is used to denote a table,
perhaps you could do whatever = () ..end.  However I still prefer
being as verbose as possible about my types, and i don't like the
|param1, param2| ickiness that stems from Ruby.  Who knows... just a
thought...  I pride Lua on being as verbose as possible (within
reason), so I'm not really pushing for a way to help other scripters
be lazy typists :p

Regards :)

On Sat, Feb 6, 2010 at 12:21 PM, James Graves <ansible@xnet.com> wrote:
> 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
>> x.foo 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
> themselves.
>
> So would it be possible to have the editor itself fold the existing
> syntax:
>
>        ... 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,
>
> James
>