[Metalua-list] Vararg in match

Alexander Gladysh agladysh at gmail.com
Sat Sep 13 14:54:59 GMT+2 2008


Hi, list!

Naively I wanted to use vararg in match block. Silly example:

require 'walk.id'

-{ extension 'match' }

local foo = function(ast)
  match ast with
    | `Id { ... } -> print(select("#", ...))
    | _ -> print("2")
  end
end

local ast = assert(mlc.ast_of_luastring("print(3)"))
walk_id.guess({ id = { free = foo } }, ast)

This gives quite unfriendly error:

/Users/agladysh/metalua/bin/lua: compile.lua:1077: No vararg in this function
stack traceback:
	[C]: in function 'assert'
	compile.lua:1077: in function 'parser'
	compile.lua:1052: in function 'expr'
	compile.lua:371: in function 'explist'
<...>

Is it possible to use varargs in match block? (It seemed intuitive.)

Alexander.



More information about the Metalua-list mailing list