Phobos is now compiled with -preview=dip1000

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri May 17 09:00:54 UTC 2019


On Thursday, May 16, 2019 11:22:30 PM MDT Mike Franklin via Digitalmars-d-
announce wrote:
> I consider it a bug that the compiler doesn't emit an error when
> using attributes on types for which they are not intended.

As in you think that something like

auto foo(scope int i) {...}

should be illegal, because scope makes no sense on an int? That's nice in
theory, but templates make such an approach a serious problem. It needs to
work to do something like

auto foo(T)(scope T t) {...}

without having to have separate overloads for types where scope makes sense
and types where it doesn't. Similarly, you don't want to have to use static
ifs whenever you declare a variable that you want to be scope in the cases
where the template argument is a type where scope does work.

In general, D ignores attributes when they don't apply rather than making it
an error, because making it an error causes serious problems for generic
code. This does unfortunately mean that some people are bound to sometimes
end up using an attribute when it doesn't apply, thinking that it does, and
that's unfortunate, but overall, it just works better for the compiler not
to complain about such cases.

- Jonathan M Davis





More information about the Digitalmars-d-announce mailing list