-preview=in might break code
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Oct 3 18:37:52 UTC 2020
On 10/3/20 2:36 PM, Paul Backus wrote:
> On Saturday, 3 October 2020 at 16:56:06 UTC, Mathias LANG wrote:
>>
>> To put it differently: Why is `auto ref` acceptable but `in` is not ?
>
> The issue with `in`, compared to `auto ref`, is that, because its
> behavior is implementation-defined, it invites programmers to write code
> that "works on their machine," but is not portable to other environments
> (including future versions of the same compiler). It's the same issue
> that C has with features like variable-sized integer types and
> implementation-defined signedness of `char`.
>
> Yes, *technically* it's your fault if you write C code that relies on an
> `int` being 32 bits, or a `char` being unsigned, just like it would
> *technically* be your fault if you wrote D code that relied in an `in`
> parameter being passed by reference. But making these things
> implementation-defined in the first place is setting the programmer up
> for failure.
That's a very good comparison, thank you.
More information about the Digitalmars-d
mailing list