On Mar 2, 2015, at 21:17 , Jens Alfke <[email protected]> wrote:
>
> The hacky C equivalent would be to put your function in a .h file, again 
> using “T” instead of “int” or “float”. Then when you need the int version do:
>       #define T int
>       #include “myfn.h”
>       #undef T
> Etc. for float.

It seems to me this would be quite tricky to get right, because you couldn’t 
have any extern functions (or any methods) that take arguments of type T or T*, 
because the resulting function names (or method selectors) would be duplicated. 
Static functions would still be possible, provided you put the different T 
versions in different source files, but that seems like it would escalate the 
duplication in other ways.

I guess you could use token pasting to make function/method names unique, but 
then you’d still likely want to use macros to invoke the various names without 
too much pain.

All in all, I’d agree that any rational person would do better to copy/paste 
the code instead.



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to