lua-users home
lua-l archive

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


Hi,

Luiz Henrique de Figueiredo wrote:
> 
> Lua 4.0 (alpha) is now available for downloading at

You did not get much response about the new version so I'll try to
give you some of my impressions ;)

First observations: it's really noticeable faster, the already clean
code got even cleaner, the re-entrant API is really nice, and the
new instruction format looks as made for a RISC CPU ;)

The points in detail:

- The Instruction type.  You defined it as unsigned long.  You realize,
that a long on 64-bit CPUs is normally 64 bit?  I guess, an unsigned int
would fit better.  I don't no any _relevant_ architecture where an int
is less than 32 bit (and then, these systems probably want a 16 bit
instruction format *g*).

- You wrote "+ reduced memory usage" and I was surprised to find that
tables take 17-25% more space.  I was very skeptic when I first saw
new hashing routines (I've an uneasy feeling when filling hashes up to
100% *g*).  I took some profiling and saw that especially luaH_set
is really faster (464->334 avg clk cycles).  I just hope, that the
additional memory for management is compensated by the high fill rate.

- Another thing with tables: there is still a problem with entries whose
values has been set to nil.  The reference of the key stays until the
table is rehashed.  That leads to memory/object leaks.  I would suggest
to clear the keys of nil'ed entries during the marking phase of the gc.

- I did not like the idea of the "repeat ... end" and I'm glad that it
didn't made it into 4.0 *g*

- Now to the for-loops.  I guess that most people - when hearing that
4.0 has for-loops - thought about looping over tables and I was very
disappointed to realize that you only implemented numeric style loops.
Yes, numeric loops are useful but don't you think that iterating over
tables is even more wanted?  If you did not have enough time: just
ask for it and I will write an implementation!  IMHO, there should be
no 4.0-final without _real_ for-loops.

- Another thing with for-loops.  Why did you to made the iteration
variable an automatic local?  I considered this while implementing
for-loops for 3.2 but discarded that idea pretty fast.  It's too ...
inconsistent!?! ... special? ... ugly!  Look at this:

	n="foo"				-- global n
	print(n)			-- foo
	for n=1,3 do print(n) end	-- 1 2 3
	print(n)			-- foo

Ok, sometimes it may be easier to not have to write the "local n" and
the generated code saves one instruction but it looks so ... wrong.

- About the break I have to repeat myself:  I don't like the concept
of break-labels.  If you want labels, add a goto but not a break.
If you want a multi level break, use break-levels.  Sorry.

- The multiple state stuff is great.  It would be even nicer if one
could share the memory/objects of different instances of the inter-
preter.  If one would split up the lua_State struct at the "global
state" comment and let multiple upper parts use the same lower part
you could do really nice stuff (i.e. co-routines, cooperative multi-
tasking, ...).


Ok, that's all for the moment.  If some points sound too negative
then excuse me.  I just want to give you some feedback and it's
only what I think/feel about it.  You've really done a great job
with 4.0a.

Ciao, ET.