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
being able to write s("bd").sometimes(_.hurry(2)) instead of s("bd").sometimes(x=>x.hurry(2)) would be much simpler..
Right now, function arguments are a bit confusing, because sometimes you can use curried functions, e.g. fast(2) and in other cases, you cannot, e.g. x=>x.speed(2) . In cases where you can use curried functions, you still cannot chain on them: fast(2).hurry(2) does not work. Arrow functions work all the time but they are a bit verbose, so _. could be a good way to standardize function arguments. I chose "_" because it is one of the few special characters allowed as variable names + it looks like a placeholder which can be thought of the spot where the pattern on the left is inserted. The implementation could be done in various ways:
using transpilation / code as data:
very simple: code.replaceAll('_.', 'x=>x.') in the transpiler. potentially error prone in some minor cases, e.g. s("bd").sometimes(_=>_.hurry(2)) would become s("bd").sometimes(_=>x=>x.hurry(2)) . essentially it would mean you're only allowed to use _. as intended.
medium simple: doing the replacement on the AST, only if its a direct child of a function call?
being able to write
s("bd").sometimes(_.hurry(2))
instead ofs("bd").sometimes(x=>x.hurry(2))
would be much simpler..Right now, function arguments are a bit confusing, because sometimes you can use curried functions, e.g.
fast(2)
and in other cases, you cannot, e.g.x=>x.speed(2)
. In cases where you can use curried functions, you still cannot chain on them:fast(2).hurry(2)
does not work. Arrow functions work all the time but they are a bit verbose, so_.
could be a good way to standardize function arguments. I chose "_" because it is one of the few special characters allowed as variable names + it looks like a placeholder which can be thought of the spot where the pattern on the left is inserted. The implementation could be done in various ways:using transpilation / code as data:
code.replaceAll('_.', 'x=>x.')
in the transpiler. potentially error prone in some minor cases, e.g.s("bd").sometimes(_=>_.hurry(2))
would becomes("bd").sometimes(_=>x=>x.hurry(2))
. essentially it would mean you're only allowed to use _. as intended.using js
js is the safest bet, but it generates a bit more garbage (function is called 20 times per second and generates arrays all the time)
The text was updated successfully, but these errors were encountered: