LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

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

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

Print Reply
Subject:
From:
Joseph Wright <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Thu, 12 Feb 2009 08:11:21 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (58 lines)
Will Robertson wrote:
> On 12/02/2009, at 5:00 PM, Will Robertson wrote:
> 
>> Having some more troubles, this time with \token_if_expandable.
>> Unfortunately, the only token I can find that trips this "true" is
>> \relax or \scan_stop:, which isn't exactly what I thought the intended
>> behaviour was supposed to be.
> 
> After searching through c.t.t. for a while, I found an insane thread
> talking about this sort of thing:
>   <http://groups.google.com/group/comp.text.tex/msg/2b571c53da89f86f>
> 
> Dan Luecking's comment is that
>   \expandafter\ifx\noexpand#1#1
> "seems a feasible test for expandability of a token".
> 
> I'm in a rush, and might be barking up the wrong tree here, but here's a
> re-implementation of \token_if_expandable that *seems* to behave in a
> more coherent manner.

This is still a bit odd.  For example, try:

\documentclass{article}
\usepackage{expl3}
\begin{document}

\def\foo{bar}
\def\test{\edef\test{bar}}

\ExplSyntaxOn
\def:Npn \token_if_expandable_p:N #1{
  \cs_if_exist:NTF #1 {
    \exp_after:NN \if_token_eq:NN \exp_not:N #1 #1
      \c_false \else: \c_true \fi:
  } {\c_false}
}
\def_test_function:npn {token_if_expandable:N} #1{
\if:w\token_if_expandable_p:N#1}

\noindent
Should~be~T:~\token_if_expandable:NTF \foo {T} {F} \\

Should~be~T:~\token_if_expandable:NTF \test {T} {F} \\

Should~be~F:~\token_if_expandable:NTF \undefined {T} {F} \\

Should~be~F:~\token_if_expandable:NTF \def {T} {F} \\

Should~be~F:~\token_if_expandable:NTF \the {T} {F} \\

Should~be~F:~\token_if_expandable:NTF \write {T} {F}

\ExplSyntaxOff

Look at what happens with \the.

Joseph

ATOM RSS1 RSS2