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
Re: _overloadMinus: what to do with invalid input? [message #89929 is a reply to message #89928] Mon, 29 December 2014 11:41 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
Paul van Delst <paul.vandelst@noaa.gov> wrote:
> 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:
>
>> q = fd_cloud[0] - 1
>> 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:
>
>> q = fd_cloud[0] - 1
> % CLOUD::_OVERLOADMINUS: Must supply two Cloud objects for subtraction
>
>
> Which is the more idiomatic for IDL?
>
> cheers,
>
> paulv

I would think an error and halting, like IDL would do if you tried to use
an invalid operator with the native types. What happens if you try to add
two pointers? (not in front of my computer right now)

Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
[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 15:13:20 PDT 2025

Total time taken to generate the page: 0.00436 seconds