> 11.04.2011 14:00, Alex Peshkoff wrote: >> On 04/11/11 15:21, Dimitry Sibiryakov wrote: >>> You are talking about using structures (actually, pointers to them) in >>> new API, right? Passing pointers to structure to interfaces doesn't mean >>> that user has do >>> work with these structures' members directly, AFAIU. >> >> Certainly, one can safely pass any pointer to interface if it is only >> passed, no access to it's internals is attempted. >> The problem is that with mentioned class Message there was need to work >> with members directly. > > Specifically for this task structures can have methods.
We talk there about API *declarations*. API *declarations* ideally shouldn't have code else it will be hard to port it into another language. As for struct\interface choice : - struct should be as simple as possible to avoid problems with different alignment rules of different compilers\languages - struct used as array member should be even more simple to avoid problems with different rules of array member alignment - struct is very hard to extend in the feature and it have no versioning (many structures in Win32 API have fixed first field used for versioning, user *must* fill it with sizeof(struct) value, btw) - interface (pure virtual class) are free from issues above but direct access to the interface "members" is impossible and costs virtual function call So, we can use struct, yes. But in very limited places. Hope it is more clear now, Vlad ------------------------------------------------------------------------------ Xperia(TM) PLAY It's a major breakthrough. An authentic gaming smartphone on the nation's most reliable network. And it wants your games. http://p.sf.net/sfu/verizon-sfdev Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel