You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
“big” convention: support key function as well as comparator
a small convention would be preferable
but this big convention would be trivially performant
Rebellion already follows the key convention in many cases, and also uses a comparator in other cases [which cases?]
Syntax for Rhombus’s binary =
Jack: the existing proposals (above) don’t look great
TBD
Syntax vs semantics
The syntax may vary across #langs
The present discussions are mainly about semantics that may be leveraged by any #lang
Nonlinear order with non-numeric data could be surprising
E.g. a < b, a > b, and a = b could all be false!
Users would need to be aware of this possibility for custom data
For most common cases (e.g. numbers, strings) the ordering is linear
Defining vs using these relations
At definition site they would be binary (define (less-than-proc a b) …), to define equality or order for each type. E.g. lexicographic ordering for strings would be defined using a binary function somewhere
At use site it would be the unary key function
Performance
If done as a macro, the key argument could be rewritten to a binary comparator
Static optimizations:
unary functions like string-upcase could “store” binary comparators like string-equal?, string-ci<? etc. that can be used instead of performing the unary mapping