Is there any reason to use Racket’s string-append-immutable though? It might be simpler to just:
(define string-append-immutable (compose string->immutable-string string-append)) (provide string-append-immutable) since you need to define it anyway for the versions prior 7.5.0.14. On Mon, Mar 30, 2020 at 12:00 PM Sorawee Porncharoenwase < [email protected]> wrote: > Your code would not work because prior 7.5.0.14, there’s no > string-append-immutable, so the use of string-append-immutable in the > else branch will result in an unbound id error. > > Instead, use https://docs.racket-lang.org/version-case/index.html which > will run the “if” at compile-time, making the "unbound id" go away at > compile-time. > > Another problem is that when you define string-append (or even > string-append-immutable), it will shadow Racket’s string-append (or > string-append-immutable). You might want to do something like this > instead: > > (define @string-append-immutable ... now you can use string-append-immutable > here ...) > (provide (rename-out [@string-append-immutable string-append-immutable])) > > > > On Mon, Mar 30, 2020 at 11:49 AM Siddhartha Kasivajhula < > [email protected]> wrote: > >> Hi there, >> Is there a standard/recommended way to handle multiple versions of Racket >> in library code? >> >> For instance, this handy utility was added in a recent version of Racket: >> >> >> https://docs.racket-lang.org/reference/strings.html?q=strings#%28def._%28%28quote._~23~25kernel%29._string-append-immutable%29%29 >> >> I'd like to use it in my library code but that would probably mean that >> users with an older version of Racket wouldn't be able to use the library, >> is that right? I'm tempted to add something like: >> >> (require version/utils) >> (define string-append >> (if (version<? (version) "7.5.0.14") >> (compose string->immutable-string string-append) >> string-append-immutable)) >> >> ... at the top of the module. Is this advisable? Or is there a better, >> maybe more raco-friendly way? >> >> Thanks, >> -Sid >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Racket Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/racket-users/CACQBWFkRahhtoXKUbpcJ%2BHpYwq5FBU85Ze_NGkEntXX3kTD01g%40mail.gmail.com >> <https://groups.google.com/d/msgid/racket-users/CACQBWFkRahhtoXKUbpcJ%2BHpYwq5FBU85Ze_NGkEntXX3kTD01g%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CADcuegsPsYRE7JZa6vrAoV2fHKPLM9O9-8ghhTiR5TexyHeRSA%40mail.gmail.com.

