lua-users home
lua-l archive

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

Despite usual believe, it happens that Lua and C++ can have a very similar syntax.
I just discovered it. Consider the following code:

    f=print debug.setmetatable(nil, {__len=f,__lt=f,__call=f,__index=f})_=

    #include <iostream>
    #include <stdlib.h>

        enum { TRUE, FALSE, MAYBE };

        class {
            int (aMethod)(int, void);
            void (convertToFloat)(double[8], float[8]);
            double (getValue)();

        int (globalFunction) (void);

Is it a valid Lua program? YES, although it outputs essentially debug information.
Is it a valid C++ program ? No, but nearly !

-- Patrick Rapin
-- coauthor of "Le guide de Lua et ses applications", D-BookeR