LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Classic View

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

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

Print Reply
"Julien RIVAUD (_FrnchFrgg_)" <[log in to unmask]>
Thu, 3 Dec 2009 19:02:36 +0100
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