MOO-cows Mailing List Archive


Re: A possible bug and a request...

Ron Stanions writes:
> If you have a property:     x = { 1, 2, 3, 4, 5 }
> and you do:                      x[2] = x[4] = 8;
> you would expect to get:   { 1, 8, 3, 8, 5 }
> but instead you get:          { 1, 8, 3, 4, 5 }

This is not a bug, but a (mis?)feature.  The expression `x[k] = v' is defined
in the manual to be effectively equivalent to `x = listset(x, k, v)' except
that its value is V, not the new X.  Thus, in your test case, you get something
like this:
	x = listset(x, 2, [x = listset(x, 4, 8); 8])
where I've made up a new kind of expression
which evaluates both EXPR1 and EXPR2, in that order, and then returns the value
of EXPR2.

Consider this rewriting and the fact that, for almost all kinds of expressions
and statements, MOO evaluates subexpressions from left to right.  It then
becomes clear that MOO will first fetch the *original* value of X, for passing
as the first argument to the outer call to listset(), then do
		x = listset(x, 4, 8)
and *then* do the outer call to listset().  Since the first argument to
listset() was fetched before the third argument changed the value of X, that
change is effectively lost.

I don't claim that this is good behavior, but it *is* what's documented in the
manual and, more importantly, it's what the server will keep on doing for the
foreseeable future, primarily for compatibility reasons.


> Whenever a traceback occurs it is generally difficult for a programmer 
> to get enough information out of the person it happened to to try to fix 
> it.  What would be really cool is if you could somehow store tracebacks 
> in a special property on #0,  if the property exists. That way whenever 
> a traceback occurs any programmer or wizard on line could take a look at 
> exactly what happened.

Except when the MOO is busy enough that the traceback stored there gets
overwritten before you can look at it...

The error-handling system in 1.8.0 is probably enough to make it possible for
you to implement any of a number of ways for saving and displaying tracebacks.
Take a look.



Home | Subject Index | Thread Index