racket / r6rs

Other
6 stars 9 forks source link

Fix list-sort #2

Closed ChillMagic closed 7 years ago

ChillMagic commented 7 years ago

I try to fix it. Is that ok?

stamourv commented 7 years ago

Thanks for looking into it! Unfortunately, I don't think this fix works.

Lists in R6RS are mutable, unlike in Racket. Hence the conversion back and forth between mutable (argument and return value of the R6RS function) and immutable (which Racket's sort expects and returns).

Your change would break R6RS programs that try to sort mutable lists, which would not be accepted by this function anymore.

Another solution would be to add a private entry point to Racket's sort that would accept mutable lists (which it would just copy anyway, which it already has to do for immutable lists), and have list-sort use that.

ChillMagic commented 7 years ago

@stamourv Oh I get it, thank you for your description! I don't know much about it. Now I konw that it is difficult to build a perfect R6RS standard library in Racket. Thank you.