[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A proposal for the confusing pseudo table ≈ array concept
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 22 Jan 2018 07:08:54 +0200
2018-01-22 4:36 GMT+02:00 KHMan <keinhong@gmail.com>:
> Here is another perspective on tables with more accessible wording: Many of
> us have been 'trained' using standard data structures coursework material.
> In a way everybody does think arrays and hashes separately -- I think of
> them separately when using other languages. But that does not short-circuit
> my brain when I switch mental modes to coding Lua.
>
> Lua is scripting language, it is more dynamic and malleable than say,
> compiled languages or languages targeted towards JIT. Lua tables simply sits
> at a higher abstraction than traditional data structures. That's why I
> always think of the word 'lookup'. The data structures coursework, those are
> more at a for-compilation abstraction level (notably, with examples in
> C/C++/Java.)
>
> Let's say, I have an idea of generational tables. So I implement tables
> using red-black trees as a back-end option to get always-sorted tables and a
> no-op when sorting the table. It doesn't change the abstraction that is the
> Lua table. But well, the table abstraction may not be the ideal thing if one
> wants (or expects) everything to be boiled down to run in lean and mean
> machine code close to metal.
I use stock Lua as my hammer for everyday tasks [1]. What counts is the
number of minutes it takes from when I sit down to when I have the results.
Several things contribute to those minutes:
1. Typing in the code.
2. Thinking while I type.
3. Consulting the manual.
4. Running the code.
5. Debugging
I find that having only one data structure cuts down on items 2 and 3.
I also find that if item 4 contributes significantly, then I have not really
understood the problem yet (or it is really very tough).
I also find that I think about my problem in terms of Lua tables.
It's the rule rather than the exception that my tables conceptually
have a sequential part and a hash part, and I would find it a pain
to translate my code into a language that does not support
Lua's model of a table as a mapping from almost any Lua
value to almost any other Lua value.
Roberto said the other day that tables are the bread-and-butter
of Lua, and if we demonize them, there is nothing left. Amen.
[1] Anything from indexing my music to solving Project Euler [2]
problems.
[2] https://projecteuler.net/
- References:
- A proposal for the confusing pseudo table ≈ array concept, Elias Hogstvedt
- Re: A proposal for the confusing pseudo table ≈ array concept, Jean-Luc Jumpertz
- Re: A proposal for the confusing pseudo table ≈ array concept, KHMan
- Re: A proposal for the confusing pseudo table ≈ array concept, Elias Hogstvedt
- Re: A proposal for the confusing pseudo table ≈ array concept, KHMan
- Re: A proposal for the confusing pseudo table ≈ array concept, Sean Conner
- Re: A proposal for the confusing pseudo table ≈ array concept, Petri Häkkinen
- Re: A proposal for the confusing pseudo table ≈ array concept, Elias Hogstvedt
- Re: A proposal for the confusing pseudo table ≈ array concept, Petri Häkkinen
- Re: A proposal for the confusing pseudo table ≈ array concept, Elias Hogstvedt
- Re: A proposal for the confusing pseudo table ≈ array concept, Petri Häkkinen
- Re: A proposal for the confusing pseudo table ≈ array concept, Andrew Starks
- Re: A proposal for the confusing pseudo table ≈ array concept, Elias Hogstvedt
- Re: A proposal for the confusing pseudo table ≈ array concept, KHMan