[M3devel] quake and/or "short circuit"

Mika Nystrom mika at async.async.caltech.edu
Wed Aug 18 00:27:04 CEST 2010


If you really want it, you can always introduce "cand" and "cor" for
the short-circuit versions.

Dijkstra advises against it, though.

    Mika

Jay K writes:
>--_203e0ef7-c6fc-42ed-ad8c-3abbdc3b9c9e_
>Content-Type: text/plain; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
>
>It would have been nice for and/or to short circuit in quake like they do i=
>n C.
>
>
>Code like:
>
>if not defined("TARGET")
>  readonly TARGET =3D "I386_FREEBSD"
>else
>  if not equal(TARGET=2C "FreeBSD4")
>    readonly TARGET =3D "I386_FREEBSD"
>  end
>end
>
>
>is better written as:
>if not defined("TARGET") or not equal(TARGET=2C "FreeBSD4")
>  readonly TARGET =3D "I386_FREEBSD"
>end
>
>but that isn't allowed because equal() will complain that TARGET isn't defi=
>ned.
>
>It probably can't fixed though=2C due to e.g.:
>
>if TRUE or DoSomething()
>  ...
>end
>
>
>would be broken.
>
>
>perhaps
>OR and AND
>or short_circuit_and
>or and_shorted
>or and_short_circuit
>or and_early_out
>or and_early
>or "&&"
>or something...
>
>
>Or I should just rewrite so much quake in Modula-3...
>
>
> - Jay
> 		 	   		  =
>
>--_203e0ef7-c6fc-42ed-ad8c-3abbdc3b9c9e_
>Content-Type: text/html; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
><html>
><head>
><style><!--
>.hmmessage P
>{
>margin:0px=3B
>padding:0px
>}
>body.hmmessage
>{
>font-size: 10pt=3B
>font-family:Tahoma
>}
>--></style>
></head>
><body class=3D'hmmessage'>
>It would have been nice for and/or to short circuit in quake like they do i=
>n C.<br><br><br>Code like:<br><br>if not defined("TARGET")<br>&nbsp=3B read=
>only TARGET =3D "I386_FREEBSD"<br>else<br>&nbsp=3B if not equal(TARGET=2C "=
>FreeBSD4")<br>&nbsp=3B&nbsp=3B&nbsp=3B readonly TARGET =3D "I386_FREEBSD"<b=
>r>&nbsp=3B end<br>end<br><br><br>is better written as:<br>if not defined("T=
>ARGET") or not equal(TARGET=2C "FreeBSD4")<br>&nbsp=3B readonly TARGET =3D =
>"I386_FREEBSD"<br>end<br><br>but that isn't allowed because equal() will co=
>mplain that TARGET isn't defined.<br><br>It probably can't fixed though=2C =
>due to e.g.:<br><br>if TRUE or DoSomething()<br>&nbsp=3B ...<br>end<br><br>=
><br>would be broken.<br><br><br>perhaps<br>OR and AND<br>or short_circuit_a=
>nd<br>or and_shorted<br>or and_short_circuit<br>or and_early_out<br>or and_=
>early<br>or "&amp=3B&amp=3B"<br>or something...<br><br><br>Or I should just=
> rewrite so much quake in Modula-3...<br><br><br>&nbsp=3B- Jay<br> 	
>	 	   	=
>	  </body>
></html>=
>
>--_203e0ef7-c6fc-42ed-ad8c-3abbdc3b9c9e_--



More information about the M3devel mailing list