LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Classic View

Use Proportional Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Will Robertson <[log in to unmask]>
Tue, 16 Sep 2008 08:25:31 +0930
text/plain (45 lines)
Hi,

I've been thinking more about this.
Just so we're clear, what you're looking for is a function that can be  
given a token list and return true or false depending if, without  
expansion, the list contains a quark.

So:

\def\abc{\q_stop}
\if_contains_quarks_p:n{hello\abc}     ->  'false'
\if_contains_quarks_p:n{hello\q_stop}  ->  'true'

Right?

No matter how this function is implemented, it's always going to be  
slow. One approach might be (in LaTeX2e pseudocode):

\edef\quarktest{\detokenize{\q_}}
\@ifin{\quarktest}{\detokenize{#1}}
\in@

But it's not necessarily robust. Maybe some punk will come along and  
define a whole bunch of \q_ macros that aren't quarks. Or define  
quarks that don't start with \q_. Or maybe you want to distinguish the  
case when a quark has been misspelled.

Anyway, an alternative might be to globally record all quarks are  
they're defined:

\def_new:Npn \quark_new:N #1{
   \seq_push:Nn \g_all_quarks_seq {#1}
   \tlp_new:Nn #1{#1}
}

Then \g_all_quarks_seq can be queried to answer the question "is this  
token/control sequence actually a quark?". Not fast, but it's more  
bullet-proof.

  - What do you think?
  - How necessary is it to be able to answer this question in general?
    (I.e., when you're not looking for a *specific* quark.)

Will

ATOM RSS1 RSS2