| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| 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 |
|
#2
| |||
| |||
| 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 -- //////// |
|
#3
| |||
| |||
| 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 > > -- > //////// |
|
#4
| |||
| |||
| 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! |
|
#5
| |||
| |||
| 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. |
|
#6
| |||
| |||
| 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 |
|
#7
| |||
| |||
| 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. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.