[NTG-context] the difference between \def and \define

Hans Hagen pragma at wxs.nl
Tue Apr 16 18:03:09 CEST 2013


On 4/16/2013 12:11 PM, Marco Patzer wrote:
> On 2013–04–16 Thomas A. Schmitz wrote:
>
>> I'm not lobbying for define to have something similar, I just want
>> to point out that it would be in the spirit of convergence between
>> ConTeXt and Lua. It certainly isn't an urgent need, but having
>>
>> \define[one,two,three]
>>
>> wouldn't be absurd, now would it?
>
> Sorry, misunderstanding on my part. That one looks fine. I thought
> we're talking about translating the number to words, which wouldn't
> make any sense:
>
>    \define[3]\foo{#one, #two, #three}
>
> I still don't think it's necessary to use named parameters with
> \define. For modules most likely \def, \setvalue or texdefinition
> are being used and \define for in-document markup, wherefore
> numbered parameters are perfectly fine. The only thing that could be
> improved is a definition which doesn't interfere with \asciimode,
> but that's low priority and can easily be worked around.

It's also messy (in parsing):

\define[#one,#two]\test{#one#two}

there we have to collect and move the test backwards. Also, names 
defeats the use of the one number becoming multiple #'s so it then close to

\define\test[#one,#two]{#one#two}

which is nearly

\def\test[#one,#two]{#one#two}

apart from the checking, so i decided to provide this:

     \checked\def \whatevera#alpha#beta{#alpha + #beta}
     \checked\edef\whatevera#alpha#beta{#beta + #alpha}

     \unique \def \whateverb#alpha#beta{#alpha + #beta}
     \unique \edef\whateverb#alpha#beta{#beta + #alpha}

     \whatevera{1}{2}\par
     \whateverb{1}{2}\par

(can be used with \def \edef \xdef \gdef \udef \uedef \uxdef and \ugdef)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list