ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Buffers vs. \def
@ 2012-04-18  9:48 Procházka Lukáš Ing. - Pontex s. r. o.
  2012-04-18 10:22 ` Hans Hagen
  2012-04-18 10:50 ` Wolfgang Schuster
  0 siblings, 2 replies; 3+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-04-18  9:48 UTC (permalink / raw)
  To: ConTeXt

[-- Attachment #1: Type: text/plain, Size: 721 bytes --]

Hello,

a question - I'm just curious:

What is advantage (or maybe intension) of using buffers over \def?

Compare:

----
\def\BufA{This is buffer A.}

\startbuffer[BufB]
   This is buffer B.
\stopbuffer

\starttext
   \BufA
   \getbuffer[BufB]

   \ifx\BufC\undefined No buffer C.\else\BufC\fi
\stoptext
----

Both ways give the required effect.

Moreover, when using \def, I can also test its existence (maybe it's also possible with buffers, but I don't know how).

Best regards,

Lukas


-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

[-- Attachment #2: t-Buf.mkiv --]
[-- Type: application/octet-stream, Size: 179 bytes --]

\def\BufA{This is buffer A.}
\startbuffer[BufB]
  This is buffer B.
\stopbuffer

\starttext
  \BufA
  \getbuffer[BufB]

  \ifx\BufC\undefined No buffer C.\fi
\stoptext

[-- Attachment #3: t-Buf.pdf --]
[-- Type: application/pdf, Size: 6365 bytes --]

[-- Attachment #4: 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] 3+ messages in thread

* Re: Buffers vs. \def
  2012-04-18  9:48 Buffers vs. \def Procházka Lukáš Ing. - Pontex s. r. o.
@ 2012-04-18 10:22 ` Hans Hagen
  2012-04-18 10:50 ` Wolfgang Schuster
  1 sibling, 0 replies; 3+ messages in thread
From: Hans Hagen @ 2012-04-18 10:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 18-4-2012 11:48, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
> Hello,
>
> a question - I'm just curious:
>
> What is advantage (or maybe intension) of using buffers over \def?

better test with

\startlines
test
test
\stoplines

also, bufferes can be flushed verbatim, as tex, as ... while macros are 
sort of frozen.

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] 3+ messages in thread

* Re: Buffers vs. \def
  2012-04-18  9:48 Buffers vs. \def Procházka Lukáš Ing. - Pontex s. r. o.
  2012-04-18 10:22 ` Hans Hagen
@ 2012-04-18 10:50 ` Wolfgang Schuster
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Schuster @ 2012-04-18 10:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 18.04.2012 um 11:48 schrieb Procházka Lukáš Ing. - Pontex s. r. o.:

> Hello,
> 
> a question - I'm just curious:
> 
> What is advantage (or maybe intension) of using buffers over \def?
> 
> Compare:
> 
> ----
> \def\BufA{This is buffer A.}
> 
> \startbuffer[BufB]
>  This is buffer B.
> \stopbuffer
> 
> \starttext
>  \BufA
>  \getbuffer[BufB]
> 
>  \ifx\BufC\undefined No buffer C.\else\BufC\fi

\ifdefined\BufC … \else … \fi

Sometimes \setvariables is a better method to store texts in a document.

> \stoptext
> ----
> 
> Both ways give the required effect.
> 
> Moreover, when using \def, I can also test its existence (maybe it's also possible with buffers, but I don't know how).

You can use \doifelsebuffer{<buffer name>}{…}{…}.

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] 3+ messages in thread

end of thread, other threads:[~2012-04-18 10:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-18  9:48 Buffers vs. \def Procházka Lukáš Ing. - Pontex s. r. o.
2012-04-18 10:22 ` Hans Hagen
2012-04-18 10:50 ` Wolfgang Schuster

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).