I dun a DIP, possibly the best DIP ever

Manu turkeyman at gmail.com
Thu Apr 23 00:21:01 UTC 2020


On Thu, Apr 23, 2020 at 2:50 AM Steven Schveighoffer via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On 4/22/20 10:37 AM, Manu wrote:
> > I think efficient implementation here would depend on a static fold,
> > which I plan for a follow-up, and it's a very trivial expansion from
> > this DIP.
> > Static reduce would allow `...` as an argument to a BinOp
> > Ie; `Tup + ...` would expand `Tup[0] + Tup[1] + Tup[2] + ...`
> > You could do `is(FindType == Tup) || ...`, and it would evaluate true if
> > FindType exists in Tup, with no junk template instantiations!
>
> This is awesome, and I'm not seeing why you would save it for later.
>

Because it's strictly additive, DIP's with over-reach tend to fail.

In general, couldn't this DIP be done just strictly on binary operators
> and do what this DIP does with commas?
>
> i.e.
>
> foo(T) , ... expands to foo(T[0]), foo(T[1]), ..., foo(T[n])
>

That looks really grammatically challenging to me. I wouldn't know where to
start attempting to implement that :/
The current patch in the compiler is extremely sanitary and self-contained,
but I can't imagine how to do that without making some pretty aggressive
changes to the parser. I think that's likely to have unexpected and
far-reaching side-effects.
It could be expanded to support that syntax in the future, but I'd rather
move with the simple definition I have in the DIP today. I think what you
describe above is very risky :/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20200423/d9e1b30c/attachment-0001.htm>


More information about the Digitalmars-d mailing list