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
Over the last weeks, I ended up creating my own partial application package. One interesting feature I managed to implement that I think is pretty cool is a special "placeholder constant". It acts very similar to the _ in your @$-macro.
As an example, look at this:
greeter = println ¦ "Hello, " ¦ ⎵ ¦ ", nice to meet you!"
greeter("bobby")
# ->Hello, bobby, nice to meet you!
greeter("peter", " Have a nice Day")
# ->Hello, peter, nice to meet you! Have a nice Day
The ¦ in my code has the same role as $ in your package. The ⎵ is my placeholder constant, signifying that an argument should be supplied here.
If you want to implement this feature, one thing to consider is the name of this constant. Some suggestions:
use ⎵ (\underbracket) like I did. Advantages: expressive, the function of this is visually very obvious, unlikely to clash with other definitions made by the user/other packages loaded by the user. Disadvantage: People without IDE support (VSCode, Neovim, Jupyter) will have difficulty typing this character, as it is not part of any keyboard I know of.
use something like _! (_ itself is not possible). Advantage: still somewhat expressive, sidesteps the problem from the last point. Disadvantage: pretty ugly!
come up with something yourself...
The fact that there is a placeholder and its position should be accessible in the type signature, so code generation can make use of this and shuffle the arguments accordingly at compile time.
As in my last issue, I would supply this as a PR myself, but I am a bit short on time recently, and the way I have structured my package is quite a bit different to yours, so some adaptation is needed. I will give you a link to my code, if you want to do this you can use whatever you like from it, it is pretty simple and well documented. The relevant code is anything involving the type ReserveFunc. Anything past line 110 is just pretty printing and can be ignored.
Hello.
Over the last weeks, I ended up creating my own partial application package. One interesting feature I managed to implement that I think is pretty cool is a special "placeholder constant". It acts very similar to the
_
in your@$
-macro.As an example, look at this:
The
¦
in my code has the same role as$
in your package. The⎵
is my placeholder constant, signifying that an argument should be supplied here.If you want to implement this feature, one thing to consider is the name of this constant. Some suggestions:
⎵
(\underbracket
) like I did. Advantages: expressive, the function of this is visually very obvious, unlikely to clash with other definitions made by the user/other packages loaded by the user. Disadvantage: People without IDE support (VSCode, Neovim, Jupyter) will have difficulty typing this character, as it is not part of any keyboard I know of._!
(_
itself is not possible). Advantage: still somewhat expressive, sidesteps the problem from the last point. Disadvantage: pretty ugly!The fact that there is a placeholder and its position should be accessible in the type signature, so code generation can make use of this and shuffle the arguments accordingly at compile time.
As in my last issue, I would supply this as a PR myself, but I am a bit short on time recently, and the way I have structured my package is quite a bit different to yours, so some adaptation is needed. I will give you a link to my code, if you want to do this you can use whatever you like from it, it is pretty simple and well documented. The relevant code is anything involving the type
ReserveFunc
. Anything past line 110 is just pretty printing and can be ignored.Link: https://github.com/arikheinss/PartialApplication.jl/blob/main/src/PartialApplication.jl
The text was updated successfully, but these errors were encountered: