I am trying out l3keys for the first time and I am encountering the following issue. I have some boolean keys (true/false). For them it looks nice to use .bool_set:N so that I can get automatic validation of the value passed into the key and I also get the key value nicely stored in a boolean variable for later inspection.
At the same time, I would like to execute some code right after the variable is set. However, it looks like .code:n and bool_set:N cannot be used together on the same key, because the one that comes later substitutes the action of the first. In practice, there seems to be no possibility to run a hook triggered by the variable setting action.
Obviously, there are several possible workarounds:
run some code after every
key_set:nn.
However, this means that such code needs to check for every possible variable being set to see if it has changed and take action accordingly. If you have say 30 variables, this means checking all of them, when maybe only one of them is being changed. Having a hook invoked just for the variable that has been set seems more appropriate as long as the variables do not interact one with the other.use
.code:ninstead of the variable setting actions.
However, this means redoing the parsing and validation of the value.
Because all the workarounds seem to have inefficiencies of their own, I wonder if I am missing something... Any help is appreciated!

If I get it correctly,
\__keys_cmd_set:nnis the internal used to associate code to the keys, 1st argument is the key path and 2nd one is the code itself, is this the OK? So you are imposing that after the regular code the hook code is used, is this correct?What puzzles me a bit is the role of all those constants.
Furthermore, the variant is a little obscure to me in how it passes ##1 to the hook. Could you help me understand?
– callegar Dec 18 '18 at 16:39\__keys_cmd_set:nnis the internal to actually define a key and most/all key types are using it internally. All those constants are internals ofl3keys, too, which are supposed to assure no naming conflicts.The variant checks whether the hook has been defined (\cs_if_exist_use:cT), and if it does it inputs the control sequence and the next argument, stripping one pair of braces. So if\foo_hookexists,\cs_if_exist_use:cT { foo_hook } { { ##1 } }expands to\foo_hook { ##1 }, and\foo_hookcan absorb that argument. – Skillmon Dec 18 '18 at 17:48