Function overloading in macros #176
Replies: 2 comments 12 replies
-
Not only that, it would be against the design. It is currently allowed to redefine macros, like:
So, it would be hard to distinguish between a redefinition and a definition of an overload. I am thinking about adding a builtin macro
I am still thinking about a nice solution for your second sample. |
Beta Was this translation helpful? Give feedback.
-
Both use cases can now be implemented thanks to the new # "Hold" use case
Hold = $0{mul[130, default[$1, 1]]ms}
# "log" use case
switch = $0$1
_log1 = $(echo "$0" >> $LOG_FILE)
_log2 = $(pastel --force-color paint "$1" "$0" >> $LOG_FILE)
log = switch["_log", $$]["$0", "$1"] |
Beta Was this translation helpful? Give feedback.
-
@houmain Would it be a lot of work to support the same macro with varying amount of parameters? Example:
The idea came from the fact I've found my macros
Tap
andHold
great ways to make the config more readable and to allow fine tuning the value for all the mappings in one place. But in a few situations I need the value to be longer, but I couldn't come up with a good name. It then occurred to me that using a multiplier would be a even better to have the value relative to the most often needed one.Currently I've just used
HoldX
, but I remember having a similar need on some macros that execute commands earlier on. For instance it would be nice to have this...rather than this:
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions