lua-users home
lua-l archive

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


I would like to Luiz's token filter facility in order to
add runtime function argument type checking in some Lua
code, e.g something along the lines of :

function F(x :: integer, y :: float)
  ... do something useful ...

This type checking would be optional. Of course, it would
not be limited to integer or float, ideally I would like
to be able to define my own types.

Is it a good idea to use token filtering ?
Does someone already did something similar ? (don't want
to reinvent a wheel !)

Anyway before starting anything interesting, I have a first
problem : the token filter patch doesn't work as I expect ;
I just compiled a brand new Lua 5.1.4 with the patch and tried
fdebug.lua ; here is what I get :

Lua 5.1.4  Copyright (C) 1994-2008, PUC-Rio
> dofile("fdebug.lua")
> print(1+2)
FILTER  =stdin
FILTER  1       <name>  print
FILTER  1       (       nil
FILTER  1       <number>        1
FILTER  1       +       nil
FILTER  1       <number>        2
FILTER  1       )       nil
FILTER  1       <eof>   nil
> print(1+2)
FILTER  0       <eof>   nil
FILTER  0       <eof>   nil

Why the second "print" is not displaying the same
output ??? I find this very confusing.

Thanks in advance for any help,