From: Damien MATTEI <Damien.Mattei@unice.fr>
To: Kawa mailing list <kawa@sourceware.org>
Subject: behavior of CASE with strings PART 2
Date: Tue, 17 Jan 2017 10:07:00 -0000 [thread overview]
Message-ID: <201701171107.25991.Damien.Mattei@unice.fr> (raw)
testing with eqv? predicate (that seems to be used in kawa CASE if it follow R5RS) and according to https://www.gnu.org/software/kawa/Conditionals.html i have this:
|kawa:1|# (case "dog" (("cat" "dog" "mouse") "animal") (else "mineral or vegetable"))
animal
#|kawa:2|# (invoke "dog":class 'getName)
java.lang.String
#|kawa:3|# (eqv? "dog" "dog")
#t
#|kawa:4|# (define a "dog")
#|kawa:5|# (eqv? a "dog")
#t
and now in my code:
i modified the code to display things:
(begin
(display-msg-var-nl "ResultatGeneralAFKawa : work : type1 = " type1)
(display-msg-var-nl "ResultatGeneralAFKawa : work : type2 = " type2)
(display-msg-var-nl "ResultatGeneralAFKawa : work : Nom = " Nom)
(if (equal? "B5" type1)
(display-nl "ResultatGeneralAFKawa : work : equal? test TRUE")
(display-nl "ResultatGeneralAFKawa : work : equal? test FALSE"))
(if (eqv? "B5" type1)
(display-nl "ResultatGeneralAFKawa : work : eqv? test TRUE")
(display-nl "ResultatGeneralAFKawa : work : eqv? test FALSE"))
;;(display (string-append "|" (type1:getClass:getName) "|"))
(display "ResultatGeneralAFKawa : work : type1 is of type : ")
(display (invoke type1:class 'getName) )
(newline)
(display "ResultatGeneralAFKawa : work : B5 is of type : ")
(display (invoke "B5":class 'getName) )
(newline)
(if (eq? "B5" type1)
(display-nl "ResultatGeneralAFKawa : work : eq? test TRUE")
(display-nl "ResultatGeneralAFKawa : work : eq? test FALSE"))
(set! nutype1
(case type1
(("O") 1) ;; java.lang.String
(("O0") 2)
(("O1") 3)
(("O2") 4)
(("O3") 5)
(("O4") 6)
(("O5") 7)
(("O6") 8)
(("O7") 9)
(("O8") 10)
(("O9") 11)
(("B") 12)
(("B0") 13)
(("B1") 14)
(("B2") 15)
(("B3") 16)
(("B4") 17)
(("B5") 18)
(("B6") 19)
(("B7") 20)
(("B8") 21)
(("B9") 22)
(("A") 23)
(("A0") 24)
(("A1") 25)
(("A2") 26)
(("A3") 27)
(("A4") 28)
(("A5") 29)
(("A6") 30)
(("A7") 31)
(("A8") 32)
(("A9") 33)
(("F") 34)
(("F0") 35)
(("F1") 36)
(("F2") 37)
(("F3") 38)
(("F4") 39)
(("F5") 40)
(("F6") 41)
(("F7") 42)
(("F8") 43)
(("F9") 44)
(("G") 45)
(("G0") 46)
(("G1") 47)
(("G2") 48)
(("G3") 49)
(("G4") 50)
(("G5") 51)
(("G6") 52)
(("G7") 53)
(("G8") 54)
(("G9") 55)
(("K") 56)
(("K0") 57)
(("K1") 58)
(("K2") 59)
(("K3") 60)
(("K4") 61)
(("K5") 62)
(("K6") 63)
(("K7") 64)
(("K8") 65)
(("K9") 66)
(("M") 67)
(("M0") 68)
(("M1") 69)
(("M2") 70)
(("M3") 71)
(("M4") 72)
(("M5") 73)
(("M6") 74)
(("M7") 75)
(("M8") 76)
(("M9") 77)
(else => (begin
(display-nl "display values:")
(dv type1)
(dv nutype1)
(display "WARNING : ResultatGeneralAFKawa : work : CASE type1 in ELSE")
(newline)
'()))))
(dv nutype1)
display* and dv are macro to display variables.
here is the output in logs:
ResultatGeneralAFKawa : work : type1 = B5
ResultatGeneralAFKawa : work : type2 = F5
ResultatGeneralAFKawa : work : Nom = FIN
ResultatGeneralAFKawa : work : equal? test TRUE
ResultatGeneralAFKawa : work : eqv? test FALSE
ResultatGeneralAFKawa : work : type1 is of type : java.lang.String
ResultatGeneralAFKawa : work : B5 is of type : java.lang.String
ResultatGeneralAFKawa : work : eq? test FALSE
display values:
type1 = B5
nutype1 = ()
WARNING : ResultatGeneralAFKawa : work : CASE type1 in ELSE
my concern is with type1 which is of type java.lang.String ,also "B5" in case is of type java.lang.String ,and they should be equal in the sense of eqv? and the CASE should be satisfied in (("B5") 18) but in,stead it goes in ELSE clause
because "B5" and type1 are not equal (eqv?) as "dog" and "dog" (depends of the scheme implementation )
i do not want to rewrite the CASE in other things, is there a way to have String that equal in the sense of eqv? ?
regards,
damien
--
Damien.Mattei@unice.fr, Damien.Mattei@oca.eu, UNS / OCA / CNRS
next reply other threads:[~2017-01-17 10:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-17 10:07 Damien MATTEI [this message]
2017-01-17 13:24 ` Per Bothner
2017-01-17 15:57 ` Jamison Hope
2017-01-18 6:37 ` Per Bothner
2017-01-19 4:53 ` Per Bothner
2017-01-19 10:04 ` Damien MATTEI
2017-01-19 16:00 ` Per Bothner
2017-01-21 9:47 ` Damien Mattei
2017-01-22 4:36 ` match form as a generalization of case Per Bothner
2017-01-23 22:12 ` Damien Mattei
2017-01-23 22:27 ` Per Bothner
2017-01-20 22:54 behavior of CASE with strings PART 2 Damien Mattei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201701171107.25991.Damien.Mattei@unice.fr \
--to=damien.mattei@unice.fr \
--cc=kawa@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).