Giving up

Tim tim.dlang at t-online.de
Sat Aug 6 09:02:53 UTC 2022


On Saturday, 6 August 2022 at 08:29:19 UTC, Walter Bright wrote:
> On 8/5/2022 9:43 AM, Max Samukha wrote:
>> Both "123." and "123.E123" is valid C. For some reason, D only 
>> copied the former.
>
> It's to support UFCS (Universal Function Call Syntax). The idea 
> with C compatible aspects of D is to not *silently* break code 
> when there's a different meaning for it. And so, these generate 
> an error message in D (although the error message could be much 
> better).

It could silently break code if the right function is defined. 
The following example is valid in C and D (except 
import/include), but prints a different value:

```D
// #include <stdio.h>
import core.stdc.stdio;

int E2(int i)
{
     return i;
}

int main()
{
     float f = 123.E2;
     printf("%f\n", f);
     return 0;
}
```


More information about the Digitalmars-d-announce mailing list