If someone had a good example to explain the nuances between the two handlers, it would be nice!
Asked
Active
Viewed 217 times
9
1 Answers
11
The .store in handler is defined (line 818 of pgfkeys.code.tex) as:
\pgfkeys{/handlers/.store in/.code=%
\pgfkeysalso{\pgfkeyscurrentpath/.code=\def#1{##1}}}
So, as Jake says in its comment, the two lines below are equivalent:
d/.store in=\macro@d,
d/.code = {\def\macro@d{#1}}
The .store in handler is just a convenience handler defined by the more powerful .code handler.
Paul Gaborit
- 70,770
- 10
- 176
- 283
-
so why two handlers to do the same things ? My english is not good enough to understand this kind of subtlety in the pgfmanual ! I love to read the code of pgf but ... – Alain Matthes Mar 30 '16 at 12:11
-
1@AlainMatthes as I see it the
.codehandler is more general as it allows for arbitrary code while.store inalways puts its input in a macro. – cgnieder Mar 30 '16 at 12:18 -
(the definition of
.store inactually is a good example as it is defined in terms of.code.) – cgnieder Mar 30 '16 at 12:21 -
-
-
Paul, finally your lines are equivalent but not
.storein and.code. The first one is a special case of the second ..codecan be more complex if I understand well all the comments. – Alain Matthes Mar 30 '16 at 12:29 -
2@AlainMatthes I never says that
.store inhandler and.codehandler are equivalent. As Jake says:.store inis just a convenience handler defined by the more powerful.codehandler. – Paul Gaborit Mar 30 '16 at 12:43 -
Note that in the def version you have to double as many as possible if
/.codegoes into nested styles etc.####1and so on. Also it is already scoped with the current context. – percusse Mar 30 '16 at 13:08 -
@percusse You are right... but your remark is valid for any
\definition. – Paul Gaborit Mar 30 '16 at 13:21 -
-
@percusse Exact (And I understand better Symbol 1's comment:
.store inis argument free) – Paul Gaborit Mar 30 '16 at 13:27
mykey/.store in=\mymacroin order to be able to access the key value by calling\mymacro. The.codehandler doesn't allow you to do that. Maybe you could include an example of how you're using these handlers? – Jake Mar 30 '16 at 07:46path/key/.code={something}defines, internally, a macro with one argument. It is just like\def\PathKeyCode#1{something}. But.store, on the other hand, is argument-free. – Symbol 1 Mar 30 '16 at 07:56d/.code = {\def\macro@d{#1}}andd/.store in={\macro@d}equivalent, or is one preferable to the other?". Correct? – Jake Mar 30 '16 at 08:02.store inas superfluous, saying that you might just as well store the value in the key. But I seem to end up using this all the time. Probably because I don't really understand things properly. (But why is it provided if it is really so unnecessary? Is it bad to use it? I'm really unclear.) – cfr Apr 03 '16 at 02:00