On 8 October 2017 at 16:09, Ralf Hemmecke <[email protected]> wrote: > ... > Exactly. And that is why for this case I would be rather against the > name "Maybe". I'd rather opt for "Partial" as in Aldor even though > AldorLib implements Partial via Record and is thus more similar to > Union(X,"failed") or "Maybe with GENSYM()" (in terms of behaviour). >
"partial" as in "partial function" makes sense but this is an attribute of the mapping, not of the target domain. So if I read "Partial Integer" that does not make much sense to me. "Maybe Integer" on the other hand says something about the domain Integer. > https://github.com/pippijn/aldor/blob/master/aldor/lib/aldor/src/base/sal_partial.as#L92 > This implementation seems very strange to me. If "Rep == Record(val:T)" then what does it mean that failed:% == per nil 'nil' does not seem like a value of Rep. Can all Record types is Aldor have nil as a value? And a Record with only one component seems like a kind of pointless indirection unless we have some internal knowledge of how Record is implemented and we think of this as a kind of hidden pointer reference. What am I missing here? > ... >> I have just run a benchmark with oldk's optimizations that shows that >> the performance of Union(X,"failed") is identical to Union(val:X, >> failed:"failed") while the "Rep := List R" representation of Maybe(R) >> where "failed" is represented by empty list (NIL) and non "failed" >> values as a singleton list (cons), has performance the same or >> slightly better (in the case of failed values) than Maybe with global >> fGENSYM (at the cost of using about the same extra storage as the >> Union representation, compared to no extra storage for Maybe with the >> global or local GENSYM. > > A more logical representation (which does not rely on the underlying > Lisp) Nothing of the implementation of Maybe with "Rep := List R" depends on the underlying Lisp. All that we need is a List domain and that is provided by the FriCAS library (although granted the implementation of List itself does depend on the underlying Lisp for reasons of performance). > would be similar to what Partial in Aldor has, see link above. > > Rep == Record(val:T); > Sorry, I didn't find it very logical. > It doesn't suggest that there is ever more than one value. Therefore, > I suggested Rep == Reference(X) in an earlier mail. It is not important what the representation suggests. In the choice of representation for any domain it is normal that we only use part of the functionality that the underlying representation provides and then build on that. Since we want Maybe to be a functor (in the sense of Haskell) then using an underlying representation that is a functor seems like a good idea. It seems to me that Reference(X) introduces an extra unnecessary level of indirection and still suffers from a logical inconsistency when the value of Reference(X) does not in fact point to an actual X value. > > Relying on lisp as the target language is not a good idea. I'd rather > like to be independent of such implementation details. > It seems reasonable to me to assume that any target language is likely to provide at least some form of List as a primitive type. But in any case we can at least assume that there will be a way to implement List as a domain. Bill Page. -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
