Bill Allombert on Mon, 06 Aug 2012 15:25:29 +0200


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

Re: Patch: default(sopath), default(outputsp[aces])


On Mon, Aug 06, 2012 at 12:19:58PM +0200, Karim Belabas wrote:
> I'm not so sure: the interface is already inconsistant
> 
> - print() / write() have a print1() / write1() variant, but printtex() /
>   writetex() do not [ one must use print1(Strtex(...)) ]

But this is irrelevant because newline are not significant in TeX math mode.

> - printf() doesn't have the trailing \n, like its C counterpart.
>   And nobody complained so far.

printf implement the standard C interface, which is different from the GP
interface and is fundamentally aimed at different type of users.

> - since I'm so used to printf, I find myself often mistakenly including
>   a "\n" at the end of character strings output by print() ... [ ugly
>   double carriage return ]

Since you are C programmer, you prefer the printf interface. So use printf()
instead of print().

> I don't see why having a printsep() behave like printf() would be
> inconsistent, it's a kind of "formatted printing" after all.

If you are willing to use printf, then printsep is essentially useless to you.
(it saves you very few keystroke at the price of much loss in flexibility).
printsep is precisely targeted toward users that find the printf interface
too cumbersome. Not adding a trailing newline make it less useful than
it already is. Indeed printsep(...);print(); is longer than print(Strsep(...)).

> If we agree that 0) is not inconsistent, then 2) makes sense because
> it's annoying to be unable to print a \n without an extra separator
> showing up. In fact, one could also propose never to print a separator
> before a "\n" element, wherever it might appear in the argument list.

We spent about five years removing this kind of kludge, so I am wary to add
new ones.

> > Now, if we allow user functions with a variable number of arguments, what would be the
> > syntax ? Maybe
> > 
> > f(a,b,c,v[])=
> > {
> >   print(a);
> >   for(i=1,#v,print(v[i]))
> >   
> > }
> 
> Looks good:
> 
>   Printsep(join, v[]) =
>   {
>     for (i=1,#v,
>       print1(v[i]);
>       if (i < #v, print1(join)));
>   }
> 
> Would one be able to pass it like va_lists, as in
> 
>   Printsepln(join, v[]) = Printsep(join, v[]); print();

This is an interesting question. Of course you could also do it the C way:
vPrintsep(join, v) =
{
...
}
Printsep(join, v[]) = vPrintsep(join, v)

Cheers,
Bill.