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

Home » Public Forums » archive » bitwise operators 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: bitwise operators in IDL? [message #25125 is a reply to message #25080] Tue, 22 May 2001 22:14 Go to previous messageGo to previous message
marc schellens[1] is currently offline  marc schellens[1]
Messages: 183
Registered: January 2000
Senior Member
> It would be really nice if IDL had any logical operators, other than
> implied in the ambiguous usage of bitwise op's for different types.
> Specifically, having a "short-circuiting" AND and OR operator set would
> be exceptionally useful.
>
> How often do you find yourself doing something like:
>
> if ptr_valid(a) AND *a ge 0 then...
>
> only to find that it can't work, because AND always evaluates everything
> it operates on. Most decent languages offer short circuiting AND's (and
> OR's etc.), that stop as soon as the true solution is known. Here, if
> ptr_valid(a) is not true, there would be no need to continue to try to
> dereference 'a' (which generates an error), and this snippet would be
> correct.
>
> I guess for now we're stuck with
>
> if ptr_valid(a) then begin
> if *a ge 0 then begin...
>
> Oh the tedium.
>
> JD
To late for short circuitry.
Consider a case when the second function in the if case
has a side effect (e.g. modifying a global variable).
After once defining the language this way, to change it
would mean to introduce incopatibility.

But you can write:
if ptr_valid(a) then if *a eq b then begin
...

which looks a little bit nicer (IMHO).

cheers,
:-) marc
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: defining functions on-the-fly
Next Topic: more IDL falls asleep

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

Current Time: Sun Oct 12 02:38:50 PDT 2025

Total time taken to generate the page: 0.72664 seconds