lua-users home
lua-l archive

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


On Sun, Dec 9, 2012 at 3:34 PM, Jay Carlson <nop@nop.com> wrote:
>
> On Dec 9, 2012 12:58 PM, "Dirk Laurie"
>
>> This does not mean that I accept Jay's point about implicit parentheses —
>> but
>> Denis has taken that up, allowing me slink away quietly in disgrace.
>
> I'm ready to slink away too; the Scheme order-of-evaluation flamewar is
> about to arrive, and I hate all of it. So I'll throw this smoke grenade into
> the room to cover our escape:
>
> I can't remember which Scheme (Dylan?) proposal had a deterministic but
> pointedly unintuitive order, something like:
>
>   1. Even-numbered arguments are evaluated left-to-right;
>   2. The function expression ("0th arg") is evaluated.

Presumably car isn't a macro? Or a fexp in lisp-jabroni?

>   3. The odd-numbered arguments are evaluated right-to-left.
>   4. The function is applied to the arguments.
>
> This breaks code with false assumptions from other implementations yet is
> consistent between runs.
>
> Consider the following expressions: which are defined not to print hello?

Taking my previous comment about car in account, is having a defined
set of rules for parameter evaluation really useful in the proposed
alternative when you have to keep the cognitive-overhead of
distinguishing between a fcall and special forms? I mean, is the end
result really clearer than having a wild west posture on parameter
evaluation order?

As you allude to in this email, it's not a new subject by a long shot.
Any C programers here think the expression `f(x, x++)` doesn't provoke
undefined behavior?

I can't think of a single broadly used language that competes with C
that absolutely guarantees 1:1 source file expression order, but I'm
still conflicted because I would naively expect equality between `a=b;
c=d; f(a, c)` and `f(b, d)`. However, would I care about the order of
evaluation for a commutative operator, coming from the same naive
mindset? I wouldn't be on a position to make assessments about what's
pure and what's not; realistically speaking, I wouldn't be familiar
with the subject! So I can say, `..` and `+` are commutative, why do I
care about the order *anyway*

Once I understand side effects, my posturing becomes disingenuous. :)

>
>    return assert((nil)(), print("hello"))
>
>    return (nil)() .. print("hello")
>
>    return (nil)() .. (print("hello"))
>
>    return (nil)(), print("hello")
>
>    return (nil)() or print("hello")
>
> Jay