ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* the difference between \def and \define
@ 2013-04-15 13:47 Tim Li
  2013-04-15 14:04 ` Wolfgang Schuster
  2013-04-15 14:07 ` Marco Patzer
  0 siblings, 2 replies; 14+ messages in thread
From: Tim Li @ 2013-04-15 13:47 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 370 bytes --]

In plain TeX, we always use \def for creating a new macro, but in ConTeXt, sometimes it won't work, especially when making own chapter titles. The \def can produce the error message like this : "Argument of \... has an extra }". \define in ConTeXt can solve this problem. What's the difference between \def and \define? Can I use \define to replace all \def? 		 	   		  

[-- Attachment #1.2: Type: text/html, Size: 604 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-15 13:47 the difference between \def and \define Tim Li
@ 2013-04-15 14:04 ` Wolfgang Schuster
  2013-04-15 14:07 ` Marco Patzer
  1 sibling, 0 replies; 14+ messages in thread
From: Wolfgang Schuster @ 2013-04-15 14:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 717 bytes --]


Am 15.04.2013 um 15:47 schrieb Tim Li <timli2013@outlook.com>:

> In plain TeX, we always use \def for creating a new macro, but in ConTeXt, sometimes it won't work, especially when making own chapter titles. The \def can produce the error message like this : "Argument of \... has an extra }". \define in ConTeXt can solve this problem.
>  
> What's the difference between \def and \define? Can I use \define to replace all \def?

The \define command is a short form for \unexpanded\def which prevents commands to be expanded when used inside \edef or when passed to Lua.

Most of the high level commands are created to be unexpanded and expandable commands are used for internal functions.

Wolfgang


[-- Attachment #1.2: Type: text/html, Size: 1557 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-15 13:47 the difference between \def and \define Tim Li
  2013-04-15 14:04 ` Wolfgang Schuster
@ 2013-04-15 14:07 ` Marco Patzer
  2013-04-15 14:12   ` Hans Hagen
  1 sibling, 1 reply; 14+ messages in thread
From: Marco Patzer @ 2013-04-15 14:07 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1136 bytes --]

On 2013–04–15 Tim Li wrote:

> What's the difference between \def and \define?

\define is basically the same as \unexpanded\def. It uses a slightly
different syntax for specifying optional arguments:

  \define[3]\foo{First: #1, Second: #2, Third: #3}
  \unexpanded\def\foo#1#2#3{First: #1, Second: #2, Third: #3}

Furthermore, \define displays a message if the command is already
defined:

  system   > command '\foo' is already defined

However, ConTeXt happily overwrites the existing macro.

> Can I use \define to replace all \def?

There is \defineexpandable, which uses the same syntax as \define,
but it's a simple \def, without \unexpanded which is the closest
replacement.

I don't think named parameters are possible with \define, but maybe
I'm mistaken.

  \def\bar#first#second{First: #first, Second: #second}

For you information, there's also

  \starttexdefinition mycmd #1
    …
  \stoptexdefinition

  \starttexdefinition mycmd $#first #second
    …
  \stoptexdefinition


  \starttexdefinition unexpanded mycmd #first #second
    …
  \stoptexdefinition


Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-15 14:07 ` Marco Patzer
@ 2013-04-15 14:12   ` Hans Hagen
  2013-04-15 14:21     ` Wolfgang Schuster
  2013-04-15 14:26     ` Marco Patzer
  0 siblings, 2 replies; 14+ messages in thread
From: Hans Hagen @ 2013-04-15 14:12 UTC (permalink / raw)
  To: ntg-context

On 4/15/2013 4:07 PM, Marco Patzer wrote:

> I don't think named parameters are possible with \define, but maybe
> I'm mistaken.

just use suffix .mkvi or put "% macros=mkvi" at the top of your file


-----------------------------------------------------------------
                                           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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-15 14:12   ` Hans Hagen
@ 2013-04-15 14:21     ` Wolfgang Schuster
  2013-04-16  8:42       ` Hans Hagen
  2013-04-15 14:26     ` Marco Patzer
  1 sibling, 1 reply; 14+ messages in thread
From: Wolfgang Schuster @ 2013-04-15 14:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 15.04.2013 um 16:12 schrieb Hans Hagen <pragma@wxs.nl>:

> On 4/15/2013 4:07 PM, Marco Patzer wrote:
> 
>> I don't think named parameters are possible with \define, but maybe
>> I'm mistaken.
> 
> just use suffix .mkvi or put "% macros=mkvi" at the top of your file

Marco tries to do something like

  \define[3]\Test{#one#two#three}

which doesn’t work.

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-15 14:12   ` Hans Hagen
  2013-04-15 14:21     ` Wolfgang Schuster
@ 2013-04-15 14:26     ` Marco Patzer
  1 sibling, 0 replies; 14+ messages in thread
From: Marco Patzer @ 2013-04-15 14:26 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 454 bytes --]

On 2013–04–15 Hans Hagen wrote:

> >I don't think named parameters are possible with \define, but maybe
> >I'm mistaken.
> 
> just use suffix .mkvi or put "% macros=mkvi" at the top of your file

That's how to enable named parameters for \def. I was talking about
\define. The arguments are provided as a number in brackets, which
makes it hard to refer to them by name:

  %% fails, of course
  \define[2]\foo{#first, #second}

Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-15 14:21     ` Wolfgang Schuster
@ 2013-04-16  8:42       ` Hans Hagen
  2013-04-16  9:05         ` Marco Patzer
  0 siblings, 1 reply; 14+ messages in thread
From: Hans Hagen @ 2013-04-16  8:42 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 4/15/2013 4:21 PM, Wolfgang Schuster wrote:
>
> Am 15.04.2013 um 16:12 schrieb Hans Hagen <pragma@wxs.nl>:
>
>> On 4/15/2013 4:07 PM, Marco Patzer wrote:
>>
>>> I don't think named parameters are possible with \define, but maybe
>>> I'm mistaken.
>>
>> just use suffix .mkvi or put "% macros=mkvi" at the top of your file
>
> Marco tries to do something like
>
>    \define[3]\Test{#one#two#three}
>
> which doesn’t work.

hm, ok, do \define is not mkvi then ... too messy to catch that one too

-----------------------------------------------------------------
                                           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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-16  8:42       ` Hans Hagen
@ 2013-04-16  9:05         ` Marco Patzer
  2013-04-16  9:10           ` Thomas A. Schmitz
  0 siblings, 1 reply; 14+ messages in thread
From: Marco Patzer @ 2013-04-16  9:05 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 620 bytes --]

On 2013–04–16 Hans Hagen wrote:

> >Marco tries to do something like
> >
> >   \define[3]\Test{#one#two#three}
> >
> >which doesn’t work.
> 
> hm, ok, do \define is not mkvi then ... too messy to catch that one too

No need to bother with that. I was just pointing out the differences
between \def and \define for Tim. And named parameters is something
\define can't do. It doesn't make sense to use named parameters with
\define, since you explicitly pass the parameter *number* in
brackets. You cannot refer to a number by name. Well, you could
theoretically, but I'd strongly object.


Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-16  9:05         ` Marco Patzer
@ 2013-04-16  9:10           ` Thomas A. Schmitz
  2013-04-16 10:11             ` Marco Patzer
  2013-04-16 10:34             ` Hans Hagen
  0 siblings, 2 replies; 14+ messages in thread
From: Thomas A. Schmitz @ 2013-04-16  9:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 04/16/2013 11:05 AM, Marco Patzer wrote:
> It doesn't make sense to use named parameters with
> \define, since you explicitly pass the parameter*number*  in
> brackets. You cannot refer to a number by name. Well, you could
> theoretically, but I'd strongly object.

Just out of curiosity: why would you object? In Lua, we have the syntax

function whatever(one, two, three)
   do something with(one, two, three)
end

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?

Thomas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-16  9:10           ` Thomas A. Schmitz
@ 2013-04-16 10:11             ` Marco Patzer
  2013-04-16 16:03               ` Hans Hagen
  2013-04-16 10:34             ` Hans Hagen
  1 sibling, 1 reply; 14+ messages in thread
From: Marco Patzer @ 2013-04-16 10:11 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 919 bytes --]

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.

Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-16  9:10           ` Thomas A. Schmitz
  2013-04-16 10:11             ` Marco Patzer
@ 2013-04-16 10:34             ` Hans Hagen
  2013-04-16 11:14               ` Alan BRASLAU
  1 sibling, 1 reply; 14+ messages in thread
From: Hans Hagen @ 2013-04-16 10:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Thomas A. Schmitz

On 4/16/2013 11:10 AM, Thomas A. Schmitz wrote:
> On 04/16/2013 11:05 AM, Marco Patzer wrote:
>> It doesn't make sense to use named parameters with
>> \define, since you explicitly pass the parameter*number*  in
>> brackets. You cannot refer to a number by name. Well, you could
>> theoretically, but I'd strongly object.
>
> Just out of curiosity: why would you object? In Lua, we have the syntax
>
> function whatever(one, two, three)
>    do something with(one, two, three)
> end
>
> 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?

there is a commented blob that implements thinsg like this

\starttext
     \define[2]\whatevera{#1+#2}
     \whatevera{A}{B}
     \define[me][too][2]\whateverb{#1+#2+#3+#4}
     \whateverb[A]{B}{C}
     \whateverb[A][B]{C}{D}
     \define[alpha][beta][gamma][delta]\whateverc{#1+#2+#3+#4}
     \whateverc[P][Q]
\stoptext

but it's just an old idea.

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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-16 10:34             ` Hans Hagen
@ 2013-04-16 11:14               ` Alan BRASLAU
  2013-04-16 12:01                 ` Hans Hagen
  0 siblings, 1 reply; 14+ messages in thread
From: Alan BRASLAU @ 2013-04-16 11:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: pragma, Thomas A. Schmitz

Since the question has been raised about understanding \define, etc.
indeed some use remains a bit unclear (to me).

On Tue, 16 Apr 2013 12:34:48 +0200
Hans Hagen <pragma@wxs.nl> wrote:

> there is a commented blob that implements thinsg like this
> 
> \starttext
>      \define[2]\whatevera{#1+#2}
>      \whatevera{A}{B}
>      \define[me][too][2]\whateverb{#1+#2+#3+#4}
>      \whateverb[A]{B}{C}
>      \whateverb[A][B]{C}{D}
>      \define[alpha][beta][gamma][delta]\whateverc{#1+#2+#3+#4}
>      \whateverc[P][Q]
> \stoptext
> 
> but it's just an old idea.

I am perhaps a bit bewildered today... but I do not understand the
above. It gets too tricky for me!

In fact, I do not understand well the handling of arguments,
especially optional variants.
For example,
	\define[1]\Index{\index{#1}#1}
can be handy. But let's say that I want to be able to use a variant:
	\Index[alpha]{$\alpha$}
(\index[alpha]{$\alpha$}$\alpha$)

Or, maybe, I might like to handle authors:
	\define[2]\Author{\index{#2, #1}#1 #2}
	\Author{Thomas A.}{Schmitz}
But what if I were to type \Author{Aristotle}?

Alan

P.S. I indeed like the idea of the suggestion:

\define[one,two,three]\whatever{first: #one second: #two third: #three}

On 4/16/2013 11:10 AM, Thomas A. Schmitz wrote:
> It certainly isn't an urgent need, but having
>
> \define[one,two,three]
>
> wouldn't be absurd, now would it?
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-16 11:14               ` Alan BRASLAU
@ 2013-04-16 12:01                 ` Hans Hagen
  0 siblings, 0 replies; 14+ messages in thread
From: Hans Hagen @ 2013-04-16 12:01 UTC (permalink / raw)
  To: Alan BRASLAU; +Cc: mailing list for ConTeXt users, Thomas A. Schmitz

On 4/16/2013 1:14 PM, Alan BRASLAU wrote:
> Since the question has been raised about understanding \define, etc.
> indeed some use remains a bit unclear (to me).
>
> On Tue, 16 Apr 2013 12:34:48 +0200
> Hans Hagen <pragma@wxs.nl> wrote:
>
>> there is a commented blob that implements thinsg like this
>>
>> \starttext
>>       \define[2]\whatevera{#1+#2}
>>       \whatevera{A}{B}
>>       \define[me][too][2]\whateverb{#1+#2+#3+#4}
>>       \whateverb[A]{B}{C}
>>       \whateverb[A][B]{C}{D}
>>       \define[alpha][beta][gamma][delta]\whateverc{#1+#2+#3+#4}
>>       \whateverc[P][Q]
>> \stoptext
>>
>> but it's just an old idea.
>
> I am perhaps a bit bewildered today... but I do not understand the
> above. It gets too tricky for me!

that's why it's commented code -)

\define
   [optional-arg-1-default][optional-arg-2-default]...[number of {} args]

but .. not likely to become enabled anyway (was an experiment)

> Or, maybe, I might like to handle authors:
> 	\define[2]\Author{\index{#2, #1}#1 #2}
> 	\Author{Thomas A.}{Schmitz}
> But what if I were to type \Author{Aristotle}?

the [] are optional with an optional default

> \define[one,two,three]\whatever{first: #one second: #two third: #three}

that's not too complex to implement (as mkvi) if there's enough votes 
for it

> On 4/16/2013 11:10 AM, Thomas A. Schmitz wrote:
>> It certainly isn't an urgent need, but having
>>
>> \define[one,two,three]
>>
>> wouldn't be absurd, now would it?


-- 

-----------------------------------------------------------------
                                           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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: the difference between \def and \define
  2013-04-16 10:11             ` Marco Patzer
@ 2013-04-16 16:03               ` Hans Hagen
  0 siblings, 0 replies; 14+ messages in thread
From: Hans Hagen @ 2013-04-16 16:03 UTC (permalink / raw)
  To: ntg-context

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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-04-16 16:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-15 13:47 the difference between \def and \define Tim Li
2013-04-15 14:04 ` Wolfgang Schuster
2013-04-15 14:07 ` Marco Patzer
2013-04-15 14:12   ` Hans Hagen
2013-04-15 14:21     ` Wolfgang Schuster
2013-04-16  8:42       ` Hans Hagen
2013-04-16  9:05         ` Marco Patzer
2013-04-16  9:10           ` Thomas A. Schmitz
2013-04-16 10:11             ` Marco Patzer
2013-04-16 16:03               ` Hans Hagen
2013-04-16 10:34             ` Hans Hagen
2013-04-16 11:14               ` Alan BRASLAU
2013-04-16 12:01                 ` Hans Hagen
2013-04-15 14:26     ` Marco Patzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).