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: signature.asc
Description: Digital signature

___________________________________________________________________________________
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
___________________________________________________________________________________

Reply via email to