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 #25219 is a reply to message #25125] Wed, 23 May 2001 08:16 Go to previous messageGo to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
Marc Schellens wrote:
>
>> 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.

Not if you introduce another operator set all together for short
circuiting. People will use them increasingly, and AND,OR will go back
to being used primarily for their bitwise function, as they should be.
Sort of like C has "&&" and "&". I can't think of good replacement
names (I assume RSI won't allow the sensible && and ||). Ideas? (ANDS?
ORS?).

JD
[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: Sat Oct 11 03:57:28 PDT 2025

Total time taken to generate the page: 2.24304 seconds