The latest version of Felix now allows you to use some C like syntax for * parameters * function and procedure definitions
///////////////////////////////////////////// #import <flx.flxh> open syntax cstuff; // to get the C grammar fun f(int x, long *y, z:int):int = { return x + int(*y) + z; } var x = 5L; println$ f (3,&x,5); void g(int x, long *y, z:int) { var a = x + int(*y) + z; println$ a; } g (3,&x,5); int h(int x) { return x + x + 1; } println$ h 7; //////////////////////////////////////////// Please see lib/nugram.flxh for details the supported grammar. Because it may lead to ambiguities, the syntax is not opened by default .. the name 'cstuff' is sure to change .. :) You should note: * Only basic C types and pointers thereto are supported * you can use the keywords struct, enum, union, or class for any other type name (even if they're not .. the keyword is just there for parsing) * the generated code is still FELIX code -- this is just Felix with C syntax * Unlike Felix, by default C parameters are vars, that is, they're mutable. If you want to pass an immutable val, use the 'const' keyword: void f(int const x) { x++; // ERROR, modify x The const keyword must be correctly positioned AFTER the type and before the parameter. 'const int' is not correct. [It isn't correct in C either, but it's accepted has a hack] * Because it is Felix code .. you can do nested functions etc and it works.. :) **** LONG TERM **** If enough of this gets working, we have a 'better C'. Should be good for C/C++ programmers. More to do includes typedefs, structs, and variables. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language