[e-lang] Accumulator syntax breaks precedence

Thomas Leonard tal at it-innovation.soton.ac.uk
Tue Feb 1 01:36:30 PST 2011


On 01/02/11 01:41, Kevin Reid wrote:
> ? e`pragma.enable("accumulator"); accum 0 while (a) { _ * b + c }`
> # value: e`null
> ...
> #                            accum__1 := accum__1.multiply(b.add(c))
> ...
>
> The accumulator syntax effectively forces the leftmost operator to be
> lowest-precedence. This seems Very Surprising.
>
> I'm mentally filing this as yet another reason the accumulator syntax
> needs to be killed and replaced with something less special; any
> disagreement?

I could never get the hang of the accumulator syntax. Is there any 
chance of something like Python-style list comprehensions and generator 
expressions?

e.g.

 >>> items = [1, 2, 3]
 >>> [2 * x for x in items]
[2, 4, 6]

With () instead of [], it creates a generator (iterator) that evaluates 
lazily:

 >>> (2 * x for x in items)
<generator object <genexpr> at 0x7fd44dea3e60>
 >>> sum(2 * x for x in items)
12
 >>> any(x > 2 for x in items)
True


-- 
Dr Thomas Leonard
IT Innovation Centre
2 Venture Road
Southampton
Hampshire SO16 7NP

Tel: +44 0 23 8076 0834
Fax: +44 0 23 8076 0833
mailto:tal at it-innovation.soton.ac.uk
http://www.it-innovation.soton.ac.uk


More information about the e-lang mailing list