A new keyword 'cfun' can now be used to define a function: //////////////////////////// #import <flx.flxh>
cfun fff(x:int)=>x + 1; print$ fff 22; endl; fun apl(g:int-->int,x:int)=> g x; print$ apl$ the fff,22; endl; var q = the fff; print$ apl$ q,22; endl; /////////////////////////// As the name suggests, a cfun generates a plain C function with the expected type, in the example: fff: int --> int which will generate int fff(int); More precisely, this is a C++ function not an extern "C" one. A cfun cannot access any variables other than its paramaters and locals. It cannot access data in the thread frame and thus cannot use the garbage collector. Unless of course these are explicitly passed. yes, a C function can access C globals: body "static int x = 1;"; const x: int = "x"; cfun get_x(){ return x; } Such a function is suitable for use where a C callback is required. It is also suitable for building libraries of 'ordinary' C++ functions which can be used by ordinary (non Felix) C and C++ code. C functions CAN use union (struct _uctor_) objects, for example you CAN use a match inside a C fun. You can also call Felix procedures and functions, however you cannot create heap closures, since that requires the collector. 'cproc' isn't done yet but will be shortly. At this stage, there is no error checking: if you try to use the garbage collector or thread frame, you will probably get a C++ compiler error, not a Felix one. To be fixed. Note that a cfun can be passed as an argument, and is just the usual C function pointer. Finally note that cfun's get inlined just like any other function. Yes, cfuns can be polymorphic.. and their instances will be cfuns. Note: there is no assurance a cfun will have the given name at the moment, it would need to be exported, which will generate an extern "C" wrapper. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language