lua-users home
lua-l archive

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


On Thursday, November 21, 2013 06:59:45 AM Paige DePol wrote:
> Yes, my misunderstanding. My latest thoughts on the switch statement is that
> I will probably turn the whole switch block into a closure.
> 
> This way I can patch the constant list generated for the closure so all the
> case constants are in order in the constant pool with no gaps, thus making
> the jump table as efficient as possible. This would also then allow nested
> cases should someone wish to do so.
> 

Now, if Lua had a computed goto, that would make this more interesting.

What would be the roadblocks to implementing that? Each function would need a 
table of names to instruction pointers. And maybe that's all?

  goto [value] -- cast value to string and jump

What happens with an invalid label? A runtime error, I suppose.

-- 
tom <telliamed@whoopdedo.org>