Riccardo GUIDA
2018-06-28 12:54:12 UTC
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
upcase: bad Union form
(3) -> x case String
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
"bam" of mode Union(i: Integer,s: String) cannot be coerced to mode Integer
(5) -> x.s
(5) "bam"
Type: String
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
upcase: bad Union form
(3) -> x case String
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
"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 fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
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 fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.