The sort! function can enter an endless loop when sorting objects
with a function that compares using >=. Tested with the s7 I pulled
from git just now.

I discovered this one when sorting a list of hash-tables based on
one of their keys. After a round of golf it also fails when sorting
a list of lists but only when the "(obj list-ref)" syntax is used,
using car does not cause sort to fail.

        (sort! '((1) (2)) (lambda (A B) (>= (A 0) (B 0))))

I'm on openbsd which means using the fallback local_qsort_r but I
don't think that's the problem.

I also noticed that the comparison function is eventually called
with the same object (eq? is true) in A and B which seems related
somehow.

And another one for free, I'm not sure if this is a bug or just a
consequence of the quote operator. A comma outside of quasiquote
is not an error if it's quoted:

$ ./s7load "(define X (hash-table 'b 'foo)) (define B 'b) (display (X 
',B))(newline)"
#f
$ ./s7load "(define X (hash-table 'b 'foo)) (define B 'b) (display (X 
\`,B))(newline)"
foo

Matthew

_______________________________________________
Cmdist mailing list
[email protected]
https://cm-mail.stanford.edu/mailman/listinfo/cmdist

Reply via email to