[texhax] Macros that define other macros
Uwe Lück
uwe.lueck at web.de
Mon Dec 3 19:15:01 CET 2012
Am Montag, den 03.12.2012, 17:41 +0100 schrieb Uwe Lück:
> Am Montag, den 03.12.2012, 16:49 +0100 schrieb Uwe Lück:
> > Am Montag, den 03.12.2012, 16:18 +0100 schrieb Uwe Lück:
> >
> > \newcommand{\setobject}[4]{%
> > \@namedef {propI|#1}{#2}%
> > \@namedef {propII|#1}{#3}%
> > \@namedef{propIII|#1}{#4}}
> >
> > would be okay without the \objectId feature, which would mean
> > something like that properties do not know whose properties
> > they are.
>
> ... thinking of the original idea that the "submacro" actually
> reports whose submacro (property) it is. I find four possibilities
> for such an \objectId feature:
> [...]
> (iii) and (iv) that I have in mind use a macro parameter
> instead of \objectId.
(iii)
\newcommand{\setAobject}[4]{%
\@namedef {propI|#1}{#2{#1}}%
\@namedef {propII|#1}{#3{#1}}%
\@namedef{propIII|#1}{#4{#1}}}
This way \useobjectproperty{O}{propI} "finally prints" {O}
unless you choose #2 so that it gobbles the argument ahead,
e.g., #2 may end on \@gobble.
I am not sure what I should tell about my previous idea of (iv).
It has been some elaboration of (iii), providing macros that
either gobble {#1} in (iii) indeed or combine it with other
information about the property, and I have thought of more than
one way to do this ...
(iii) and (iv) are somewhat more powerful than the following
simple way:
(v)
\newcommand{\setobject}[4]{%
\@namedef {propI|#1}{#2}%
\@namedef {propII|#1}{#3}%
\@namedef{propIII|#1}{#4}}
... my first way to correct my first mistake. Then to get a
"report about the object", you can define a general way such
as
\newcommand{\reportobjectproperty}[2]{%
Property `#2' of object `#1' is
\useobjectproperty{#1}{#2}.}
Then the report \reportobjectproperty{O}{P} is different from
the property itself, while, e.g., with
(vi)
\newcommand{\setSobject}[4]{%
\@nameSdef {propI}{#1}%
\@nameSdef {propII}{#1}%
\@nameSdef{propIII}{#1}}
and
\newcommand{\@nameSdef}[2]{%
\@namedef{#1|#2}{%
Property `#2' of object `#1' is me.}}
the report about object and property is part of the property.
However, would that be useful?
We can render the self-reference `me' in (vi) more formal
when we replace `me' by \useobjectproperty{#1}{#2},
but I expect that the result is not much different from the
result of
\newcommand{\run}{\run}
I tend to conclude that the original idea
\def\macromaker#1{%
\def\submacro#1{I am submacro #1}%
\def\anothersubmacro#1{I am another submacro #1}}
leads into a bad direction (in just reporting and repeating #1) ...
Cheers,
Uwe.
More information about the texhax
mailing list