Open sirpengi opened 9 years ago
Hi. Currently dot notation is turned immediately into property/method access on the js object (Clojure behaves the same way). After all, .toUpperCase is not a function, obj.toUpperCase is. Your idea on lifting this limitation is interesting though.
Currently, to do what you need in a concise way you could use chain
:
var r5 = ki (fn [x] (chain x (toUpperCase) (trim)))
which saves you the extra functions.
As to the curry
not working with threadf
, you're right, threadf
is not a function and it only works when invoked as a special form.
From the docs, you can chain dot notation in the following way:
However, sometimes you want to move this behavior into a function for reuse. Honestly I feel this should work, but it doesn't compile:
(Neither does
(comp .toUpperCase .trim)
, but that fails with a runtime error)If you want the same behavior composed, or partially applied, you have to do the following:
On a related note,
threadf
also doesn't work with curry. The following compiles but results in a runtime error:It kind of makes sense if you think of
threadf
as a special form, but it doesn't appear dot notation should be. Dot notation works as an argument tothreadf
, but not in any other situations?