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

Home » Public Forums » archive » Re: Recursion in IDL
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: Recursion in IDL [message #877 is a reply to message #873] Mon, 05 April 1993 10:24 Go to previous message
alans is currently offline  alans
Messages: 12
Registered: September 1991
Junior Member
Recursion only works on procedures, though. It would be far more useful
for IDL to support recursive *functions*. Unfortunately, this is more
difficult for IDL's parser, I guess, because it has to distinguish between a
function call and an array subscript operation which share the same syntax.
E.G.,

function foo, bar
if (bar eq 1) then $
return, 1 else $
return, bar * foo (bar-1)
end

IDL> print,foo(2)
% Variable is undefined: FOO.
% Execution halted at FOO </dev/tty( 1)> .
% Called from FOO </dev/tty( 2)>.
% Called from $MAIN$ .

Yecch! Does anyone know a way around this? Compile it twice? (Yes,
actually I just tried and it *does* work if you ".run" it twice. (*WOW*) So
I take it all back; IDL *does* support recursive functions, albeit with an
ugly hack. For the record, I'm running IDL 3.0.0 on Sparc SunOs 4.1.1...

RSI, I understand the difficulty involved, but can something be done about
that? I never explicitly ".run" anything; I put all procedures & functions
in my IDL path, and have encouraged my colleagues to do the same...Gee,
think of the CPU-hogging Object-Oriented possibilities with this - functions
which walk structures of structures looking for a particular field names,
recursive "sizeof"-type operations, etc. It boggles the imagination! ;-)
--
Alan J.Stein MIT/Lincoln Laboratory alans@ll.mit.edu
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: PV-Wave-> Postscript-> TeX
Next Topic: multiple images with postscript in wave ?

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

Current Time: Sun Oct 12 07:14:35 PDT 2025

Total time taken to generate the page: 0.71888 seconds