lua-users home
lua-l archive

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


Shmuel Zeigerman wrote:
> Gregg Reynolds wrote:
>>
>> There's something I'm not understanding about dofile.  The manual says:
>> " Returns all values returned by the chunk"
>>
> The chunk (the entire body of a file) is considered a function. So it
> can explicitely return something, e.g.
> 

Ok, so there must be a problem with using methods.  If my file says sth like

	return { x = 5 }
or
	return { "a", "b" }

then I get a table from dofile as expected.  But my file says sth like

	return {
	  q:foo{ id='x1', ...}
	  q:foo{ id='x2', ...}
	...
	}

and when I run dofile, I get this sort of thing:

 test.ldf:13: '}' expected (to close '{' at line 1) near 'q'
stack traceback:
        [C]: in function 'dofile'
        stdin:1: in main chunk
        [C]: ?

Just to complicate things, if I have only a single q:foo{...} expression
in my file, then everything is copacetic - dofile returns the expected
table.  But as soon as I add another q:foo, I get the error.

I would expect an array holding the values returned by the q methods.
The object q is just a holder of methods, defined before I call dofile,
just so I can say q:foo etc. (think xml Qnames).  It works just fine
without the "return {...}" wrapper, so I don't think it's a syntax
problem.  Any ideas?  I'm flummoxed.

thanks,

gregg