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>

    namespace
    {
        enum { TRUE, FALSE, MAYBE };

        template<T>
        class {
        public:
            int (aMethod)(int, void);
            void (convertToFloat)(double[8], float[8]);
        protected:
            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