Changeset c72f9fd for doc/proposals


Ignore:
Timestamp:
Jul 20, 2017, 2:38:41 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
e1e4aa9
Parents:
957453d
Message:

Cleanup on revised virtual proposal

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/proposals/virtual.txt

    r957453d rc72f9fd  
    22
    33There are two types of virtual inheritance in this proposal, relaxed
    4 (implicate) and strict (explicate). Relaxed is the simpler case that uses the
     4(implicit) and strict (explicit). Relaxed is the simpler case that uses the
    55existing trait system with the addition of trait references and vtables.
    6 Strict adds some constrants and requires some additional notation but allows
     6Strict adds some constraints and requires some additional notation but allows
    77for down-casting.
    88
     
    2828void draw(line*);
    2929
    30 While all the members of this simple UI support drawing creating a UI that
    31 easily supports both these UI requires some tedious boiler-plate code :
     30While all the members of this simple UI support drawing, creating a UI that
     31easily supports both these UI requires some tedious boiler-plate code:
    3232
    3333enum type_t { text, line };
     
    4949}
    5050
    51 While this code will work as indented, adding any new widgets or any new
     51While this code will work as implemented, adding any new widgets or any new
    5252widget behaviors requires changing existing code to add the desired
    5353functionality. To ease this maintenance effort required CFA introduces the
     
    8383This could be implied in simple cases like this one (single parameter on the
    8484trait and single generic parameter on the function). In more complex cases it
    85 would have to be explicately given, or a strong convention would have to be
    86 enforced.
     85would have to be explicitly given, or a strong convention would have to be
     86enforced (e.g. implementation of trait functions is always drawn from the
     87first polymorphic parameter).
    8788
    8889Once a function in a trait has been marked as virtual it defines a new
     
    9596one virtual parameter. The program must have a single table to look up the
    9697function on. Using trait references with traits with more than one parameter
    97 is also restricted, inistially forbidden, see extention.
    98 
    99 Extention: Multi-parameter Virtual Traits:
     98is also restricted, initially forbidden, see extension.
     99
     100Extension: Multi-parameter Virtual Traits:
    100101
    101102This implementation can be extented to traits with multiple parameters if
     
    140141So the trait error is the head of a new tree and io_error is a child of it.
    141142
    142 Also the parent trait is implicately part of the assertions of the children,
     143Also the parent trait is implicitly part of the assertions of the children,
    143144so all children implement the same operations as the parent. By the unique
    144 path down the tree, we can also uniquely order them so that prefixs of a
    145 child's vtable has the same format as the parent's.
     145path down the tree, we can also uniquely order them so that a prefix of a
     146child's vtable has the same format as its parent's.
    146147
    147148This gives us an important extra feature, runtime checking of the parent-child
     
    171172This can generate a seperate vtable for each U for which all the T+U
    172173implementations are provided. These are then seperate nodes in the tree (or
    173 the root of different trees) as if each was created individually.
     174the root of different trees) as if each was created individually. Providing a
     175single unique instance of these nodes would be the most difficult aspect of
     176this extension, possibly intractable, though with sufficient hoisting and
     177link-once duplication it may be possible.
    174178
    175179Example:
     
    187191
    188192Currently traits must be the internal nodes and structs the leaf nodes.
    189 Structs could be made internal nodes as well, and might specify structural
    190 inheritance.
     193Structs could be made internal nodes as well, in which case the child structs
     194would likely structurally inherit the fields of their parents.
    191195
    192196
    193197Storing the Virtual Lookup Table (vtable):
    194198
    195 We have so fare been silent on how the vtable is created, stored and accessed.
     199We have so far been silent on how the vtable is created, stored and accessed.
    196200
    197201Creation happens at compile time. Function pointers are found by using the
Note: See TracChangeset for help on using the changeset viewer.