There are a couple of issues with cstructs. A cstruct is similar to a struct, except Felix does not generate type definition, instead it assumes the cstruct is already defined in C as a struct or union.
That's the idea. Similar for other "c" prefixed things such as cenum. However there's a problem: cstruct X { .. } assumes there is a struct named "X" in C. So this mechanism fails in C++, if the type is defined in a namespace (which all of them will be). There's another problem. Consider a Posix structure called X. The Standard specifies it has certain members but sometimes it doesn't prohibit additional members, for example "dirent" the directory entry thingo. In this case it is not safe to construct the type with a componentwise constructor: you have to use a factory function provided by the standard, or initialise the members individually. The reason is that Felix currently takes a tuple and reinterprets it as a struct. This only works if the members are strictly 1-1. Either Felix must assign the cstruct members individually, or simply not provide a componentwise constructor. In addition it isn't possible to specify a finaliser for a cstruct. It currently gets a destructor, but this is overkill for some cstructs, and plain wrong for others, for example a mutex from Posix has a take down function which should be specified as a finaliser, a cstruct containing one (or, for that matter, a struct) will not invoke this function just by calling a destructor. The problem really is that Felix specifically *requires* a data type to be first class, which implies that a destructor is enough to take one down. in theory this means if you have one that isn't true for, you have to wrap it. The problem is that the wrapped value is no longer the right type to pass to a C function, eg a wrapped mutex is not the right type to call a Posix mutex function on. So the function would have to be wrapped too. So actually there are two kinds of cstruct: (a) One which is literally a struct, just don't generate it. The original idea. (b) One which is really a primitive opaque C type but where the members specify access functions in a shorthand way. These issues arose considering how to serialise a cstruct. What I propose to do: nothing at the moment, until I have a better plan. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_jan _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language