Hello Manuel, i forward my answer because it seems impossible to reach both bigloo and kawa mailing list ,messages do not go in kawa,only bigloo mailing list.
i know R5RS specify to use eq? predicate for comparison but this exclude the use of strings in programming with CASE of course i could use COND or try to write a macro as i'm doing. Damien ---------- Message transmis ---------- Sujet : Re: behavior of CASE with strings PART 2 Date : jeudi 19 janvier 2017 De : Damien MATTEI <[email protected]> À : [email protected] Le Thursday 19 January 2017 05:53:05 Per Bothner, vous avez écrit : > > On 01/17/2017 10:36 PM, Per Bothner wrote: > > I think this is something to think of for the Kawa 3.0 release, > > using the new PATTERN construct in each clause. > > The invoke branch has a 'match' form, which has the syntax: > > (match TARGET-EXPR (PATTERN BODY...) ...) > > This matches TARGET-EXPR against each PATTERN, until one matches, > at which point the BODY... forms are evaluated. > > This is the 'match' form from Racket: > https://docs.racket-lang.org/guide/match.html > https://docs.racket-lang.org/reference/match.html > > Unfortunately, the implemented forms of PATTERN are very > limited, but the intention to allow literals and quoted forms. > These will be compared using equal?, so you will be able to write: > > (match "yes" > ("no" #f) > ("yes" #t)) > > THIS IS NOT YET IMPLEMENTED. (It's not conceptually hard; I just need to > decide the best way to present such match forms.) > > I think this is the generalization of 'case' that we're looking for. Hi Per, thanks for your answer... i read the many answers to the mailing list about CASE and STRINGS and delayed my answer because i wanted to answer after having a solution (still not done) i understand the various implementation of Scheme follow or not the R5RS and R7RS but this could be changed in a future revision because it is limitating to be able to use CASE with STRINGS in language such as ASP, Java and not Scheme, with Racket it seems that equal? predicate is used, so probably my code will work with Racket. i think of many solutions and finalyy begin to write a recursive macro implementing a case-string but i'm facing proble with multiple "ellipsis" in a recursive macro and wanted to debug it this morning when i read your last message, so here it is: ;; CASE adapted for string comparison (define-syntax case-string (syntax-rules () ((_ var (lst res) (... ...) (else => res-else)) (if (member var lst) res (case var (... ...) (else => res-else)))) ((_ var (else => res-else)) res-else))) ellispsis have to be fixed and the behavior seems to be not defined in R5RS i tried many scheme and it behave diffrently, even in Racket with #lang R5RS it does not work now Damien -- [email protected], [email protected], UNS / OCA / CNRS ------------------------------------------------------- -- [email protected], [email protected], UNS / OCA / CNRS
