Eigenstate: myrddin-dev mailing list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 0/2] impl specialization and lookup changes


On Sun, 2 Jul 2017 14:52:00 +0000, Quentin Carbonneaux <quentin@xxxxxx> wrote:

> On Sat, Jul 01, 2017 at 10:28:58PM -0700, Ori Bernstein wrote:
> > The interesting part in this example is that the type
> > of the expression here might have no relation to the
> > type that the trait is specialized over.
> 
> Ah that's right!  I focused too much on the first
> example.  Type hints would be of no use in the
> second one.  So it looks like something else is
> really necessary. 

Bah, I was hoping you had one of those magic solutions.

> Syntax does not count much, though.  So I'm
> totally fine with Michael's suggestion.

Syntax does matter -- it's nice having something
cohesive, something that flows and doesn't make me think
about what comes next as I type.

It might be good to think of this as 'cast to trait',
and reuse the cast syntax, just with the 'trait-of'
operator instead of the 'type-of' operator:

	str = (Def :: trait)

That being said, it's not intrusive, and not worth
bikeshedding over too much. The functionality is useful,
and I'll just make a breaking change if/when we think of
something nicer.

I've been wanting to redo the way that traits are
specified over type params, so there's a good chance we
can look at the syntax here in light of that.

Aside:

The specific problem I'm trying to solve with the trait
syntax is that it's impossible to depend or use aux
types in trait specifiers with the current syntax. So,
you can say `must be iterable`, but there's no way to
specify that the iterator must return integers, for
example.

-- 
    Ori Bernstein

References:
[RFC PATCH 0/2] impl specialization and lookup changesMichael Forney <mforney@xxxxxxxxxxx>
Re: [RFC PATCH 0/2] impl specialization and lookup changesQuentin Carbonneaux <quentin@xxxxxx>
Re: [RFC PATCH 0/2] impl specialization and lookup changesOri Bernstein <ori@xxxxxxxxxxxxxx>
Re: [RFC PATCH 0/2] impl specialization and lookup changesQuentin Carbonneaux <quentin@xxxxxx>