From: David R. <ro...@ph...> - 2008-11-03 20:38:59
|
Hello, I've been playing with vpython for a course I'll be teaching this winter, and have run into what seem to be broken semantics, which I'm afraid will confuse the heck out of my students (as it confused the heck out of me). Try to predict the outcome of the following program (run interactively, so you can see the value of b): from visual import * a = sphere() a.pos = vector(0,0,0) b = a.pos a.pos = vector(1,1,1) b a.poo = vector(0,0,0) b = a.poo a.poo = vector(1,1,1) b The result differs depending on whether we are dealing with a.poo or a.pos. a.poo behaves like native python while a.pos behaves in a very confusing manner. I hope this you consider this a bug! Is there any hope to get it fixed soon? Also, does anyone have an idea how to explain the assignment semantics to me? I spent a few months hating python semantics until finally I discovered that python is fine, it's vpython that's buggy. My current plan is to advise students never to put native vpython data members on the right hand of an = sign, since that's the only way I know of to avoid extreme frustration. Is there another approach that could work? It'd be much more elegant to actually use those data members as if they were real vectors, but I don't want to lead students into the land of extremely-confusing bugs. The idea of teaching in python was to avoid weird pointer aliasing bugs, not to make them harder to track down... David |