[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua5.0 new "For" question
- From: Björn De Meyer <bjorn.demeyer@...>
- Date: Sun, 22 Dec 2002 20:38:44 +0100
Peter Hill wrote:
/snip
> I see our aesthetic senses differ here. What do other people think?
To that I agree. Our tastes differ. If you really need this feature,
what's wrong with a pseudofuction keyword like, say, all()?
>
> Actually, no, you've completely missed the point. What I'm wanting is
> something like:
> function two() return 11,22 end
> a, b, c, d = #two(), 3, 4
>
> which sets
> a==11, b==22, c==3, d==4
> Ie, the "#" directive relates to the compiler operation of assembling
> arguments on the stack. The "#" overrides the natural "exp1" behaviour of
> truncate-to-1, something that can't currently be done.
Aha. So, in essence, it's about nonterminal function calls
being "adjusted" to a single result.
However, the question is, why would you want to say
a, b , c, d = two() , 3, 4
when
c , d , a , b = two()
does exactly what you want? As I showed in my
previous message, the for loop problem you saw
can be solved without using "#". What other practical
problems do you see?
/snip
> nres() didn't give the desired results. So what Lua5.0 construct will?
I admit I misunderstood you there. To solve the specific problem
of a, b, c, d = two(),3 ,4 you could again use a wrapper function,
like a,b,c,d = reverse(4,3,two()). But, I realise that that is not
a generic answer, and probably not what you have in mind.
> "Pure" is a very loaded term (with some nasty connotations I won't go into).
> As for "pure Lua", a language which regularly undergoes notable revisions
> can hardly claim (or even want) to be pure. The disappearance of upvalues
> and the new lexical scope thing (which I'm still coming to grips with) is
> hardly "language purity" from the point of view of a Lua4.0 vetran.
Of course, this is all subjective, and to that I admit.
We differ in taste yet again, so it seems. I disliked
the upvalues, and prefer the lexical scoping.
> As to "simple"... I agree that is an excellent goal to have. But, once
> again, exactly what is simple is not always black and white.
Yes, I agree, but again, simplicity is also a matter of taste.
> So how "unsimple" is the suggested '#'? Lua already provides both the "exp1"
> (discard down / pad up to a single value) and "exp" (keep all values)
> actions. It's just that only the final element of an expression list can be
> an "exp", while the others all have to be "exp1". That asymmetry is rather
> non-obvious to the novice programmer (hence I wouldn't call it "simple") and
> it also limits the programmer's options.
Ash, now I see what you ment. You are talking about the
assymetry between a, b , c , d = foo(), e and a, b , c, d = e, foo().
Yes, I agree that it would be better if that could be changed.
However, the way I see it, if we want to make function calls
orthogonal, a function's results should never be adjusted.
Always return all results. If you want only one result,
then you can say (foo()) already in Lua 5. if you want a numbered
amount of results, then nres(n,foo()) could then be used in
all places.
However, IIRC, there are problems in the Lua parser that make it
hard to have and exp in the middle or at the beginning of an
expression list. Which explains why we have to make do
with only having the final element of an expression list being
exp, whilst the other elements must be exp1.
> I personally consider it more "simple" (and symmetrical) having all elements
> of an expression list dealt with in the same way - defaulting to the "exp1"
> action, with a single character "exp" override.
Well, here we disagree again. I'd rather inverse the whole situation,
as we alreay have an operator that reduces an exp list to exp1, namely
().
> Yah, that does sound stuck up. Comments like "this is so ugly it almost
> makes me weep" about somebody's suggestions do not exactly endear them to
> open discussion.
Sorry. I must admit I misjudged the situation and you.
I jumped to the conclusion that you were a newbie who
wanted to change the language before really knowing it.
Of course, now I realise my mistake, and I apologise again,
in earnest.
> When I first encountered Lua a year or two ago I was quite enthused by it;
> it is a lovely language. I joint the List but, after making a reasonably
> educated suggestion and being cut off at the knees, I was so disgusted that
> I gave up on Lua completely for a while (a rather sad outcome).
I am sorry to hear that. I'm a techie, and I'm not that good
at communicating without causing friction. I try to be polite.
But I can get quite vocal about my tastes and ideas, and
I tend to speak in a very straightforward way, which sometimes
sounds unintentionally rude. Maybe I'm not the only one?
> You think it is "ugly"? I don't think so. And an off-the-cuff aesthetic
> judgement is hardly a reason to unilaterally silence the issue without
> discussion, especially when your proposed "fix" doesn't work.
>
> A discussion list should be a place to present ideas... not stifle them.
I had certainly not the intention to silence or offend you.
I had misjudged you. I hope we can put this behind us,
and focus on the problem at hand. I do want to help.
--
"No one knows true heroes, for they speak not of their greatness." --
Daniel Remar.
Björn De Meyer
bjorn.demeyer@pandora.be