Re: An illuminating experiment using platform().

new topic     » goto parent     » topic index » view thread      » older message » newer message
Jim C. Brown said...
Shawn Pringle B.Sc. said...

Seriously, there is little cost involved using platform() as compared to say ifdef with the correct parameters. I wrote a seven line program called example: <snip> The branches that include platform() = to other platforms are not even included.

There is absolutely no branching cost of using platform() rather than ifdef when translating to C.

Shawn Pringle B.Sc.

Agreed. However, platform() has two flags which make it inferior to the platform detection support available via ifdef.

First, ifdef supports using UNIX and making finer distinguishment via LINUX/FREEBSD/OSX (and perhaps more to come). platform() is inconsistent, with the builtint version only separating OSX from UNIX.

Second, platform() is inconsistent. The machine_func(53) call will return a 3 on OSX but the builtint platform() returns a 4. At one point in time, both versions of platform returned a 4 for FreeBSD.

It is possible to clean up platform() and give it the ability to tell you if you are just on a UNIX, or tell you more fine grained information (linux vs osx vs bsd). This will never happen since we have the ifdef system now.

You give some good examples of how flexible ifdef is: Especially for DEBUG and defining functions. It is not a question of speed but flexibility of what you can do at parse time.

You haven't explained why anyone should care if machine_func(53,{}) and platform() return the same result or not. Who has ever heard of machine_func(53,{}). I don't think it is necessary and I do think it is a bad idea to remove something that already exists and is relied on just because there is a more capable method now.

It is rather analogous to banning radio because people can go buy tvs.

Shawn

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu