Re: Major Bug in Interpreter [Attn: Robert Craig]

new topic     » goto parent     » topic index » view thread      » older message » newer message

After reading the post you made, and doing several runs of my own, I've
come to my own conclusion of how things are working now.

You said, that you would have to make all kinds of checks throughout the
code to make sure you wasn't screwing something up.

To me, after looking at the program logic, both from execution, trial and
error, and my own thoughts on program flow with Euphoria, I can only ask, Why
this behavior was choosen over the default behavior?

And yes, this is Documented in the Reference Manual.

Section: 2.2.4 -> 2.2.9

If you notice, that's the majority of the Sequence refrence, but the
more specific points are this:

Section 2.2.5 Subscripting of Sequences
" A single element of a sequence may be selected by giving the element number in
square brackets. Element numbers start at 1. Non-integer subscripts are rounded
down to an integer.

For example, if x contains {5, 7.2, 9, 0.5, 13} then x[2] is 7.2. Suppose we
assign something different to x[2]:

        x[2] = {11,22,33}

Then x becomes: {5, {11,22,33}, 9, 0.5, 13}. Now if we ask for x[2] we get
{11,22,33} and if we ask for x[2][3] we get the atom 33. If you try to subscript
with a number that is outside of the range 1 to the number of elements, you will
get a subscript error. For example x[0], x[-99] or x[6] will cause errors. So
will x[1][3] since x[1] is not a sequence."


Now why wouldn't this be valid as well, for your addition of the $?

$ should be the last entry into the sequence, at the time of the evaluation of
the lhs, just as with length() shows the length of the sequence at the time of
evaluation.  So, if you do this:

sequence stack
stack = {1,2,3,4}
procedure removeOne()
   stack = stac[1..length(stack)-1]
end procedure

integer i
i = length(stack)
removeOne()
stack[i] = 1


It should error out.  The same should be true for the '$' operator.  I mean,
it would only make sense.  Oviously, the lhs evaluation length() is what we
are wanting, not what we add to it, or remove from it.  If we wanted that,
then we would do that after the assignment, as it has allways been done before.

I'm just trying to make sense of my own ideals of how Euphoria's rules are.
And Derek Parnell is right, this is your interpreter.  I'm just trying to
see the point of trying to account for every possibility, with a single
operator, when it isn't nesscarly needed.

Mario Steele

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu