717: Improve SCOOP 2 documentation and prototype.

https://svn.lrde.epita.fr/svn/oln/trunk/static Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Improve SCOOP 2 documentation and prototype. * doc/algorithms.ml (merge2): Reorder patterns as in merge3. Aesthetic changes. (merge3): Aesthetic changes. * doc/algorithms.txt: Adjust. * doc/rules.txt: Typos. Improve the last two examples. algorithms.ml | 46 +++++++++++++++------------------- algorithms.txt | 32 ++++++++++++------------ rules.txt | 75 ++++++++++++++++++++++++++++++++------------------------- 3 files changed, 80 insertions(+), 73 deletions(-) Index: doc/algorithms.ml --- doc/algorithms.ml (revision 716) +++ doc/algorithms.ml (working copy) @@ -73,26 +73,25 @@ let merge2 (local_res : cxx_type) (super_res : cxx_type) : cxx_type = match local_res, super_res with - | Stc_Abstract, Stc_Not_found -> Stc_Abstract + (* local_res == stc::not_found. *) | Stc_Not_found, Stc_Not_found -> Stc_Not_found - | Stc_Final t, Stc_Not_found -> Stc_Final t - | t, Stc_Not_found -> t - | Stc_Not_found, Stc_Abstract -> Stc_Not_found - | Stc_Abstract, Stc_Abstract -> Stc_Abstract - | Stc_Final t, Stc_Abstract -> Stc_Final t - | t, Stc_Abstract -> t - - | Stc_Abstract, Stc_Final u -> error "Final VT redefined abstract" | Stc_Not_found, Stc_Final u -> Stc_Final u - | Stc_Final t, Stc_Final u -> error "Final VT redefined final." - | t, Stc_Final u -> error "Final VT redefined." - - | Stc_Abstract, u -> error "VT redefined abstract." | Stc_Not_found, u -> u - | Stc_Final t, u -> Stc_Final t - | t, u -> t + (* local_res == stc::abstract. *) + | Stc_Abstract, Stc_Abstract -> Stc_Abstract + | Stc_Abstract, Stc_Not_found -> Stc_Abstract + | Stc_Abstract, Stc_Final _ -> error "Final VT redefined abstract" + | Stc_Abstract, _ -> error "VT redefined abstract." + + (* local_res == stc::final<T>. *) + | Stc_Final _, Stc_Final _ -> error "Final VT redefined final." + | Stc_Final t, _ -> Stc_Final t + + (* local_res == T. *) + | _, Stc_Final _ -> error "Final VT redefined." + | t, _ -> t ;; (* Another version (rewriting) of merge3. *) @@ -114,7 +113,7 @@ | Stc_Not_found, Stc_Final u, _ -> Stc_Final u | Stc_Not_found, u, _ -> u - (* local_res == stc::not_abstract. *) + (* local_res == stc::abstract. *) | Stc_Abstract, Stc_Not_found, Stc_Not_found -> Stc_Abstract | Stc_Abstract, Stc_Not_found, Stc_Abstract -> Stc_Abstract | Stc_Abstract, Stc_Not_found, Stc_Final v -> Stc_Final v @@ -128,9 +127,9 @@ | Stc_Abstract, Stc_Not_delegated_Abstract, _ -> Stc_Not_delegated_Abstract | Stc_Abstract, Stc_Not_delegated, _ -> Stc_Not_delegated_Abstract - | Stc_Abstract, Stc_Final u, _ -> error ("Final VT " ^ + | Stc_Abstract, Stc_Final _, _ -> error ("Final VT " ^ "redefined abstract") - | Stc_Abstract, u, _ -> error ("VT redefined " ^ + | Stc_Abstract, _, _ -> error ("VT redefined " ^ "abstract.") (* local_res == stc::not_delegated. *) @@ -147,15 +146,14 @@ " and abstract") (* local_res == stc::final<T>. *) - | Stc_Final t, Stc_Final u, _ -> error ("Final VT " ^ + | Stc_Final _, Stc_Final _, _ -> error ("Final VT " ^ "redefined final.") | Stc_Final t, _, _ -> Stc_Final t (* local_res == T. *) - | t, Stc_Final u, _ -> error ("Final VT " ^ + | _, Stc_Final _, _ -> error ("Final VT " ^ "redefined.") | t, _, _ -> t - ;; @@ -380,7 +378,7 @@ with Scoop_exception "Final VT redefined final." -> (); ;; -(* ** General virtual type lookup +(* ** General virtual type lookup (i.e., with delegation) *** Abstract @@ -403,8 +401,6 @@ vtype delegatee_type = D; } - // FIXME: What should be the value of ``t''? - // I would say ``stc::not_found'', but I'm not sure (see intro.txt, too). type t = C#my_type; *) let a = @@ -573,7 +569,7 @@ ;; -(* Olena-like examples. +(* *** Olena-like examples. class /image_entry/ < stc::none { Index: doc/algorithms.txt --- doc/algorithms.txt (revision 716) +++ doc/algorithms.txt (working copy) @@ -29,8 +29,8 @@ | stc::abstract -> error "find: VT is abstract." | stc::not_delegated_abstract -> error "find: VT is abstract." | stc::not_delegated -> stc::not_found - | stc::final t -> t - | t -> t + | stc::final<T> -> T + | T -> T ** find_rec @@ -70,25 +70,25 @@ merge2 (local_res, super_res) = match local_res, super_res with - | stc::abstract, stc::not_found -> stc::abstract + // local_res == stc::not_found. | mlc::not_found, stc::not_found -> stc::not_found - | T, stc::not_found -> T - | stc::final<T>, stc::not_found -> stc::final<T> - | mlc::not_found, stc::abstract -> stc::not_found - | stc::abstract, stc::abstract -> stc::abstract - | T, stc::abstract -> T - | stc::final<T>, stc::abstract -> stc::final<T> - - | stc::abstract, U -> error ("VT redefined abstract.") + | mlc::not_found, stc::final<U> -> stc::final<U> | mlc::not_found, U -> U - | T, U -> T - | stc::final<T>, U -> stc::final<T> + // local_res == stc::abstract. + | stc::abstract, stc::not_found -> stc::abstract + | stc::abstract, stc::abstract -> stc::abstract | stc::abstract, stc::final<U> -> error ("Final VT redefined abstract") - | mlc::not_found, stc::final<U> -> stc::final<U> - | T, stc::final<U> -> error ("Final VT redefined.") + | stc::abstract, U -> error ("VT redefined abstract.") + + // local_res == stc::final<T>. | stc::final<T>, stc::final<U> -> error ("Final VT redefined final.") + | stc::final<T>, _ -> stc::final<T> + + // local_res == stc::final<T>. + | T, stc::final<U> -> error ("Final VT redefined.") + | T, _ -> T merge3 (local_res, super_res, delegatee_res) = @@ -109,7 +109,7 @@ | mlc::not_found, U, _ -> U - // local_res == stc::not_abstract. + // local_res == stc::abstract. | stc::abstract, stc::not_found, stc::not_found -> stc::abstract | stc::abstract, stc::not_found, stc::abstract -> stc::abstract | stc::abstract, stc::not_found, stc::final<V> -> stc::final<V> Index: doc/rules.txt --- doc/rules.txt (revision 716) +++ doc/rules.txt (working copy) @@ -16,7 +16,7 @@ stc::none (FIXME: What about stc::top ?) - deferred_type? (FIXME: Which syntax?) + (deferred_type?) (FIXME: Which syntax?) * Declaration/definition @@ -93,7 +93,7 @@ - Unless declared final (see relevant item), a virtual type of a class can be redefined in its subclass(es). The new value can be the same or different for the inital one. The syntax is the same as the one - for defining a virtual type. + defining a virtual type. Ex.: @@ -315,7 +315,7 @@ This process relies on an `atomic' lookup on each inspected class: each of them can be queried for a locally defined virtual type. -(FIXME: reference to the local_find algorithm.) +(FIXME: reference to the find_local algorithm.) The result of this local lookup is - mlc::not_found: meaning there is no delegatee_type; @@ -415,6 +415,8 @@ FIXME: Continue. + + * Examples @@ -471,41 +473,50 @@ *** E#bar - A local_find(A, bar) = mlc::not_found - ^ + top-down + propagation + | - | X local_find(X, bar) = 0 - | ^ - | | - B | local_find(B, bar) = mlc::not_found - ^ | + | find_local(A, bar) = not_found A + | => find(A, bar) = not_found ^ + | | X find_local(X, bar) = 0 + | | ^ => find(X, bar) = 0 + | find_local(B, bar) = not_found B | + | => find(B, bar) = not_found ^ | + | | Y find_local(Y, bar) = char + | | | => find(Y, bar) = char + | find_local(C, bar) = not_found C<>-� + | => find(C, bar) = char ^ | | - | Y local_find(Y, bar) = char + | find_local(D, bar) = not_found D + | => find(D, bar) = char ^ | | - | | - C<>-� local_find(D, bar) = mlc::not_found - ^ - | - D local_find(D, bar) = mlc::not_found - ^ - | - E local_find(E, bar) = mlc::not_found + | find_local(E, bar) = not_found E + | => find(E, bar) = char + v *** E#hop - A local_find(A, bar) = mlc::not_found - ^ - | X - B ^ local_find(B, bar) = mlc::not_found - ^ | - | Y - C<>-� local_find(D, bar) = stc::not_delegated - ^ - | - D local_find(D, hop) = mlc::not_found - ^ - | - E local_find(E, hop) = mlc::not_found + top-down + propagation + + | find_local(A, hop) = not_found A + | => find(A, hop) = not_found ^ + | | X find_local(X, hop) = int + | | ^ => find(X, hop) = int + | find_local(B, hop) = not_found B | + | => find(B, hop) = not_found ^ | + | | Y find_local(Y, hop) = not_found + | | | => find(Y, hop) = int + | find_local(C, hop) = not_deleg C<>-� + | => find(C, hop) = not_found ^ + | | + | find_local(D, hop) = not_found D + | => find(D, hop) = not_found ^ + | | + | find_local(E, hop) = not_found E + | => find(E, hop) = not_found + v
participants (1)
-
Roland Levillain