diff options
Diffstat (limited to 'csc/macros.csc')
| -rw-r--r-- | csc/macros.csc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/csc/macros.csc b/csc/macros.csc index 41225ae..1edecd2 100644 --- a/csc/macros.csc +++ b/csc/macros.csc @@ -365,7 +365,7 @@ (define (identifier-uuid i) - ; Join marks by ( because symbols aren't allowed to have ( in the name. + ; Join marks by ( because symbols are unlikely to have ( in the name. (sprintf "{}({}" (apply join "(" (map number->string (marks i))) (identifier-name i))) @@ -373,12 +373,27 @@ (hash-bytevector (string->utf8 (identifier-uuid i)))) - (define (identifier<? i1 i2) - (string<? (identifier-uuid i1) (identifier-uuid i2))) + (define (marks<? m1 m2) + (loop for m1* in m1 + for m2* in m2 + if (< m1* m2*) + return #t + else if (> m1* m2*) + return #f + finally (return (< (length m1) (length m2))))) + + + (define (cmp-identifiers i1 i2) + (cond + ((bound-identifier=? i1 i2) 0) + ((or (string<? (symbol->string (identifier-name i1)) (symbol->string (identifier-name i2))) + (marks<? (marks i1) (marks i2))) + -1) + (else 1))) (define (alist->substitutions l) - (alist->map hash-identifier identifier<? l)) + (alist->map hash-identifier cmp-identifiers l)) (define (is-underscore expression) |
