lua-users home
lua-l archive

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


It was thus said that the Great Elias Hogstvedt once stated:
> Hi Kevin, I'm not sure I get what you mean. I agree with what you're saying
> about Lua but I don't see how this will change any of the behavior you're
> describing. pairs will still be pairs and tables would behave like they
> always did. Why do you need to know the type of the list? You are saying
> the type is irellevant but at the same time that it is relevant.

  What should happen with the following code?

	function process(list)
	  for i = 1 , #list do
	    print(list[i]) -- example code
	  end
	end

	foo = { one = 1 , two = 2 , three = 3 }
	bar = { 1 , 2 , 3 }

	process(bar)
	process(foo)

  Should process() throw an error on being passed foo?  Should it not do
anything?  There are valid arguments for both sides in this (in development,
it should blow up because it's most likely a bug; in production it should
do nothing and keep going).

  Yes, this is a simple example, but in a larger project, issues like this
can happen.  It's one of the issues I have with Lua---there are times when I
forget what's exactly in a Lua table I'm working with (in a large project)
and I long for something like C's struct definition where I can see what's
supposed to be in a table.  But that's not Lua so I have to make do with
that Lua is, not what I wish Lua could be.

  -spc