Parallel Assignment # a,b=c,d=1,2

We can write:
aa = bb = cc = 1 # no need aa = ( bb = ( cc = 1 ) )

Why we cannot write:
a,b = c,d = e,f = 1,2 # error!
x = (e,f = 1,2) # show x = [1,2]
And this works:
a,b = (c,d = (e,f = 1,2))

So my question is in that case,
why we need ( ) to avoid error in parallel assignment?
Explanation?

Thanks.

···

Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

OK, I guess:

a, b = c, d = e, f = 1, 2
Ruby parse as
a, b = c, (d =e), ( f = 1), 2

But I cannot wirte like this either:
(a, b) = (c, d) = (e, f) = (1,2)

Why ?

···

D T tran55555@yahoo.com wrote:
We can write:
aa = bb = cc = 1 # no need aa = ( bb = ( cc = 1 ) )

Why we cannot write:
a,b = c,d = e,f = 1,2 # error!
x = (e,f = 1,2) # show x = [1,2]
And this works:
a,b = (c,d = (e,f = 1,2))

So my question is in that case,
why we need ( ) to avoid error in parallel assignment?
Explanation?

Thanks.


Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!


Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Hi,

···

In message “Re: Parallel Assignment # a,b=c,d=1,2” on 03/06/24, D T tran55555@yahoo.com writes:

So my question is in that case,
why we need ( ) to avoid error in parallel assignment?
Explanation?

Because yacc sucks.

						matz.

Saluton!

  • D T; 2003-06-23, 21:00 UTC:

OK, I guess:

a, b = c, d = e, f = 1, 2
Ruby parse as
a, b = c, (d =e), ( f = 1), 2

Exactely - as in

a = 1
c = 2
e = 3
puts a, b = c, d = e, f = 1, 2
1
2
3
1
2

But I cannot wirte like this either:
(a, b) = (c, d) = (e, f) = (1,2)

Why ?

Possibly because you can write

a = c = e = 1
b = d = f = 2

either?

Gis,

Josef ‘Jupp’ Schugt

Hi,

So my question is in that case,
why we need ( ) to avoid error in parallel assignment?
Explanation?

Because yacc sucks.

Anything better that we could/should/will use?

···

On Mon, 2003-06-23 at 14:43, Yukihiro Matsumoto wrote:

In message “Re: Parallel Assignment # a,b=c,d=1,2” > on 03/06/24, D T tran55555@yahoo.com writes:

  					matz.

i would be curious what the experts think of this one:

The LEMON Parser Generator

-a

···

On Wed, 25 Jun 2003, Guillaume Marcais wrote:

On Mon, 2003-06-23 at 14:43, Yukihiro Matsumoto wrote:

Hi,

In message “Re: Parallel Assignment # a,b=c,d=1,2” > > on 03/06/24, D T tran55555@yahoo.com writes:

So my question is in that case,
why we need ( ) to avoid error in parallel assignment?
Explanation?

Because yacc sucks.

Anything better that we could/should/will use?

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
~ > ruby -e ‘p(%.\x2d\x29…intern)’
====================================

Hi,

···

In message “Re: Parallel Assignment # a,b=c,d=1,2” on 03/06/26, ahoward ahoward@fsl.noaa.gov writes:

i would be curious what the experts think of this one:

The LEMON Parser Generator

I’m investigating. It can be reentrant, thread safe, and free (as in
freedom). But there’s too few document.

						matz.

If you are really willing to use a replacement for yacc/bison, what
about:

http://www.antlr.org/pccts133.html

Cheers,
Sam

Quoteing matz@ruby-lang.org, on Thu, Jun 26, 2003 at 01:34:35AM +0900:

···

Hi,

In message “Re: Parallel Assignment # a,b=c,d=1,2” > on 03/06/26, ahoward ahoward@fsl.noaa.gov writes:

i would be curious what the experts think of this one:

The LEMON Parser Generator

I’m investigating. It can be reentrant, thread safe, and free (as in
freedom). But there’s too few document.

  					matz.