Re: listed subscripting
- Posted by ags <eu at 531pi.co.nz> Apr 24, 2006
- 406 views
Antonio Alessi wrote: > An expression like: > }}} <eucode> > newString = > originalString[1..2]&"INSERT"&originalString[5..9]&originalString[27..$] > </eucode> {{{ > could simply become: > }}} <eucode> > newString = originalString[1..2]&"INSERT"&[5..9]&[27..$] > </eucode> {{{ > It should be plain to implement, I mean more useful than complicated... I don't think that would work very well. What if you wanted to use multiple strings like:
newString = originalString[1..2] & "INSERT" & otherString[3..5] & [5..9]
What would the "[5..9]" refer to? I like the idea of listed subscripts though. It would only be useful IMHO if it worked with predefined sequences like:
constant REPORT_FIELDS = {1,5,9,13} sequence item --in some for loop item = record[REPORT_FIELDS]
That changes the semantics codepilot originally brought up though, ie: variable[1,5,9,13] does not look the same as variable[{1,5,8,13}] and Al Getz wrote: > I've had my share of problems like this too, where you could use > some sort of functionality to deal with sequences easier. > Another that comes immediately to mind is > {a,b,c,d}=s[1,2,3,4] I think Rob has already made his views clear on multiple lvalue assignment and I tend to think it would be a headache in the context of Euphoria. What happens (even in the case of a subscript list) if the sequence s is not as long as the subscript list? Gary