Discussion Thread: DIP 1037--Add Unary Operator ...--Community Review Round 1

Manu turkeyman at gmail.com
Wed Oct 28 14:48:48 UTC 2020


On Wed, Oct 28, 2020 at 11:35 PM Ola Fosheim Grøstad via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On Tuesday, 27 October 2020 at 10:54:07 UTC, Mike Parker wrote:
> > This is the discussion thread for the first round of Community
> > Review of DIP 1037, "Add Unary Operator ...":
>
> I think it should be made more generic and flexible. Make it work
> with all sequence types that provides a length and indexing.


Definitely not my DIP. I can immediately imagine heaps of issues with that
idea, and I have never wanted that before.
If you want to do a non-static map, then use `map`, which accepts a lambda
and looks and feels very natural and convenient.

Make it possible to offset.


Not sure what this means? You can slice tuples in D, does that not give you
the ability to offset as you like?

Make it work for empty sequences (initial
> value for fold/reduce).


I don't think this is necessary, and it is deliberately omitted. You can
append a limit value to a tuple trivially using something like
AliasSeq!(limit, MyTup).
Perhaps in the future if we ever get first-class tuples, you can use `~` to
intuitively concatenate tuples, and I think that's more proper than what
C++ does. If it turns out I'm wrong and it should exist, then it's a
trivial expansion.

Make the comma-expansion more intuitive.
> E.g. (pseduo):
>
> Given:
>
> seq1 = /* 1 ,2, 3 */
> seq2 = /* 10, 20, 30, 40, 50*/
>
>
> IN:
> (seq1[_]*10 + seq2[_+1], ...)
>
> OUT (e.g. length = min(seq1.length, seq2.length):
> (seq1[0]*10 + seq2[1], seq1[1]*10 + seq2[2], seq1[2]*10 + seq2[3])


That looks like a minefield of grammatical issues. Why would you prefer
that with the comma separating the expression and `...`?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20201029/62fc993e/attachment.htm>


More information about the Digitalmars-d mailing list