[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: '...' is a variable,who can explain
- From: "wj" <jiang_wang@...>
- Date: Fri, 12 Jan 2007 14:55:54 +0800
function f(...)
print(type(...))
end
f(1,2,3)
dose work.
look this
exp ::= nil | false | true | Number | String | `...´ | function | prefixexp | tableconstructor | exp binop exp | op exp
prefixexp ::= var | functioncall | `(´ exp `)´
... is invalid out of function block.is right?
----- Original Message -----
From: "David Burgess" <dburgess@gmail.com>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Friday, January 12, 2007 2:00 PM
Subject: Re: '...' is a variable,who can explain
It does raise the question of whether
type(...)
should return a value?
db
On 1/12/07, jason zhang <jzhang@sunrisetelecom.com.cn> wrote:
>
>
> function ::= function funcbody
> funcbody ::= `(´ [parlist1] `)´ block end
> parlist1 ::= namelist [`,´ `...´] | `...´
>
> ... means vararg function.
>
>
>
> ----- Original Message -----
> From: wj
> To: lua@bazar2.conectiva.com.br
> Sent: Friday, January 12, 2007 1:24 PM
> Subject: '...' is a variable,who can explain
>
>
> look at this code:
>
> --codes begin
>
> function joinFunc(f1,f2)
> return function (...)
> return f1(f2(...)) --...treated as a variable! is it maze!
> end
> end
>
> f1 = joinFunc(print,math.abs)
>
> f1(-2) --out:2
>
> --codes end
>
> why the
>