It's bothered me for a while now that ':' does double duty. At the start of a symbol it's part of the symbol[1], but inside it is an infix operator[2]. I just found a way to avoid this: pun '+'! Now I can stop treating ':' as an infix char. https://github.com/akkartik/wart/commit/2bdb37bd50 The challenge in doing this was to figure out when '+' should mean compose. The first answer that comes to mind is, when the args are functions. But other types can also be coercible to functions (for using them in function position). So perhaps it should mean compose if the args are both coercible to function? But what if we later refine '+' for a type that is also coercible to function? What should win then? The solution I went with was to compose only if one of the args is actually a function, without any coercions needed. I've never seen an example composing other types so far. The most I use so far is: (a (car x))
..where a is a list or hash table. That will continue to work. But let me know if you ever need to run: (a1 (a2 x))
where neither a1 nor a2 are functions.Also, comments on the aesthetics of this choice most welcome. One way to overuse it: def (foo x)
if ~list?.x
list.x
(foo+car.x + foo+cdr.x)
('+' also joins lists and strings: http://arclanguage.org/item?id=17048.)--- Now that ':' has no infix duties, I can bring back comment tokens! http://arclanguage.org/item?id=16495 And I have another idea for it that I hope to show off soon. --- [1] http://arclanguage.org/item?id=12657 [2] http://arclanguage.org/item?id=16775 |