New Trait Syntax Coming.
[Thread Prev] | [Thread Next]
[Date Prev] | [Date Next]
- Subject: New Trait Syntax Coming.
- From: Ori Bernstein <ori@xxxxxxxxxxxxxx>
- Reply-to: myrddin-dev@xxxxxxxxxxxxxx
- Date: Sun, 31 Dec 2017 17:50:30 -0800
- To: myrddin-dev@xxxxxxxxxxxxxx
I've on and off been complaining about how the current way of specifying traits sucked for two reasons: - Tons of redundancy in the trait listings for type spec - The syntactic impossibility of specifying aux types for traits. So, thanks to some talking with npnth on IRC, we've finally got a solution to both issues. The '::' separator is now being pulled out of the type, and instead will follow the whole type. It will take a trait list which appies to the type variables in the preceeding type. For example, generic rngrand : (rng : rng#, lo : @a::(numeric,integral), hi : @a::(numeric,integral) -> @a::(numeric,integral)) becomes: generic rngrand : (rng : rng#, lo : @a, hi : @a -> @a) :: numeric,integral @a Which, to my eyes, is a lot nicer to read. Any number of traits can be specified this way: generic foo : (x : @a, y : @b -> @c) :: numeric,integral @a, numeric,integral @b, iterable @c -> (@a, @b) Note that the syntax for these types mirrors the syntax for impl specifications. Also, thanks for tarug0's change to remove the need for escaping the newlines after a ',', which makes wrapping these things much nicer. This change has already been mostly implemented, although some of the wiring for aux types needs work. I'll bang on it a little bit more before I put it somewhere accessible. Happy new year! -- Ori Bernstein
Re: New Trait Syntax Coming. | Ori Bernstein <ori@xxxxxxxxxxxxxx> |
- Next by Date: Re: [PATCH 2/2] add permutation iterator
- Next by thread: Re: New Trait Syntax Coming.
- Index(es):