1. question on syntax[a,b,c]
- Posted by Salix <salix at freema?l?hu> Sep 24, 2007
- 655 views
Hello, I do not miss this option a lot but I would love to hear opinion. Currently the Euphoria syntax allows you to create new sequences (for printf() let's say) this way:
sx={buffer[1],buffer[2],buffer[4],buffer[5],buffer[8],buffer[3],buffer[7]} -- or sx=buffer[1..2]&buffer[4..5]&{buffer[5],buffer[8],buffer[3],buffer[7]}
At the same time it would simplify the code a bit if you could say
sx=buffer[1,2,4,5,8,3,7] -- or sx=buffer[{1,2,4,5,8,3,7}]
Just to make it clear: apart from readabilty issues I do not see any advantage, so I do not propose it to be implemented. It's just that I'd like to know the reasons of this limitation. Kind regards, Salix
2. Re: question on syntax[a,b,c]
- Posted by Pete Lomax <petelomax at blu?yonder.c?.uk> Sep 24, 2007
- 644 views
Salix wrote: > > Hello, > > I do not miss this option a lot but I would love to hear opinion. Currently > the Euphoria syntax allows you to create new sequences (for printf() let's > say) > this way: > > }}} <eucode> > sx={buffer[1],buffer[2],buffer[4],buffer[5],buffer[8],buffer[3],buffer[7]} > -- or > sx=buffer[1..2]&buffer[4..5]&{buffer[5],buffer[8],buffer[3],buffer[7]} > </eucode> {{{ > > At the same time it would simplify the code a bit if you could say > > }}} <eucode> > sx=buffer[1,2,4,5,8,3,7] > -- or > sx=buffer[{1,2,4,5,8,3,7}] > </eucode> {{{ > > Just to make it clear: apart from readabilty issues I do not see any > advantage, > so I do not propose it to be implemented. It's just that I'd like to know the > reasons of this limitation. I would say because: a) there is not much call for it, so it never got done. b) nested slices etc get tricky and we'd never agree on the syntax. c) this sort of requirement tends to be application-specific. d) it is trivial and more flexible to roll your own, eg:
function subset_of(sequence src, sequence idii) sequence res res = repeat(0,length(idii)) for j=1 to length(idii) do res[j] = src[idii[j]] end for return res end function sequence buffer, sx buffer={11,22,33,44,55,66,77,88,99} sx = subset_of(buffer,{1,2,4,5,8,3,7}) ?sx
To expand on point b, you should ask what code sh/could replace eg
sx={buffer[3][1..2],buffer[7][3][1]&buffer[4..6]}
Regards, Pete
3. Re: question on syntax[a,b,c]
- Posted by CChris <christian.cuvier at agri??lture.gouv.fr> Sep 24, 2007
- 611 views
Salix wrote: > > Hello, > > I do not miss this option a lot but I would love to hear opinion. Currently > the Euphoria syntax allows you to create new sequences (for printf() let's > say) > this way: > > }}} <eucode> > sx={buffer[1],buffer[2],buffer[4],buffer[5],buffer[8],buffer[3],buffer[7]} > -- or > sx=buffer[1..2]&buffer[4..5]&{buffer[5],buffer[8],buffer[3],buffer[7]} > </eucode> {{{ > > At the same time it would simplify the code a bit if you could say > > }}} <eucode> > sx=buffer[1,2,4,5,8,3,7] > -- or > sx=buffer[{1,2,4,5,8,3,7}] > </eucode> {{{ > > Just to make it clear: apart from readabilty issues I do not see any > advantage, > so I do not propose it to be implemented. It's just that I'd like to know the > reasons of this limitation. > > Kind regards, > > Salix You can check the OpenEu specs at http://oedoc.free.fr for an even more comprehensive slicing scheme, which include yours. Given the atmosphere, I'll include it in a fork of the language rather than hinting at adding it in, perhaps up in a few months. CChris