Indeed Riccardo detected a bug. The question is whether I should simply fix the documentation and (*) remove this line:
""" If you accidentally use the branch type on the right-hand side of case, false will be returned. """ i.e. we leave it unspecified what happens for cases like x case Integer or (**) replace the above line by the sentence: """ The use of the type as a selector is no longer allowed. """ Or (***) someone (Waldek?) fixes the behaviour so that it is in line with the FriCAS-UG. Honestly, I prefer (**). Opinions? Ralf On 6/28/18 2:54 PM, Riccardo GUIDA wrote: > Hi, > > if this is not the correct place for sending FricasUG fix requirements, > please excuse me and let me now. > > RiCCardo > > [FricasUG] FIXME: sec 2.5.2 "Union-s with selectors" pag 96 > "Note that case uses the selector name as its right-hand argument. If > you accidentally use the branch > type on the right-hand side of case, false will be returned. Now it > returns error." > > > (1) -> U := Union(i:Integer, s:String) > > (1) Union(i: Integer,s: String) > Type: > Type > (2) -> x:U := "bam" > > (2) "bam" > Type: Union(s: > String,...) > (3) -> x case Integer > > >> Error detected within library code: > upcase: bad Union form > > (3) -> x case String > > >> Error detected within library code: > upcase: bad Union form > > (3) -> x case i > > (3) false > Type: > Boolean > (4) -> x case s > > (4) true > > The statements above prove that the fricasUG must be fixed. > > > === Feature suggestion for Union-s === > > I must say that I would find more natural (and maybe it would have > simpler code) > to have the predicates > x case Integer > x case String > as for non-selector Union-s and to use selectors only to get the values > x.i > x.s > with "failed" instead of a coerce error when the inappropriate selector > is called: relying on the fact that a coercion might rescue you if the > value branch does not correspond to the selector looks somehow hackish. > > (5) -> x.i > > >> Error detected within library code: > "bam" of mode Union(i: Integer,s: String) cannot be coerced to mode > Integer > > (5) -> x.s > > (5) "bam" > Type: > String > -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/b4f2858a-a41c-94de-1c1d-947d00352dcc%40hemmecke.org. For more options, visit https://groups.google.com/d/optout.
