No need for version expression is a lie
An Pham
home at home.com
Thu Aug 24 20:29:38 UTC 2023
On Thursday, 24 August 2023 at 17:03:20 UTC, Walter Bright wrote:
> On 8/24/2023 8:30 AM, Adam D Ruppe wrote:
>> Or when someone again tries to figure proof and puts `else
>> static assert(0)` at the end, making incremental porting
>> impossible. (which i also wrote about in the last year:
>> http://dpldocs.info/this-week-in-d/Blog.Posted_2023_02_20.html#static-assert-patterns-arguably-harmful-for-porting )
>
> Not impossible, just initially a mite tedious. One can still
> incrementally port to AdrOS by adding:
>
> ```
> version (Windows)
> {
> enum x = 7;
> }
> else version (AdrOS)
> {
> enum x = 0; // FIXME
> }
> else
> static assert(0);
> ```
>
For import or declaration, I refer to use
version (Windows)
{
enum x = 7;
}
else
pragma(msg, "Unsupport system for " ~ __MODULE__);
For function logic, still refer to use static assert
int foo()
{
version (Windows)
{
return 7;
}
else
static assert(0, "Unsupport system for " ~ __FUNCTION__);
}
More information about the Digitalmars-d
mailing list