LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Proportional Font
Show Text Part by Default
Condense Mail Headers

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

Print Reply
Sender:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Thu, 3 Dec 2009 19:02:36 +0100
Reply-To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Subject:
MIME-Version:
1.0
Content-Transfer-Encoding:
8bit
In-Reply-To:
Content-Type:
text/plain; charset=ISO-8859-1; format=flowed
From:
"Julien RIVAUD (_FrnchFrgg_)" <[log in to unmask]>
Parts/Attachments:
text/plain (68 lines)
Sorry, I messed with Thunderbird's settings and my answer was sent in HTML.

Joseph Wright a écrit :
> A couple of things here. First, active characters tend to be bad news. In my own siunitx package, I've moved from using an approach like yours in v1 to trying a different system in v2, based on \tl_replace_all_in:Nnn:
>
>   \cs_set:Nn \my_int_function:n #1 {
>     \tl_set:Nn \l_my_tmp_tl {#1}
>     \tl_replace_all_in:Nnn \l_my_tmp_tl { . } { \cheminsommet }
>     \tl_replace_all_in:Nnn \l_my_tmp_tl { : } { \cheminface   }
>    % Do more stuff with the input
>   }
>
> The reason for this is two-fold. First, active characters can cause a lot of problems (see what happens when two packages try to do something like this).
Note that those characters would be set active only in the call of the 
function; outside of it the catcode is preserved (or so I think). In 
fact, in my first version of the \chemin macro, I did some kind of 
replace, but without expl3 that meant an ugly thing with a lot of ad-hoc 
looping code. Won't search/replace be slower than setting . and : to 
macros ? Anyway, the question here is more to play with expl3 than 
anything else, getting rid of chemin as it is now isn't a priority at 
all... :)
> Second, the \tl_replace_all_in:Nnn approach means that there is only one level of replacement, which is often what people expect if they protect characters. I think the general feeling is that the team are aiming to avoid active characters as far as possible.
>   
Fair enough.
> If you do want to use \tl_rescan:Nnx, what is wrong with
>
> \group_begin:
>   \char_make_active:N \:
>   \char_make_active:N \.
>   \cs_gset:Npn \my_int_function:n #1 {
>     \tl_set_rescan:Nnx \l_my_tmp_tl
>       {
>         \char_make_active:N \:
>         \char_make_active:N \.
>         \cs_set_eq:NN . \cheminsommet
>         \cs_set_eq:NN : \cheminface 
>       } 
>       {#1}
>     % Stuff with \l_my_tmp_tl
>   }
> \group_end:
>
> or
>
> \group_begin:
>   \char_make_active:N \:
>   \char_make_active:N \.
>   \cs_gset_eq:NN . \cheminsommet
>   \cs_gset_eq:NN : \cheminface 
>   \cs_gset:Npn \my_int_function:n #1 {
>     \tl_set_rescan:Nnn \l_my_tmp_tl
>       {
>         \char_make_active:N \:
>         \char_make_active:N \.
>       } 
>       {#1}
>     % Stuff with \l_my_tmp_tl
>   }
> \group_end:
>
> (The later makes active . and : globally available, so works without x-type expansion of the tl. I'd personally go for the first of these two solutions as it again is independent of what others do.)
>   
I think I have tried such solutions, wouldn't TeX complain about 
nonexistent \char_make_active because a colon cannot anymore be in the 
name of a macro ?

Julien

ATOM RSS1 RSS2