Suggestions for improvement in Euphoria
Here are a few suggestions for better methods of accessing sequences in
Euphoria.
The first (and simplest) lacking in sequence slicing is the inability to
do:
new = old[length(old)..1]
to get a reverse element-ordering. I have needed this a lot and I'm sure
I'm not the only one.
Second, I think there needs to be a better way of accessing the last
element within a sequence. Perhaps a value of -1 could be used to
represent the last element, or a character such as '~' to represent the
length of the sequence. Example:
new = old[1..length(old)]
could be the same as:
new = old[1..-1]
-or-
pointer = -1
new = old[1..pointer]
-or-
new = old[1..~]
the first and last of the new methods would severely reduce the typing
required on most slicing operations, and in some cases the second example
would allow more universal code:
if var1 = var2 then
element = 2
else
element = -1
end if
var3 = sequence[element]
Third, there needs to be better support for multi-depth slicing:
new = old[1][5][2][3]
should be replaced with:
new = old[{1, 5, 2, 3}]
-or-
pointer = {1, 5, 2, 3}
new = old[pointer]
as this would allow you to use a sequence to let you access different
depths during run-time without having to use recursive function.
Fourth, there needs to be support for grabbing many high-level elements
at once:
new = repeat(3, 0)
new[1] = old[2][3][4][1]
new[2] = old[3][3][4][1]
new[3] = old[4][3][4][1]
should be replaced with:
new = old[2..4][3][4][1]
and of course the above method of using a sequence to specify depths
could be applied to get:
pointer = {3, 4, 1}
new = old[2..4][pointer]
These are some of the things I most want changed in Euphoria. I'm curious to see
who else agrees, or if RDS is already implementing features similar to these in
the upcoming Euphoria 2.1.
|
Not Categorized, Please Help
|
|