I dun a DIP, possibly the best DIP ever

Manu turkeyman at gmail.com
Fri Apr 24 07:10:18 UTC 2020


On Fri, Apr 24, 2020 at 4:35 PM Walter Bright via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

>
> There's a lot of merit to the idea of arrays and tuples using a common
> syntax,
> which is what I'm proposing.
>

Your idea all falls over anywhere it encounters variadic args, or potential
for overloads though. Without an explicit expression, the only way forward
is to preserve existing D semantics (or it's a radically breaking change),
and that will severely narrow the applicability of this proposal.

Consider this:

  alias Tup = AliasSeq!(0, 2, 3);
  void fun(int);
  fun(Tup);  // scalar argument receives tuple, it can expand, so: fun(0),
fun(1), fun(2)

Now someone introduces an overload:
  void fun(int, int, int);

To the previous expression expanded, but now it found an applicable call
and doesn't expand anymore.
Obviously that's far too dangerous to allow, so; functions MAY have
overloads (or just accept var args), and I think that simply means that
expansion can never be applied to function arguments.
That's a HUGE loss, because I do that extremely frequently. Probably more
than anything.

This same principle argument applies to templates which may receive
variadic arguments.
It weakens the value in my DIP by a huge amount to forego the explicit
syntax designed specifically to handle the resolution of ambiguous
expressions.

This doesn't rule out your proposition that `Tup + 10` can (and probably
should) work though. Again, these are not mutually exclusive proposals.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20200424/c4c06c9f/attachment.htm>


More information about the Digitalmars-d mailing list