1. Multiple assignment?

I'm still finding my way around Eu, and keep getting confused by possibilities in other languages.

Right now, I am looking for a tidy way to pull elements from a sequence into separate variables, something like

-- object a, b, c 
-- sequence s = { 111, 222, 333 } 
-- a , b, c = s 
-- 
-- yielding a=>111, b=>222, c=>333 

Is there any idiom for doing something like that in Eu?

new topic     » topic index » view message » categorize

2. Re: Multiple assignment?

boater said...

I'm still finding my way around Eu, and keep getting confused by possibilities in other languages.

Right now, I am looking for a tidy way to pull elements from a sequence into separate variables, something like

-- object a, b, c 
-- sequence s = { 111, 222, 333 } 
-- a , b, c = s 
-- 
-- yielding a=>111, b=>222, c=>333 

Is there any idiom for doing something like that in Eu?

With the next version of Euphoria (v4.1) you will be able to do multiple assignments. For example ...

function f( sequence x) 
 
   return x * x + 2 * x + length(x) 
    
end function 
 
object a,b,c 
 
{a,b,c} = {1,2,3}  -- Assign literal values to each of 'a', 'b', and 'c' 
 
? {a,b,c} 
 
{c,?,b} = f({a,b,c}) -- Assign function return elements.  
                     -- But note the '?' means skip respective element. 
? {a,b,c} 
 
{a,b} = {b,a} -- swap two items. 
 
? {a,b,c} 
 
{a} = f({a,b,c}) -- Also handles unmatched number of elements  
 
? {a,b,c} 
 

This will display ...

{1,2,3} 
{1,18,6} 
{18,1,6} 
{363,1,6} 

new topic     » goto parent     » topic index » view message » categorize

3. Re: Multiple assignment?

boater said...

I'm still finding my way around Eu, and keep getting confused by possibilities in other languages.

Right now, I am looking for a tidy way to pull elements from a sequence into separate variables, something like

-- object a, b, c 
-- sequence s = { 111, 222, 333 } 
-- a , b, c = s 
-- 
-- yielding a=>111, b=>222, c=>333 

Is there any idiom for doing something like that in Eu?

Not in 4.0, but in the unreleased 4.1 development version there is:

{a , b, c} = s 

Matt

new topic     » goto parent     » topic index » view message » categorize

4. Re: Multiple assignment?

mattlewis said...

Not in 4.0, but in the unreleased 4.1 development version there is:

{a , b, c} = s 

Matt

Sounds like exactly what need! Anyone want to hazard a guess when 4.1 will be out?

new topic     » goto parent     » topic index » view message » categorize

5. Re: Multiple assignment?

boater said...
mattlewis said...

Not in 4.0, but in the unreleased 4.1 development version there is:

{a , b, c} = s 

Matt

Sounds like exactly what need! Anyone want to hazard a guess when 4.1 will be out?

It's been held up indefinitely, with no time table towards a release.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Multiple assignment?

jimcbrown said...
boater said...
mattlewis said...

Not in 4.0, but in the unreleased 4.1 development version there is:

{a , b, c} = s 

Matt

Sounds like exactly what need! Anyone want to hazard a guess when 4.1 will be out?

It's been held up indefinitely, with no time table towards a release.

Does this mean OpenEuphoria is, more or less, Dead?
Andreas

new topic     » goto parent     » topic index » view message » categorize

7. Re: Multiple assignment?

andi49 said...
jimcbrown said...
boater said...
mattlewis said...

Not in 4.0, but in the unreleased 4.1 development version there is:

{a , b, c} = s 

Matt

Sounds like exactly what need! Anyone want to hazard a guess when 4.1 will be out?

It's been held up indefinitely, with no time table towards a release.

Does this mean OpenEuphoria is, more or less, Dead?
Andreas

No. If nothing else, 4.0.6 will get out. And of course, fixes and improvements are still going into the pre-alpha 4.1 during the wait.

new topic     » goto parent     » topic index » view message » categorize

8. Re: Multiple assignment?

mattlewis said...

in the unreleased 4.1 development version there is:

{a , b, c} = s 

I just had a thought. Can it (already) do this:

{{a,b},{c,d}} = s 

as shorthand for

a = s[1][1] 
b = s[1][2] 
c = s[2][1] 
d = s[2][2] 

Also, since it already allows

{a} = {1,2,3} 

it should allow

{} = {1,2,3} 

and hence

{a,{},c} = {1,2,3} 

rather than/as an alternative to

{a,?,c} = {1,2,3} 

Pete

new topic     » goto parent     » topic index » view message » categorize

9. Re: Multiple assignment?

DerekParnell said...

With the next version of Euphoria (v4.1) you will be able to do multiple assignments. For example ...

Is this officially documented anywhere yet?

Pete

new topic     » goto parent     » topic index » view message » categorize

10. Re: Multiple assignment?

petelomax said...
DerekParnell said...

With the next version of Euphoria (v4.1) you will be able to do multiple assignments. For example ...

Is this officially documented anywhere yet?

Yes. It's in the 4.1.0 release notes:

said...

Can [[assign to multiple variables -> :Multiple Assignment]] with one statement using sequence semantics.

...and documented in the 4.1.0 documentation.

Matt

new topic     » goto parent     » topic index » view message » categorize

11. Re: Multiple assignment?

Would it be easy to extend multiple assignments to multiple constants?
For example:

constant (X,Y} = somefunction() 

This would have the same effect as:

object a,b 
{a,b} = somefunction() 
constant X=a, Y=b 
new topic     » goto parent     » topic index » view message » categorize

12. Re: Multiple assignment?

ArthurCrump said...
constant {X,Y} = somefunction() 

I quite like that. You could also have something like:

  integer {{a,sequence s},object o} = <Expr>; 

(I moved the leading type outside the {} to simplify parsing.)
(I have considered but not actually implemented either of these.)

Pete

new topic     » goto parent     » topic index » view message » categorize

13. Re: Multiple assignment?

jimcbrown said...
boater said...

Sounds like exactly what need! Anyone want to hazard a guess when 4.1 will be out?

It's been held up indefinitely, with no time table towards a release.

I'm puzzled. I've been using it with EuGTK for -what- around a year now, with only 1 problem, which was fixed months ago.

I don't consider EuGTK to be a 'trivial' app, so I'm guessing that it gives Eu 4.1 a pretty good workout. So what, exactly, is wrong with 4.1 as it exists?

BTW, I've posted an update of EuGTK, version 4.6.7 today. It has improved documentation, a new print engine that makes printing multi-page documents easy, and more than 200 demo programs. http://sites.google.com/site/euphoriagtk/

new topic     » goto parent     » topic index » view message » categorize

14. Re: Multiple assignment?

irv said...
jimcbrown said...
boater said...

Sounds like exactly what need! Anyone want to hazard a guess when 4.1 will be out?

It's been held up indefinitely, with no time table towards a release.

I'm puzzled. I've been using it with EuGTK for -what- around a year now, with only 1 problem, which was fixed months ago.

I don't consider EuGTK to be a 'trivial' app, so I'm guessing that it gives Eu 4.1 a pretty good workout. So what, exactly, is wrong with 4.1 as it exists?

I was referring to http://openeuphoria.org/ticket/673.wc - a Windows-only bug, but a release blocking one.

That's since been fixed (making me more optimistic about a release happening soon), so I'm not sure what's holding up 4.1 right now.

EDIT: We have had a bunch of bug fixes resulting from Matt going through the tickets and cleaning things up, along with several other fixes from our ARM developers. Maybe it's just a long hard slog to get all our t's crossed and our i's dotted.

new topic     » goto parent     » topic index » view message » categorize

15. Re: Multiple assignment?

jimcbrown said...
irv said...

So what, exactly, is wrong with 4.1 as it exists?

I was referring to http://openeuphoria.org/ticket/673.wc - a Windows-only bug, but a release blocking one.

That's since been fixed (making me more optimistic about a release happening soon), so I'm not sure what's holding up 4.1 right now.

EDIT: We have had a bunch of bug fixes resulting from Matt going through the tickets and cleaning things up, along with several other fixes from our ARM developers. Maybe it's just a long hard slog to get all our t's crossed and our i's dotted.

Yes, I've been cleaning up a lot of little things, especially documentation issues. There are some ARM things to nail down.

I think that the call-c stuff isn't working on OSX. I know we had a bunch of tickets opened on that, although we've also done a bit of work in that area, so maybe that's fixed. I don't have access to OSX, so I have no idea how we'll get that resolved. Maybe we won't, for 4.1. getlost

Matt

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu