[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sc-devel] Color(1.0, 1.0, 1.0) != nil



Hi Tom,

I found the same error here and traced it back to the following extension to Color in file "extColor-web.sc" in Wouter Snoei's very useful library:

!= { arg aColor;
^((aColor.red != red) &&
(aColor.blue != blue) &&
(aColor.green != green) &&
(aColor.alpha != alpha) );
}

This doesn't check for a nil - or any other non-Color object - being passed for comparison. So it would crash with any object that doesn't respond to methods red, blue, green, or alpha.

If I remove wslib temporarily, then 

Color(1.0, 1.0, 1.0) != nil

returns true.

I'm not clear on the need for this extension, since without wslib the following are correctly returned:

Color(1.0, 1.0, 1.0, 1.0) != nil; // returns true
Color(1.0, 1.0, 1.0, 1.0) != Color(1.0, 1.0, 1.0, 1.0); // returns false
Color(1.0, 1.0, 1.0, 1.0) != Color(0.0, 1.0, 0.0, 1.0); // returns true
Color(1.0, 1.0, 1.0, 1.0) != Color(1.0, 0.0, 1.0, 1.0); // returns true
Color(1.0, 1.0, 1.0, 1.0) != Color(1.0, 1.0, 0.0, 0.0); // returns true
Color(1.0, 1.0, 1.0, 1.0) != Color(1.0, 1.0, 1.0, 0.0); // returns true

but I'm probably missing something - Wouter? 

Cheers,

Paul


On 5 Dec 2007, at 13:30, Tom Hall wrote:

Should this cause an error?

Color(1.0, 1.0, 1.0) != nil
// => ERROR: Message 'red' not understood.

but
nil != Color(1.0, 1.0, 1.0) // => true

Color(1.0, 1.0, 1.0) == nil // => false


Regards


Tom

_______________________________________________
Sc-devel mailing list