PDA

View Full Version : Bug in Event Handlers


thatoneguy
02-08-2008, 08:35 PM
If you define an event handler as:

on spinner changed true do
(
stuff
)

it'll modify the variable "true" instead of kicking up an error.

So I had a variable "true" inadvertantly defined as an integer, which shouldn't be possible.

focomoso
02-08-2008, 09:09 PM
a bug... user error? not sure which. It's a scoping issue.

In the listener:
true = 5
-- Cannot assign to read-only variable: true

but:
(
true = 5
print true
)
5
5

So in a scope, you're setting a local variable, true, to a value.

Kramsurfer
02-08-2008, 09:48 PM
Wow... that's fun...


(
tn = false;false = true;true = tn

if not true then
(
format "%:%\n" true false
)
)



Imagine the choas... :-)

You can create statements that are true when NOT true... ha ha... forget encrytion, just write your scripts to not work and other people will never figure out how it does...

thatoneguy
02-08-2008, 11:01 PM
Adventures in realllllllly wonky code.

rollout bob "bob"
(
checkbox true "spinner"
on true changed true do
(
if true == false then
(
print "True Equals False which equals a checkbox..."
)
else
(
true = "Not false"
print true
)
)
)
createdialog bob

Jon-Huhn
02-09-2008, 01:53 AM
Gavin, that's just plain disturbing...:)

thatoneguy
02-13-2008, 07:11 PM
Pretty much the possibilities are endless. You can even redefine undefined and just about any built in function... as another function :/

(
false = true
undefined = false
array = #(5,3,2,1,4)
sort = "oops"
box = "ohno!"
maya = "the other app"
max = maya
fn box =
(
print "hello"
sphere()
)
fn sort sort =
(
print "Just so you know. True == False and undefined == false which actually equals true"
box()
)

if true == false and true == undefined and max == maya then
(
sort array
)
)
Print "What should Happen:"
sort #(5,3,2,1,4)

JHN
02-13-2008, 08:24 PM
I think the official term for this is operator and function overloading and can be done in at least c++ don't know about other programming languages.. but true = false... i don't know.. :hmm: I read somewhere the c++ inventor wanted to make it possible to overload a space " ".. can you think of the posibilities and the total chaos when that happens...

-Johan

CGTalk Moderation
02-13-2008, 08:24 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.