lua-users home
lua-l archive

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


On Tue, Feb 28, 2012 at 1:32 PM, Fabien <fleutot+lua@gmail.com> wrote:
> On Tue, Feb 28, 2012 at 2:41 AM, Jay Carlson <nop@nop.com> wrote:

>> I don't think anybody's been talking about a functional programming style.

> Fair enough. However, I believe that if you introduce terse and tempting
> lambdas in the language, then you're going to entice people into writing bad
> functional-ish code.

Smalltalk-80 blocks resembled closures but were not first class
values; they were stack-allocated. (I remember bumping my shins on
this before implementations fixed it.) Ruby syntax wants you to use
blocks a particular way. So I guess both of those languages threw
stumbling blocks in front of a functional style.

> One of Lua's goal is to be beginner-friendly; it
> doesn't only mean its grammar must be easy to grasp, it also means it
> shouldn't tempt beginners into writing unnecessarily awful code.

Greg Hudson made assignment a statement in one language; this
predictably enraged the C-heads, who really wanted to write

    while ( (c = getchar()) != EOF) {} ...



>
> There are advanced stuff in Lua (metatables, coroutines, first class
> environments etc.), but it's very natural to write code without even knowing
> about them, and they aren't tempting at all to beginners. If you introduce
> lambdas, you'll want to expose them to casual users.
>
>>
>> Given you went to the trouble of building the pattern match syntax, you
>> should consider how verbose anything like it would be in base Lua.
>
>
> I wouldn't call the result "beginner-friendly", and I certainly wouldn't
> advocate back-porting it into plain Lua :) I realize that delayed execution
> is a desirable feature, and if there's a beginner-friendly way to introduce
> it in the language, I'm all for it. But I'm afraid that terse lambdas would
> have unintended side effects in many hands.
>
> PS: Thunks, in an imperative context, are probably more akin to
> continuations than to lambdas; but I don't know what to make out of this
> remark.