[AD] Update on `const' |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
Hi, Since we implemented `const'-correctness in the library, I have learnt several more things about `const', and gained some experience using it (both in my own applications and elsewhere). I have a couple of points which may be of interest: - `const' is C89. This means that probably every compiler we use accepts it, so we can do away with the ugly AL_CONST and just use plain const. If this does prove to be a problem anywhere, we can use preprocessor trickery to solve it. - Several functions have incorrect semantics, taking a const pointer but returning a mutable one. An example of this is `get_filename'. I suppose the idea behind it is that the function doesn't alter the string, so it is passed as `const', but the user might want to alter it afterwards, so it is returned as mutable. This is not really valid; in actual fact, in situations like this, we should have two functions: char* get_filename(char* path); const char* get_filename_const(const char* path); We have to treat `char*' and `const char*' as separate types. Ideally, I would like to change these two things, but I am unsure of where we are heading at the moment (new API, etc). What do you think? Bye for now, -- Laurence Withers, lwithers@xxxxxxxxxx http://www.lwithers.demon.co.uk/
Attachment:
signature.asc
Description: PGP signature
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |