[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

>metatable meme >ipairs({k = 'v'}) doesn't

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 26
Thread images: 1

File: lua.gif (5KB, 256x255px) Image search: [Google]
lua.gif
5KB, 256x255px
>metatable meme
>ipairs({k = 'v'}) doesn't give you anything
>table.unpack instead of a splat operator

Why the fuck do people use this garbage
>>
>>58933434
Because they think it is well supported, while in reality PUC RIO does what the fuck they want and LuaJIT is becoming incompatible and dying.

They also use it for inappropriate things like game scripting, while it was never made for this and it shows.
>>
>>58933434
It's like a minimalist JS that's very easy to embed into other programs (at least compared to cluster fucks like Python and some/all JS engines).

>ipairs({k = 'v'}) doesn't give you anything
What should it do?
>>
It's mostly clean, minimalist, and most important of all: no fucking hipsters.
>>
>>58933434
>>58933515
It's used for scripting because there was no standard. Lua is/was the easiest to embed, with a very low footprint, and it kinda became the de facto standard because no one actually used one common language for this (companies usually created their own scripting language instead).
>>
>>58933537
>What should it do?
It's name implies it should perform some variant of pairs, perhaps sorted pairs. Instead it treats the clusterfuck that is a table only like an array, completely ignoring the non-numerical keys. Why would you mash together maps and arrays if you're just going to do this shit?

>>58933561
>mostly clean
Explain the clusterfuck that is tables, the PRIMARY data structure of Lua.
>no fucking hipsters
Maybe cause no one wants to fucking use it
>>
>>58933577
>companies usually created their own scripting language instead
I'm inclined to agree with them, given how well made Bethesdas and Projekt CD RED and some engine vendors custom languages are, but then again there is the mess that is doom scripting.
>>
>greenspun's tenth rule
Why is lisp not a standard for embedded scripting?
>>
Monkeys can't do anything properly, what did you expect?
>>
>>58933624
>Why would you mash together maps and arrays if you're just going to do this shit?
Probably because real world applications need their specific performance characteristics after all. I think most practical Lua implementations treat a continous sequence of keys 1..N as a special case that has some chance of remaining special as long as you only manipulate the "array" via the dedicated functions.

I guess autistic minimalism can be a breath of fresh air after the cluster fuck of JS and even worse languages, but this just feels like OpenGL cramming its existing functionality full of new and confusing behaviors because they didn't want to change too many things at once.
>>
Ruby memers out.
>>
>>58933938
Because there is no modern and appropriate lisp dialect for embedded scripting.
Also, there is no non-cancerous, bytecode based, non-GNU, non-cancer API interpreter.
>>
>>58934030
Define modern and define appropriate.
>>
>>58934050
>define modern
released in 2016 or later
>define appropriate
lightweight and easy to embed
DUH!
>>
>>58934088
Of what relevance is release date? Are you an Atom user?
>>
>>58934088
>answering for somebody else
who am i kidding i do that all the time
>>58934050
>at least common lisp tier
>small standard library with a clear distinction between safe host functions and - optionally loaded - unsafe host functions, supporting a standardized VM sandbox
>standardizes - as in from the beginning - but overwritable/opt-out import mechanism
Probably a lot more, but it's too late right now.
>>
>>58933434
>>ipairs({k = 'v'}) doesn't give you anything
ipairs is for integer keys (i.e. arrays), hence 'i'. pairs() is the iterator function you would use.
Learn to read the fucking documentation before you embarrass yourself.
>>
>>58934172
There are loads of lovely embedded Schemes with utilitarian standard libraries that are exposed to the child code optionally one by one.

The reason few projects embed a lisp is that barely anyone understands lisp.
>>
>>58933993
>Lua 5.0 uses a new
algorithm that detects whether tables are being used as arrays and auto-
matically stores the values associated to numeric indices in an actual array,
instead of adding them to the hash table.
>Performance
Seems like useless overhead to me.

>>58934202
So you're defending the choice of classifying arrays as a subset of unordered maps?
>>
>>58934247
Avoiding hashing is avoiding overhead.
>>
>>58934267
Have you considered that if arrays were their own construct, there would be no avoiding to begin with? The fastest code is no code.
>>
>>58934243
>There are loads of lovely embedded Schemes with utilitarian standard libraries that are exposed to the child code optionally one by one.
There are exactly two which aren't utter crap, Chibi and Guile and they aren't an option for reasons I mentioned.
>>
>>58934292
Have you considered that tables are to Lua almost as lists are to Lisp?
>>
>>58934247
>detects whether tables are being used as arrays
Is this where it all breaks down if you _want_ to store nil as an array element?
>>
>>58934336
Except lists are lists in lisp, not a forced combination of two unrelated data structures.
>>
>>58934395
How could I forget about the fucking dumb as shit nil meme? Thanks.
Thread posts: 26
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.