[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Oddball Event Handling (Longer than it Ought to Be)
- Subject: Re: Oddball Event Handling (Longer than it Ought to Be)
- From: davidf(at)dfanning.com (David Fanning)
- Date: Sun, 31 Dec 2000 12:01:38 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <MPG.14b8681e8daad5f6989cd6@news.frii.com> <on1yuooaqq.fsf@cow.physics.wisc.edu>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:22782
Craig Markwardt (craigmnet@cow.physics.wisc.edu) writes:
> Thanks for the cool description of you project.
>
> Now, prepare to be lightly toasted :-)
>
> > FUNCTION FindTLB, startID
> >
> > ; This function traces up the widget hierarchy to find the top-level base.
> >
> > FORWARD_FUNCTION FindTLB
> > parent = Widget_Info(startID, /Parent)
> > IF parent EQ 0 THEN RETURN, startID ELSE parent = FindTLB(parent)
> > RETURN, parent
> > END
>
> I have no problem with recursion. In this case however it's not
> really needed. For the book larnin' types, this is known as tail
> recursion I believe, which is often easily optimized. I admit
> recursion may help you conceptualize what's going on though. Wouldn't
> the following code do the same thing?
>
> parent = startid
> while widget_info(parent, /parent) NE 0 do $
> parent = widget_info(parent, /parent)
Oh, sure, it would *work*. But how you gonna give
something like that away? :-)
Apparently I didn't make it clear that I wasn't
looking for criticism of my exciting new program,
but I have to admit I fooled around for a few
minutes trying to get a WHILE loop to work. But
after becoming confused I just wandered around in
the wilderness for a while, making a change here,
and another change there for no apparent rational
reason (you know, how you do when you are improvising)
and all of a sudden, BLAM, something worked.
In my personal programming myth, if something works
it is clearly the most highly optimised solution.
But thanks for your suggestion. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155