June 29, 2018
On 06/28/2018 11:10 PM, Jonathan M Davis wrote:
> On Friday, June 29, 2018 05:52:03 Alex via Digitalmars-d-learn wrote:

>> Wouldn't this be weird from the semantic view?

I agree with all your concerns. The fact that Meta decided to make the element type Algebraic!T as opposed to my CommonType!T choice is another semantic problem.

> It wouldn't make any sense to turn a Tuple into a range. However, if all of
> the values are of the same type, it might make sense to create a range from
> each of the values in the Tuple.

I went a step further and used CommonType!T.

> a helper function could be created that takes a Tuple and
> returns a range which wraps it.

That's what my example did (with added bugs like 'length' being an enum by mistake).

> And at that point, talking about
> getting a range over a Tuple is basically the same thing as talking about
> creating a range from an arbitrary struct whose members all happen to have
> the same type - and that would be pretty weird.

Agreed.

Ali

June 30, 2018
On 6/29/18 1:35 PM, Ali Çehreli wrote:
> On 06/28/2018 11:10 PM, Jonathan M Davis wrote:
>  > On Friday, June 29, 2018 05:52:03 Alex via Digitalmars-d-learn wrote:
> 
>  >> Wouldn't this be weird from the semantic view?
> 
> I agree with all your concerns. The fact that Meta decided to make the element type Algebraic!T as opposed to my CommonType!T choice is another semantic problem.
> 
>  > It wouldn't make any sense to turn a Tuple into a range. However, if all of
>  > the values are of the same type, it might make sense to create a range from
>  > each of the values in the Tuple.
> 
> I went a step further and used CommonType!T.

Isn't this what only does? https://dlang.org/phobos/std_range.html#only

-Steve
June 30, 2018
On 06/30/2018 05:17 AM, Steven Schveighoffer wrote:

> Isn't this what only does? https://dlang.org/phobos/std_range.html#only

Cool. :)

    import std.range : only;

    auto t = tuple(5, 3.5, false);
    auto r = only(t.expand);

Ali
1 2
Next ›   Last »