LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text 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:
Will Robertson <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Wed, 12 Aug 2009 09:59:57 +0930
Content-Type:
multipart/signed
Parts/Attachments:
text/plain (1813 bytes) , smime.p7s (2446 bytes)
On 12/08/2009, at 7:04 AM, Lars Hellström wrote:

> Joseph Wright skrev:
>> The re-factor saw us drop "O", and sort-of downgrade "o" (we use it
>> less). The V specifier lets you write both
>> \foo_internal:V \l_my_tl  % A macro at the TeX level
>> and
>> \foo_internal:V \l_my_toks % A toks at the TeX level
>
> (o.0)
>
> Does it inspect the argument at runtime to figure out which of the  
> two cases is at hand? Looks rather fragile & syntactic sugar to me.

The heuristic is fairly safe, I believe. It uses \ifx\noexpand#1#1 to  
detect whether the argument is a macro, and if it is not inserts \the  
to extract the value of the toks/dim/whatever. The whole thing takes  
place inside a \romannumeral expansion so the number of expansion  
steps is constant.

>> whereas \foo_internal:o would need
>> \foo_internal:o {\l_my_tl}
>> \foo_internal:o { \toks_use:N \l_my_toks }
>
> I think I would rather prefer that, myself!

Only because you know what is happening underneath :)
But, furthermore, this only works if no error checking is to occur as  
the variable is "got". With "V", provided the error checking is  
expandable, this can be transparently enabled without messing up code  
like the example above.

(There is no error checking at present, but may be added conditionally  
in the future.)

The idea is that the V expansions are a consistent wrapper around  
"getting a variable", and needn't change if the underlying machinery  
becomes different.

>> So V is preferred for accessing variables (as the internal  
>> structure is
>> not important),
>
> Wouldn't you still need to know the variable's "internal structure"  
> when setting it?

But setting does not need to be done in a known number of expansion  
steps, so the setting functions \toks_set:Nn, \tl_set:Nn, etc., all  
behave analogously.

Will

ATOM RSS1 RSS2