Haven't seen this use of pipes "||" before.

This is a discussion on Haven't seen this use of pipes "||" before. within the mumps forums in Programming Languages category; Long story short. I left my company then came back to program. In the mean time they had GE code a routine for them for MUCH $$$.. Found this code and was wondering if anyone had any documentation on the use of double pipes "||" I (IN="")||(GID="")||(IPROC="") Q . I tested this and it seems to work like an or. ARHAEZ>S (IN,GID,IPROC)="" ARHAEZ>I (IN="")||(GID="")||(IPROC="") W !,"ss" ss ARHAEZ>S IN=1 ARHAEZ>S GID=1 ARHAEZ>S IPROC=1 ARHAEZ>I (IN="")||(GID="")||(IPROC="") W !,"ss" *************************************** ARHAEZ>S IN="" ARHAEZ>I (IN="")||(GID="")||(IPROC="") W !,"ss" ss ARHAEZ>I (IN=""),(GID=""),(IPROC="") W !,"ss" ARHAEZ>I (IN="")!(GID="")!(IPROC="") W !,"ss" ss...

Go Back   Application Development Forum > Programming Languages > mumps

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 06-30-2008, 04:15 PM
Blackopz
Guest
 
Default Haven't seen this use of pipes "||" before.

Long story short. I left my company then came back to program. In the
mean time they had GE code a routine for them for MUCH $$$.. Found
this code and was wondering if anyone had any documentation on the use
of double pipes "||" I (IN="")||(GID="")||(IPROC="") Q . I tested
this and it seems to work like an or.

ARHAEZ>S (IN,GID,IPROC)=""
ARHAEZ>I (IN="")||(GID="")||(IPROC="") W !,"ss"
ss
ARHAEZ>S IN=1
ARHAEZ>S GID=1
ARHAEZ>S IPROC=1
ARHAEZ>I (IN="")||(GID="")||(IPROC="") W !,"ss"
***************************************
ARHAEZ>S IN=""
ARHAEZ>I (IN="")||(GID="")||(IPROC="") W !,"ss"
ss
ARHAEZ>I (IN=""),(GID=""),(IPROC="") W !,"ss"
ARHAEZ>I (IN="")!(GID="")!(IPROC="") W !,"ss"
ss
Reply With Quote
  #2  
Old 06-30-2008, 06:29 PM
Julius Kavay
Guest
 
Default Re: Haven't seen this use of pipes "||" before.

Blackopz wrote:

> this code and was wondering if anyone had any documentation on the use
> of double pipes "||" I (IN="")||(GID="")||(IPROC="") Q . I tested
> this and it seems to work like an or.


1) expr1 ! expr2 is the standard binary-OR
The steps are:
- evaluate <expr1>
- evaluate <expr2>
- return <expr1> OR <expr2>

2) expr1 ||expr2 is a short-circuit binary-OR
The steps are:
- evaluate <expr1>
- if <expr1> is true, return True, done
Notice, <expr2> will not be evaluated!
- evaluate <expr2>
- return <expr2>


An think about the side effects, for example:

K ^A
S ^A(1)=10,^A(3)=30


I (^A(1)>5)!(^A(3)>10) ... is true and the naked indicator is ^A(3)
I (^A(1)>5)||(^A(3)>10) ... is true and the naked indicator is ^A(1)

hth and
have a nice day
julius

--
////////
Reply With Quote
  #3  
Old 06-30-2008, 07:20 PM
Maury Pepper
Guest
 
Default Re: Haven't seen this use of pipes "||" before.

In addition, you should know that "||" is not standard. It was introduced by
InterSystems in Cache. It may not be available in other implimentations of
Mumps. Also, there is "&&" which is a short-circuit AND. It quits if the
first expression is false.


"Julius Kavay" <kavay@gmx.net> wrote in message
news:6ct521F3g68vkU1@mid.individual.net...
> Blackopz wrote:
>
>> this code and was wondering if anyone had any documentation on the use
>> of double pipes "||" I (IN="")||(GID="")||(IPROC="") Q . I tested
>> this and it seems to work like an or.

>
> 1) expr1 ! expr2 is the standard binary-OR
> The steps are:
> - evaluate <expr1>
> - evaluate <expr2>
> - return <expr1> OR <expr2>
>
> 2) expr1 ||expr2 is a short-circuit binary-OR
> The steps are:
> - evaluate <expr1>
> - if <expr1> is true, return True, done
> Notice, <expr2> will not be evaluated!
> - evaluate <expr2>
> - return <expr2>
>
>
> An think about the side effects, for example:
>
> K ^A
> S ^A(1)=10,^A(3)=30
>
>
> I (^A(1)>5)!(^A(3)>10) ... is true and the naked indicator is ^A(3)
> I (^A(1)>5)||(^A(3)>10) ... is true and the naked indicator is ^A(1)
>
> hth and
> have a nice day
> julius
>
> --
> ////////



Reply With Quote
  #4  
Old 07-01-2008, 08:37 AM
Blackopz
Guest
 
Default Re: Haven't seen this use of pipes "||" before.

On Jun 30, 6:20*pm, "Maury Pepper" <mpepper.scram.s...@ieee.org>
wrote:
> In addition, you should know that "||" is not standard. It was introduced by
> InterSystems in Cache. It may not be available in other implimentations of
> Mumps. *Also, there is "&&" which is a short-circuit AND. *It quits ifthe
> first expression is false.
>
> "Julius Kavay" <ka...@gmx.net> wrote in message
>
> news:6ct521F3g68vkU1@mid.individual.net...
>
>
>
> > Blackopz wrote:

>
> >> this code and was wondering if anyone had any documentation on the use
> >> of double pipes "||" *I (IN="")||(GID="")||(IPROC="") Q . *I tested
> >> this and it seems to work like an or.

>
> > 1) expr1 ! expr2 *is the standard binary-OR
> > * The steps are:
> > * - evaluate <expr1>
> > * - evaluate *<expr2>
> > * - return <expr1> OR <expr2>

>
> > 2) expr1 ||expr2 *is a short-circuit binary-OR
> > * The steps are:
> > * - evaluate <expr1>
> > * - if <expr1> is true, return True, done
> > * * Notice, <expr2> will not be evaluated!
> > * - evaluate <expr2>
> > * - return <expr2>

>
> > An think about the side effects, for example:

>
> > K ^A
> > S ^A(1)=10,^A(3)=30

>
> > I (^A(1)>5)!(^A(3)>10) *... is true and the naked indicator is ^A(3)
> > I (^A(1)>5)||(^A(3)>10) ... is true and the naked indicator is ^A(1)

>
> > hth and
> > have a nice day
> > julius

>
> > --
> > ////////- Hide quoted text -

>
> - Show quoted text -


Thank You both for the information. I appreciate it!
Reply With Quote
  #5  
Old 07-01-2008, 01:03 PM
K.S. Bhaskar
Guest
 
Default Re: Haven't seen this use of pipes "||" before.

From the GT.M documentation:

GT.M short-circuits (bypasses) strict left-to-right Boolean evaluation
in order to optimize database performance. This behavior remains
invisible to an application unless the Boolean evaluation uses an
extrinsic function. To get around this short-circuit behavior, place
extrinsic functions first in the expression (where possible).
Alternatively, store the result of such extrinsic functions in local
variables and then use those local variables in the Boolean
evaluation.

(This has been the behavior of GT.M for as long as I have been
associated with it.)

-- Bhaskar
ks dot bhaskar at fnis dot com <-- note e-mail domain

On Jun 30, 7:20*pm, "Maury Pepper" <mpepper.scram.s...@ieee.org>
wrote:
> In addition, you should know that "||" is not standard. It was introducedby
> InterSystems in Cache. It may not be available in other implimentations of
> Mumps. *Also, there is "&&" which is a short-circuit AND. *It quits if the
> first expression is false.

Reply With Quote
  #6  
Old 07-01-2008, 01:23 PM
Rod Dorman
Guest
 
Default Re: Haven't seen this use of pipes "||" before.

In article <6ct521F3g68vkU1@mid.individual.net>,
Julius Kavay <kavay@gmx.net> wrote:
> ...
>An think about the side effects, for example:
>
>K ^A
>S ^A(1)=10,^A(3)=30
>
>
>I (^A(1)>5)!(^A(3)>10) ... is true and the naked indicator is ^A(3)
>I (^A(1)>5)||(^A(3)>10) ... is true and the naked indicator is ^A(1)


Well actually the naked indicator would be ^A( in both cases,
i.e. "WRITE $D(^(5))" would yield the same result either way.

But your point about side effects is quite valid and needs to be kept
in mind when using short circuiting syntax.
--
-- Rod --
rodd(at)polylogics(dot)com
Reply With Quote
  #7  
Old 07-01-2008, 02:25 PM
Maury Pepper
Guest
 
Default Re: Haven't seen this use of pipes "||" before.

Other than extrinsic functions, doesn't GT.M's non-standard short-circuit
behavior also cause problems with 1) setting the naked indicator and 2) use
of $Increment? The advise to "place extrinsic functions first" assumes
there is only one instance of something that has a side-effect.


"K.S. Bhaskar" <ksbhaskar@gmail.com> wrote in message
news:06a3a660-4d26-4f8c-9a32-767b6f9a8430@56g2000hsm.googlegroups.com...
From the GT.M documentation:

GT.M short-circuits (bypasses) strict left-to-right Boolean evaluation
in order to optimize database performance. This behavior remains
invisible to an application unless the Boolean evaluation uses an
extrinsic function. To get around this short-circuit behavior, place
extrinsic functions first in the expression (where possible).
Alternatively, store the result of such extrinsic functions in local
variables and then use those local variables in the Boolean
evaluation.

(This has been the behavior of GT.M for as long as I have been
associated with it.)

-- Bhaskar
ks dot bhaskar at fnis dot com <-- note e-mail domain

On Jun 30, 7:20 pm, "Maury Pepper" <mpepper.scram.s...@ieee.org>
wrote:
> In addition, you should know that "||" is not standard. It was introduced
> by
> InterSystems in Cache. It may not be available in other implimentations of
> Mumps. Also, there is "&&" which is a short-circuit AND. It quits if the
> first expression is false.


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:19 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.