www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23504] New: Allow `with` with multiple arguments

https://issues.dlang.org/show_bug.cgi?id=23504

          Issue ID: 23504
           Summary: Allow `with` with multiple arguments
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: qs.il.paperinik gmail.com

Currently, `with` can only have one type or expression argument. When multiple
resolvers are needed, one has to nest the `with` statements. Among the
semantics is that one has priority over the other. If that is not intended,
there’s no way to get around it.

Proposed: `with (A, B, C)`.

When an identifier `id` is encountered and among `A.id`, `B.id`, and `C.id`
more than one resolve, it is an ambiguity error. It expresses the intent of the
programmer that either ambiguity is expected to be impossible or that ambiguity
is might be impossible, but the code should explicitly disambiguate to avoid
confusion on the side of the reader. When members are added or renamed in `A`,
`B`, or `C`, this construct is resistant to silent change of behavior.

When `Ts` is a compile-time sequence (AliasSeq), `with (Ts)` does not compile,
even if the sequence has exactly 1 element.

Proposed:

When `Ts` is a compile-time sequence (AliasSeq), `with (A, Ts, C)` is as if
`with (A, Ts[0], ..., Ts[$-1], C)`, i.e. `Ts` will be expanded as one would
expect.

--
Nov 23 2022