[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: [new feature proposal for versions after 5.0 final] passing argum ents to chunks
- From: "Bilyk, Alex" <ABilyk@...>
- Date: Fri, 21 Feb 2003 12:50:11 -0800
This feature can be implanted in Lua. Why should it be a part of Lua itself?
Here is one way to do this (this is in pseudo code).
--=======================================================
function do_string_with_parameters(s, ...)
local f = load_string(s)
local gt = getglobals(f)
local chunk_arg = gt.chunk_arg
gt.chunk_arg = arg - chuck_arg can be used inside f()
local ret_value = f()
gt.chunk_arg = chunk_arg
return ret_val
end
Inside f one would say something like this
if(chunk_arg and type(chunk_arg) == 'table')
then
-- process parameters. E.g.
local i = 1, n = chunk_arg.n
while(i <= n)
do
print (chunk_arg[i])
i = i + 1
end
else
-- set some values by default or generate an error/warning
end
--=======================================================
Is there anything wrong with doing it this way?
AB
-----Original Message-----
From: Szabolcs Szasz [mailto:sz@szasz.hu]
Sent: Friday, February 21, 2003 12:21 PM
To: Multiple recipients of list
Subject: Re: [new feature proposal for versions after 5.0 final] passing argum ents to chunks
Well, OTOH, I still prefer the bloated Windows XP
to the tiny Windows 3.1 (even though I loved when
I could squeezed it onto a boot floppy along with
my app, in the good old days...) ;-o
Sab
----- Original Message -----
From: "Abisoft opetusohjelmat" <info@abisoft.fi>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: 2003. február 21. 21:08
Subject: Re: [new feature proposal for versions after 5.0 final] passing argum ents to chunks
>
> What would be the use of this - can you give any real-world example?
>
> I've read (a long while back) mr. Stroustrup's book on evolution of
> C++. He refused to bring in any features that couldn't be proven to be
> required in real-world scenarios. Just because something is elegant
> doesn't mean it needs to be in there! Also, he first tried to find (as
> Luiz did) existing ways of fulfilling the requested behaviour. Only if
> this failed (and the need was real) was the new feature considered.
>
> And even so, C++ has become somewhat overbloatet...
>
> Every additional feature also adds to the learning curve, documentation
> pages, etc. etc. For this reason, I actually still like Lua 4.0 more
> than 5.0 beta. Lua 4.0 fits in my mind and stays there even the
> following day. :)
>
> -ak
>
>
> Benoit Germain kirjoittaa perjantaina, 21. helmikuuta 2003, kello 11:00:
>
> > Hello,
> >
> > I know that 5.0 final is is feature freeze status, but then, the sooner
> > proposals are in the pipeline for the next version the better :-)
> >
> > So, here it is:
> >
> > Basically, passing a script or precompiled buffer to the parser
> > results in a
> > lua closure left on the stack of the lua state. Actually doing what the
> > buffer defines is done by calling it. My suggestion is to enable
> > argument
> > passing, as is possible for any "regular" function call (currently it
> > is
> > possible to call the resulting function with arguments, but of course
> > these
> > are ignored because the chunk has no means to access them). Of course
> > this
> > requires a syntax addition which could look like :
> > chunkparams <param list>
> > ...
> >
> > Most probably nothing but comments or empty lines can be allowed
> > before the
> > chunkparams statement, which acts just like the parameter list in a
> > function
> > declaration. As far as I can tell, this would not require any change
> > in the
> > virtual machine, but only in the parser, to modify the closure's
> > prototype
> > and account for these variables during compilation.
> >
> >
> > Any thoughts about this ?
> >
> >
> > Benoit.
> >
>
>