Leonhard Möhring on Thu, 24 Oct 2002 14:14:03 +0200


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

Re: Parser problem


At 03:00 24.10.2002 -0700, you wrote:
On Thu, Oct 24, 2002 at 11:50:25AM +0200, Leonhard Möhring wrote:
> At 14:12 23.10.2002 -0700, you wrote:
> >Is there any description how the argument of type "s" is supposed to
> >be parsed?  I find this very counterintuitive:
> >
> >    ? a=2
> >    %1 = 2
> >    ? print(b=a"+"a)
> >    2+2
> >    ? b
>
> missing the 2 here....
>
> what's counterintuitive about it? It seems perfectly intuitive
> to me? Assign a to b yields 2 as a result and print that out,
> just perfect, isn't it?

Your analysis would be acceptable if

  b=a"+"a

were a correct PARI expression with a defined side-effect of assigning
a to b.  It is not a correct PARI expression; thus I have no idea what
the defined side effect of this non-expression should be.

Hope this helps,
Ilya


ofc Str(b=a"+"a) is valid (right now) as well, that's why you assumed
that one should have to use print(Str(b=a , "+" , a)). Hmmm.

But isn't the implicit typecasting which is done by print and Str done
in an intuitive way? It _does_ save a lot of keystrokes for sure, since
probably most ppl use a mixture of strings and variables in their debug
printouts. The argument of print is obviously something that has to be
converted to a string after all.

I'd rather skip the side effects, than the way type "s" works.
In any case, it is difficult to change this without losing backward
compability, and i guess a majority of scripts will break if you change
the way 'print' works.

I still wouldn't call it counterintuitive, but you're probably right
that this is a shortcut which is out-of-the-line to the normal parsing
& syntax.

You have got me to the point that I am unsure if it was good to introduce
this syntax, but still by far not to the point where I'd say it's so bad
that the backward compability should be broken for it.

Leonahrd