1. Multiple assignment?
- Posted by boater Jan 11, 2013
- 3212 views
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?
2. Re: Multiple assignment?
- Posted by DerekParnell (admin) Jan 11, 2013
- 3199 views
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}
3. Re: Multiple assignment?
- Posted by mattlewis (admin) Jan 11, 2013
- 3216 views
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
4. Re: Multiple assignment?
- Posted by boater Jan 11, 2013
- 3216 views
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?
5. Re: Multiple assignment?
- Posted by jimcbrown (admin) Jan 11, 2013
- 3215 views
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.
6. Re: Multiple assignment?
- Posted by andi49 Jan 12, 2013
- 3149 views
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
7. Re: Multiple assignment?
- Posted by jimcbrown (admin) Jan 12, 2013
- 3144 views
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.
8. Re: Multiple assignment?
- Posted by petelomax Jan 13, 2013
- 3061 views
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
9. Re: Multiple assignment?
- Posted by petelomax Feb 23, 2013
- 2888 views
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
10. Re: Multiple assignment?
- Posted by mattlewis (admin) Feb 23, 2013
- 2899 views
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:
Can [[assign to multiple variables -> :Multiple Assignment]] with one statement using sequence semantics.
...and documented in the 4.1.0 documentation.
Matt
11. Re: Multiple assignment?
- Posted by ArthurCrump Feb 24, 2013
- 2884 views
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
12. Re: Multiple assignment?
- Posted by petelomax Feb 28, 2013
- 2831 views
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
13. Re: Multiple assignment?
- Posted by irv Mar 07, 2013
- 2702 views
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/
14. Re: Multiple assignment?
- Posted by jimcbrown (admin) Mar 07, 2013
- 2679 views
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.
15. Re: Multiple assignment?
- Posted by mattlewis (admin) Mar 07, 2013
- 2662 views
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.
Matt