version(number) is completely useless

Walter Bright newshound2 at digitalmars.com
Sat Jul 23 20:12:29 UTC 2022


On 7/22/2022 9:24 PM, Andrey Zherikov wrote:
> Unfortunately as you know people don't care about what you discourage or 
> encourage. People just try to express their intent using those language structs 
> that are the best for their needs and nothing prevents them from writing this 
> right now:
> 
> ```d
> static if (defined(_MSC_VER) && (_MSC_VER > 600) && !defined(__INTERIX))
> {
>    static if(defined(_WIN32_WCE))
>       alias fdopen = (fd,mode) {}; /* No fdopen() */
>    else
>       alias fdopen = _fdopen;
> }
> ```
> 
> (I took this example from 
> [zlib](https://github.com/madler/zlib/blob/master/zutil.h#L177))

`defined` doesn't work in D.

The idea is to make the wrong way unattractive and clumsy enough that people 
will look for a better way, which we provide.

BTW, I've been through the zlib .h files, in the course of dogfooding it with 
ImportC. Every ugly practice I complain about with #if's is in full display there.

Here's another gem from your link:

#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
#  define HAVE_MEMCPY
#endif

It's just madness.


More information about the Digitalmars-d mailing list