Re: [AD] namespace collision

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


>> Can I do something about `clear'?  I like the name `clear_bitmap'
>> (which, in a Freudianish way, I've typed before).  Here's what I'm
>> wanting to change:
>> 
>> (1) `clear' becomes `clear_bitmap' in source.
>> (2) `allegro.h' gets "#define clear(bmp) clear_bitmap(bmp)".
>> (3) You can switch off (2) with a #define before #include <allegro.h>.
>> (4) People who take the address of `clear' need to use
>>     `clear_bitmap' instead.  People who have member functions called
>>     `clear' need to do (3) and use `clear_bitmap'.
>> 
>> Please?
>
>If you like, but (2) is still a problem because of class methods
>called `clear' which must not be renamed (it affects the
>linking).

Then you can just switch it off by using option (3), right?

>If we go for prefixing, we could use inline functions for the
>old names, and require the user to use the new names if they
>need to do anything dodgy like take the address of a function.
>Can you see any problems with this?  The inline versions would
>only exist in allegro.h, optionally excluded by setting a
>define.  The huge advantage of inline functions is that the
>compiler understands context, so we won't damage class methods.

Nice! I think this actually solves all problems, doesn't it? Though I think
that there will be a loss in performance when calling a function from a
pointer, like in the dialog routines. Probably minor. How would you require
the user to use the new names when taking the address, by the way (and
doesn't that still break existing code?)
I think it would slightly slow down compilation as well, but again, this is
probably minor.

Still, for optionally prefixing the entire library, I really like this idea.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/