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:
Frank Mittelbach <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Mon, 19 Sep 2011 12:09:15 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (86 lines)
Am 18.09.2011 15:47, schrieb Joseph Wright:
> On 18/09/2011 10:53, Philipp Stephani wrote:
>>> Part of the reasoning we had here is that \tl_new:Nn was being used
>>> almost entirely for declaring constants. We have a conceptually-separate
>>> \tl_const:Nn for that job.
>>
>> I think both make sense, just like in other programming languages,
>> where you have e.g. "const int x = ..." as well as "int x = ...".
>
> This very much depends on the other languages you are used to. Like
> Will, I guess I prefer the separate 'declare' and 'assign' operations.

well, I used \tl_new:Nn quite a lot and had to get used to not doing so

Fact is with all (!) variables you do not only declare them in TeX you
always also assign a value to them (which in case of tl is "empty" in
case of "int" is zero etc). Not in all cases this default value is the
right one and even without wanting to make a constant you might want the
initial value of an integer be 1 or what have you.

But the number of cases where this is useful is limited. In many cases
when used the reason is to set up defaults (that can be overwritten by
the user or by somebody) at a later stage through some defined
interface. In that case it is usually better to use that interface to
also set the defaults -- that is not the style 2e packages where done
but once you get the hang of it the number of stray assignments of that
sort typically vanish.

On the whole I don't mind so much (and as I said I initially started
with providing the _new:Nn version at least for tl or as they where
called tlp back then). But one thing I would like to have is
consistency, ie either for all variable types or for none.

However there are a couple of issues here (which is why I think we are
better off with the clear separation we have now):

  - _new:N is used both for local and global variables (as the
declaration of variables is always global

  - _new:Nn would need to come in two flavors one for local one for
global assignments. And no we wouldn't want to deduce it from the
variable name. Or it could be offered only for local assignments (the
way I think it was initially when \tlp_new:Nn existed)

  - there is the question of the more complex data types where it is
fairly obvious that separation of declaration and assignment is better
separated

So taking all this together I think we should stay as we are now with a
fairly clean concepts on function names per data type etc.

======================================

>>>> Also a \cs_new:N command is missing which reserves a "function" name
>>>> without assigning it.

interesting point. Initially one could argue that this is inconsistent
with the idea that we separate declaration and setting of variables. But
then this means we understand functions as being data and while in TeX
this is certainly true we have gone a long way in expl3 try go away from
this notion.

As Joseph mentioned standard "functions" in expl3, eg those with :nn
etc, are supposed to have a well defined interface of arguments that
does *not* change (even if technically nobody would prevent you from
doing so). So my question here is: are you perhaps misusing the concepts
here? Granted that there are cases where you want to redefine functions
to have different args in different situations but they are rare. So I
guess it would be interesting to see in which circumstances you think
this type of initial declaration would be useful

The most often needed cases are are defs to hold data without arguments
and for that we have our own data structure in expl3, ie. tl.

And in the other cases it is still better to to have the right signature
up front, e.g., define

\cs_new:Npn \foo:nn #1#2 {}

That couldn't be done with a single \cs_new:N unless it would deduce the
args from the  function name (which, while possible looks like a huge
overkill)

cheers
frank

ATOM RSS1 RSS2