Conditional compilation inside asm and enum declarations
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jul 14 10:15:11 PDT 2009
Walter Bright wrote:
> Andrei Alexandrescu wrote:
>> Then I have the function right there with all versioned
>> implementations. To me that seems better than Phobos' existing style
>> of version'ing large portions of code, which inevitably results in
>> duplicating a lot of the functionality in two places.
>
> I wouldn't consider Phobos to be an exemplary example of how to do
> versioning, though it should be. I think much of it, like std.file,
> should be split off into os-dependent "personality" modules, much like
> the os api modules have been.
That would exacerbate code duplication. Consider:
version(Windows) void[] read(in char[] name)
{
...
}
version(Posix) void[] read(in char[] name)
{
...
}
S readText(S = string)(in char[] name)
{
...
}
In my approach they are laid as you see them, which I find very
well-organized. In your approach you'd define several files each
specialized for an OS, which would duplicate readText, or put readText
into a common file and have it include platform-specific files. Both
solutions are unnecessarily complicated to the simple and clear code above.
Andrei
More information about the Digitalmars-d
mailing list