Karim BELABAS on Sat, 14 Dec 2002 19:49:56 +0100 (MET)

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PATCH CVS] TeX output

On Tue, 22 Oct 2002, Ilya Zakharevich wrote:
> This patch:
>   a) Introduces a new function Str1(expr,{flag=0}) which is somewhat similar
>      to Str(), but
> 	1) Takes an expression, not a string as the first argument;
> 	2) Has a different semantic of flags.
>      See the first chunk for details.
> P.S.	How should we distinguish functions with prototype "s" from functions
> 	with prototype "G" by their helpstring?  I do not think the distinction
> 	between Str and Str1 is explained well enough in what I did...

I do not like 1). Since we're making a string of it anyway, having prototype
's' instead of 'G' only means restricting the way the function may be used.
"String context" may be a debatable feature [ I think it was a mistake to
introduce it ], but it's there, documented, and it's important to maintain

In fact, it was another mistake to add a flag to Str, because now we can't
use Str like print* or write* with any number of arguments, and it's the only
function for which "String context" is in fact useful, since it allows to
directly concatenate arguments. It would be better to have e.g.

Str({str}*): concatenates its (string) argument into a single string.

\\ current Str(, 1)
Strexpand({str}*): concatenates its (string) argument into a single string,
performing tilde expansion.

\\ your Str1(, 1)
Strtex({str}*): translates its (string) arguments to TeX format and returns
the resulting string.

All of them taking an 's*' argument. In fact, I've implemented just that in
CVS [not updated documentation yet].

Comments ?

It breaks backward compatibility since Str("$HOME", 1) now produces "$HOME1",
but I doubt this has been used in many scripts yet. Also,

  Strexpand("$HOME/", dir, "/", file, ".log")

looks nicer than the old

  Str("$HOME/" dir "/" file ".log", 1)

[ since we're in "string context", it's also possible to type

  Strexpand("$HOME/" dir "/" file ".log")

but this is not necessary anymore ]

Note: I don't really see the point of getting the char value ( Str1(,2) ),
since Vecsmall does it in a more usable form ( translates a full string if
necessary, not a single char ). In any case, it has nothing to do with the
TeX representation, so it would belong to another function.

>   b) Fixes output of t_STR values in TeX format (up to some extend?);
>   d) Fixes output of variable with underscores; now
> 	1) The output is a correct TeX;
> 	2) Differently named variables are output differently.
>      Having the output pretty was not a principal aim, but judge by yourselves:
>       ? x1_2_3__22_23__32_34
>       %6 = x
>             1,2,3,[22,23],[32,34]
>       ? x_1_2_3__22_23__32_34
>       %7 = x
>             [1,2,3],[22,23],[32,34]

No problem with this. Committed to CVS.


Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425  Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud             Email: Karim.Belabas@math.u-psud.fr
F-91405 Orsay (France)           http://www.math.u-psud.fr/~belabas/
PARI/GP Home Page: http://www.parigp-home.de/