Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upvirtual structs #5
Conversation
This comment has been minimized.
This comment has been minimized.
jdm
commented
Mar 12, 2014
|
Will there be some way for an override method to call the parent type's override implementation? |
This comment has been minimized.
This comment has been minimized.
jdm
commented
Mar 12, 2014
|
I would also really like to see casting elaborated upon, with examples, etc. |
This comment has been minimized.
This comment has been minimized.
|
I've been thinking more about this. I think that we ought to "close" subtyping so that you can only subtype a virtual struct within the same module (or some submodule). My reasoning:
Basically, virtual structs become an alternative to enums. To some extent this is the expression problem -- enums are there to provide one half, virtual structs with virtual fns to provide the other half, and traits to solve extensibility. (There is some sort of precedent, as an aside, with scala's sealed keyword) |
This comment has been minimized.
This comment has been minimized.
bill-myers
commented
Mar 16, 2014
|
Closed subtyping seems an extremely interesting idea, because then one could see this not as competition for traits, but rather a generalization of enums. The current "enum" syntax could be recast as syntax sugar for virtual structs. This would give "datasort refinements" and "GADTs"/"type parametrization for variants" for free to the enum side, and would give the ability to represent the type tag in ways different than the a vtable pointer (byte-sized tag, null pointer optimization, etc.) to the virtual class side. I still wonder whether the methods would be better put in named traits, with support for declaring a "vtable trait" on the structs/enums/enums variants. Maybe there could be some syntax sugar there too, by having a "virtual impl" declarations that would be equivalent to declaring and implementing a trait, and declaring it as a vtable trait, just like the current "impl" behaves like syntax sugar for declaring and implementing a trait. BTW, I'd suggest then to make the structs either abstract or final, so that it works like the current enum vs enum variant, and doesn't have the issue of having a single identifier that names both a concrete virtual struct, and the set of virtual structs inheriting it. |
bill-myers
referenced this pull request
Mar 17, 2014
Closed
Alternative to virtual struct and functions by extending enums #11
This comment has been minimized.
This comment has been minimized.
|
Incorporated comments from this issue. (Do comments on earlier commits just disappear? I guess I probably shouldn't have force pushed) |
This comment has been minimized.
This comment has been minimized.
|
If you still have the commit hashes (I guess you do, via |
This comment has been minimized.
This comment has been minimized.
|
On Mon, Mar 17, 2014 at 11:32:29PM -0700, Nick Cameron wrote:
Usually github keeps and lists commented, citing "an outdated version |
This comment has been minimized.
This comment has been minimized.
|
(filed as #14) |
This comment has been minimized.
This comment has been minimized.
adrientetar
commented
Mar 18, 2014
|
@nikomatsakis The behavior you described only occurs when people comment of the diff tab and not on the commit itself. |
nrc
added a commit
to nrc/rfcs
that referenced
this pull request
Mar 30, 2014
nrc
added a commit
to nrc/rfcs
that referenced
this pull request
Mar 30, 2014
This comment has been minimized.
This comment has been minimized.
ghost
commented
Jun 28, 2014
|
Please do not use the word "virtual", nor as a keyword, nor as a name for a feature. Even though i am used primarily to C++, i can not get used to this word. For me it means something that i can see, but is not actually there. Like in "virtual reality" or "virtual memory". The meaning of this word has nothing in common with what you plan to use it for. In source code i think it is the comment which is virtual - it looks to be there, but is actually not real source. Please choose some other words. Perhaps "dynamically dispatchable", ... . You know it better. Just not "virtual" please. |
This comment has been minimized.
This comment has been minimized.
sinistersnare
commented
Jun 28, 2014
|
@almale |
nrc
self-assigned this
Sep 4, 2014
alexcrichton
force-pushed the
rust-lang:master
branch
from
6357402
to
e0acdf4
Sep 11, 2014
aturon
force-pushed the
rust-lang:master
branch
from
4c0bebf
to
b1d1bfd
Sep 16, 2014
This comment has been minimized.
This comment has been minimized.
|
Closing in favour of other RFCs which address the same problem (see http://discuss.rust-lang.org/t/summary-of-efficient-inheritance-rfcs/494). |
nrc commentedMar 12, 2014
No description provided.