On 18-12-2010 12:03, Philipp Gesang wrote:
On 2010-12-18<01:50:29>, Philipp A. wrote:
<snip lines="some"/>
well, i just like it. and since i don’t know lua (well, that’s not exactly true, but i can’t write a normal sized script without looking things up), and tend to do things like i would do them in other languages i know. e.g.: how do you loop elegantly over table values? “for k,v in pairs(t) do print(v) end” creates a throwaway variable k, which doesn’t seem right. some things
Depending on whether you want to access the non-hashed content as well you might want to use the “next” iterator instead as it’s slightly faster (according to my tests, that is). You won’t get around the local variable, though; I have no clue and no time to check if it’s even technically feasible to iterate a hash table without accessing the hashes.
indeed, for k, v in next, sometable do ... is faster as it saves one function call (i.e. pairs returning the next, table) for indexed iteration using for i=1,n do ... is much faster than ipairs as it involves no function calls
are totally counter-intuitive for me like tables beginning with index 1, and so on.
Feels natural after some time, I guarantee. And you’ll never look the same way at a fencepost again …
indeed, I also like the start at 1 very much, as you say .. natural
What you’ll miss most is all the nice shortcuts and syntactic sugar like “setdefault(k,[]).append(v)” (two lines in Lua) and the lazy handling of arrays, strings&c. as sequences that can be iterated over like it was all the same, and probably the error handling. Nothing you can’t live without.
and often you can roll out your own without carying the truckload of (mostly soon forgotten) lib code
Anyhow, I don't like languages that need religious arguments to become popular.
or are you talking about lua having been invented at a catholic university and thus being a product of a sect somehow?
Never looked at it that way. There should be a “fun facts” section on the wiki to list all the confusing mysteries surrounding context.
I was refering to python related religious (with the programming language being the gospel) discussions, so far I never ran into a lua one. All those 'one should use this language over that' or 'this operating system over that one' are wasted on me as languages come and go, as do operating systems and related concepts. Pointless discussions when seen over a 1000 year period of time. Printing used to be done using wooden blocks and that was high end and the best at some point, then came lead (too poisonous now), then film (short fashion), now ...
Regards, Philipp
PS:
kross is the project for bringing consistent scripting to KDE, and it is just awesome, since it allows you to write stuff in the scripting language of your choice.
like .net
Apart from being OT, you can always switch to a window manager that uses your favorite scripting language instead -- mine has Lua inside which is a lot cleaner than doing configuration in e.g. bash or something.
sure, and performance seldom is an issue I guess on todays machines. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------