Le 10/07/2012 18:51, Graydon Hoare a écrit :
> On 7/10/2012 9:04 AM, David Bruant wrote:
>
>> If I can "concretize" a trait for an arbitrarily complex structure, why
>> would I create classes? Or could classes be seen as syntactic sugar over
>> traits+types?
>
> Sugar, mostly. We're still trying to decide how sweet to make it. Also
> they introduce a nominal type, whereas many of our types are
> structural (i.e. two copies of the same type definition are
> type-equal). We're still not entirely sure if we can or should be
> merging the other nominal data constructor ('enum') with 'class', or
> if that's trying to force things that are better off remaining
> separate[1].
>
>> If it's the case, then the visibility control mechanism doesn't seem
>> necessary for traits anymore since visibility would be more a concern
>> for classes than for traits.
>
> That's the idea, yes.
>
> -Graydon
>
> [1]: For those following along at home, I cannot help but point out
> the symmetry between the "case-class vs. enums" question and how we
> previously removed tuples in favour of "just records and enums", then
> got annoyed with the cases we wanted to write as tuples, so added them
> back in. Strictly speaking, redundant; but hey, so is everything
> beyond rule 110, doesn't keep us from quibbling over syntax.
I don't know this precedent so I can't talk about it much, but a quote
by Dave Herman on es-discuss [1] got me thinking a lot: "Completeness is
an anti-goal for syntax". It got me thinking about what a goal for
syntax should be. And my answer is: convenience to manipulate the
underlying VM. Otherwise, we probably would still be all writing in
assembly.
So completeness is an anti-goal for syntax, but so is minimalism (aka
"redundancy chasing"). Minimalism is certainly a good idea for virtual
machine basic constructs, but it doesn't make it a good idea for syntax.

Anyway, my 2 cents on this question.

Thanks all for your answers on traits and classes,

David

[1] https://mail.mozilla.org/pipermail/es-discuss/2012-May/023045.html
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to