Karim Belabas on Mon, 06 Aug 2012 10:23:23 +0200

 Re: [a<-b,f(a)]

```* Bill Allombert [2012-08-06 01:00]:
> Dear PARI developers,
>
> Some month ago, I have added a syntax extension
> [a<-b,f(a)] as a short cut for
> [a|a<-b,f(a)].
>
> Unfortunately this conflicts with some valid syntax:
> ? [a<3]
>   ***   syntax error, unexpected integer, expecting '-': [a<3]
>   ***                                                        ^-
> ? [a<-3]
>   ***   syntax error, unexpected ']', expecting ',': [a<-3]
>   ***                                                     ^-
> ? [a<3,1]
>   ***   syntax error, unexpected integer, expecting '-': [a<3,1]
>   ***                                                          ^-

Slightly problematic but I wouldn't call any of these a useful
construct. And all work if one surrounds the problematic 'a < 3' by
parentheses (as I would for readability in the 3rd case at the very least).

(10:02) gp > a=1
%1 = 1
(10:02) gp > [ (a<3) ]
%2 = [1]
(10:02) gp > [ (a<-3) ]
%3 = [0]
(10:03) gp > [ (a<-3), 1]
%4 = [0, 1]

> The origin of the problem is that '<-' is not a single token because
> x<-1 should be normally parsed as x < (-1), and we parse with a single
>
> Avoiding this problem was a motivation for reserving the single | sign
> for comprehension. But there are none in this [a<-b,f(a)] variant.
>
> So is there an alternative to [a<-b,f(a)] ?

One can't suggest some kind of "insertion" operator [ a << b, f(a) ] as
that clashes badly with shifts :-)

In fact, almost every operator I tried that didn't begin with '<' looked
very unnatural, and anything starting with '<' would incur the same
problem as above. One exception was [ a := b, f(a) ], but I'm not
enthusiastic.

One remote possibility would be to get rid of 'filtre' (or let it treat
comments only) and make spaces significant, as they always should have
been :-(. Then we could have the even more natural

[ a in b, f(a) ]

which I like very much. I would vote for killing <- entirely in that
case, to be replaced by 'in' always:

[a | a in b, f(a)]

etc.

Cheers,

K.B.
--
Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux1.fr/~belabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux1.fr/  [PARI/GP]
`

```

• Follow-Ups:
• Re: [a<-b,f(a)]
• From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>
• References:
• [a<-b,f(a)]
• From: Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr>