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

Home » Public Forums » archive » Re: Object programming with data...
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: Object programming with data... [message #30912 is a reply to message #30856] Wed, 22 May 2002 08:39 Go to previous messageGo to previous message
Jaco van Gorkom is currently offline  Jaco van Gorkom
Messages: 97
Registered: November 2000
Member
"Randall Skelton" <rhskelto@atm.ox.ac.uk> wrote in message
news:Pine.LNX.4.33.0205192219030.712-100000@moriarty.atm.ox. ac.uk...
> In response to some of my own questions I found a post from Ken Knighton
> in 1996 that demonstrates one way of emulating operator overloading using
> IDL functions... I'm open to other suggestions.

I have used CASE statements in the past, but also occasionally made use of
recursion, something like:

function Add, p1, p2, p3, p4, p5, p6
if n_elements(p3) eq 0 then $
return, p1+p2 $
else $
return, Add(p1+p2, p3, p4, p5, p6)
end

There is a variant which can be very quick (and sort of ugly) to add to the
start of an existing function:

function Add, p1, p2, p3, p4, p5, p6
; Add this statement for recursive parameter handling
if n_elements(p3) ne 0 then $
return, Add( Add(p1,p2), p3, p4, p5, p6)
; Original two-parameter function code follows:
return, p1+p2
end

Cheers,
Jaco
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Array Subscripting Puzzle
Next Topic: idl/idlde command line autocomplete

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

Current Time: Wed Oct 08 19:36:17 PDT 2025

Total time taken to generate the page: 0.00461 seconds