[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Switch/Case statements revisited
- From: "steve donovan" <steve.j.donovan@...>
- Date: Wed, 7 Nov 2007 15:13:57 +0200
On Nov 7, 2007 2:49 PM, Duck <duck@roaming.ath.cx> wrote:
> I think (and Steve and I were colleagues once, and hopefully chums still,
> so this is hard to say :-) it mostly sucks.
No worries, mate ;)
> A case statement which is only syntactic sugar for an equivalent if ...
> elseif ... elseif ... cascade? Why?
Because it looks and feels ugly? Tastes differ of course.
> I'd have thought that the most useful purpose of a case/switch is to
> indicate both to the programmer and to the compiler than you want to
> evaluate a specific sort of expression once, and then to base a range of
> divergent operations _on that already-calculated expression only_.
That's exactly the point.
> execution. But in many cases of switches, if performance is that important
> then a pre-initialised table with integer indices and dispatch functions
> for each index -- or some similar compromise -- will solve many efficiency
> issues in the Lua equivalent.
In which case, a switch statement is also the uglier solution ;)
>
> This case syntactic stuff seems a bit like luaSuper. OK, I can do all this
> extra and clever stuff...at the expense of letting a C++ compiler into my
> LuaLife. Is it worth it? Hmmmmmmmmmmmmmmmmmmmm. No.
In this case, you only have to let a little patch into your llex.c and
the rest is done in Lua, no explicit preprocess step.
> I can't resist it:
> 3. Run-time setting to instantiate variables at the innermost lexical
> scope ("local") by default, not at global scope.
Nah. That would be Python. You would then need the 'global' keyword
to indicate that it was _not_ local!
> 5. Extend "core and auxiliary" libraries to "core, auxiliary and
> optional." Core and aux to be ANSI-C _only_ (move shared library loading
> to optional). Include a range of popular (if not 100% portable) but
> PUC-endorsed libs in "optional." Start with luasocket and consider
> luathread.
Now that would be cool, since we all know and use the PUC libraries -
they are 'canonical' if I can get away with that word.
It would be nice, BTW, if luathread would actually work with 5.1 (hint)
steve d.