Re: Accumulator syntax breaks precedence

Thomas Leonard <tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]>
Newsgroups gmane.comp.lang.e.general
Message-ID <[email protected]>
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-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]
http://www.it-innovation.soton.ac.uk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.