Joerg Arndt on Fri, 08 Mar 2013 09:29:12 +0100

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

Re: PARI 2.6 syntax 2: [f(x)|x<-a,b(x)]

* Bill Allombert <> [Mar 08. 2013 08:28]:
> Dear PARI developers,
> In PARI 2.6 I introduced the following syntax:
> [f(x)|x<-V] and
> [f(x)|x<-V,f(x)] 
> for example [x^2|x<-[1..100],isprime(x)]
> returns the list of the square of the prime number less than 100.
> The symbol <- was chosen because it was similar to Haskell syntax, and
> looked similar to both 'element of' â and to a left arrow â, so it 
> accomodates both mathematicians and computer scientists faith.
> Unfortunately the choice of the symbol <- is problematic because
> this leads to an ambiguity between x (<-) a and x < (-a), so we can
> only use it immediatly after a vertical bar |, which prevents generalizing
> the syntax.

This sounds bad.

A new keyword "in"?
Yes, this will clash with variables in existing programs.
Instead a new keyword "from"?
Not that nice but will hopefully clash much less.

> Karim proposes to use <~ instead which is not ambiguous since ~ is not
> a valid prefix operator. Unfortunately it is ugly with some fonts where
> ~ is displayed at the top instead of the middle (looking  like in <Ë). Also
> it is a 'dead key' on some system (but we already use it for transposition
> anyway). 

Slightly ugly...
When ~ is a dead key, then hitting
  ~ [space]
brings up the plain tilde, no problem here.

PERL programmers might suggest =~  (or was it ~= ?).

> Pascal proposed to use the euro symbol â, but people using US keyboard might
> find it hard to type.

Please, no.
If UTF-8 is OK, then there is a proper symbol for \in
(displayed in your message above).
But still, please don't introduce anything non-ASCII
in the language, this is opening a huge can of worms.

> Any other suggestion ?
> Cheers,
> Bill.

Best,  jj