lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


diffs-lua-5.2.0-alpha-beta-rc1.txt wrote:
> goto, bit32.extract, bit32.replace, load with env, table __gc,
> fractional hex constants, rawlen, ...

ooo

> goto

When a single goto exists inside a conditional block, some of the
JMP's are superfluous:

local x = 1
@a:
if x > 1e8 then goto e end
x = x + 1
goto a
@e:

-- equivalent
local x = 1
while not(x > 1e8) do
  x = x + 1
end

$ luac -p -l test.lua

main <t.lua:0,0> (12 instructions at 0x9e0cb78)
0+ params, 2 slots, 1 upvalue, 2 locals, 2 constants, 0 functions
	1	[1]	LOADK    	0 -1	; 1
	2	[3]	LT       	0 -2 0	; 100000000 -
	3	[3]	JMP      	0 1	; to 5
	4	[3]	JMP      	0 2	; to 7
	5	[4]	ADD      	0 0 -1	; - 1
	6	[5]	JMP      	0 -5	; to 2

	7	[8]	LOADK    	1 -1	; 1
	8	[9]	LT       	1 -2 1	; 100000000 -
	9	[9]	JMP      	0 2	; to 12
	10	[10]	ADD      	1 1 -1	; - 1
	11	[10]	JMP      	0 -4	; to 8
	12	[11]	RETURN   	0 1

> bit32.extract, bit32.replace

It's curious that these are 0-indexed given
http://lua-users.org/wiki/CountingFromOne .  However, 0-indexing is
conventional in bitops.

> luaL_execresult, luaL_fileresult, luaL_getsubtable, luaL_newlibtable, ...

(shrugs)

> <code>modname</code> and an extra value dependent on how it got the loader.
> (If the loader came from a file, this extra value is the file name.)

I'm not sure it's good design practice for modules to know where they
were loaded from.  Module packers like preload/squish can transform
modules that are files into modules that are not files:

  http://loop.luaforge.net/release/preload.html
  http://matthewwild.co.uk/projects/squish/home

> [package.loaded] is only a reference to the real table;
> assignments to this variable do not change the
> table used by <a href="#pdf-require"><code>require</code></a>.

Probably good for sandboxing.

> We use the term <em>sequence</em> to denote a table where all
> integer keys comprise the set <em>{1..n}</em> for some integer <em>n</em>,
...
> In that case, the list must be a proper sequence
...
> in the array lst

list, sequence, proper sequence, array?  Is the usage of these terms consistent?

< error handler <code>err</code>.
> message handler <code>msgh</code>.

Rationale for the terminology change?

> 6.5 - Table Manipulation [...]
> a __len metamethod (see §3.4.6).  For performance reasons, all table
> accesses (get/set) performed by these functions are raw.

Why is the length operator not likewise raw in table functions?