comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » _overloadMinus: what to do with invalid input?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
_overloadMinus: what to do with invalid input? [message #89928] Mon, 29 December 2014 10:34 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Hello,

I am overloading the "-" operator for various objects and I have a
philosophical question about what to do when the objects do not match.

For example, should one return a FALSE result if the objects are not the
same, e.g.

FUNCTION Cloud::_overloadMinus, left, right
IF ( (~ ISA(left,'Cloud')) || (~ ISA(right,'Cloud')) ) THEN $
RETURN, FALSE

giving:

IDL> q = fd_cloud[0] - 1
IDL> help, q
Q INT = 0


...or should one throw an error an halt, e.g.


FUNCTION Cloud::_overloadMinus, left, right
IF ( (~ ISA(left,'Cloud')) || (~ ISA(right,'Cloud')) ) THEN $
MESSAGE, 'Must supply two Cloud objects for subtraction'

leading to:

IDL> q = fd_cloud[0] - 1
% CLOUD::_OVERLOADMINUS: Must supply two Cloud objects for subtraction


Which is the more idiomatic for IDL?

cheers,

paulv
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: CGContour with and without cell_fill keyword
Next Topic: Create an array of color name

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:44:13 PDT 2025

Total time taken to generate the page: 0.00384 seconds