[M3devel] quake and/or "short circuit"
hendrik at topoi.pooq.com
hendrik at topoi.pooq.com
Wed Aug 18 03:53:46 CEST 2010
On Wed, Aug 18, 2010 at 01:17:02AM +0000, Jay K wrote:
>
> I don't know what the names should be, I'm pretty comfortable with "&&" and "||".
> Short circuiting is very useful.
>
> > Dijkstra advises against it, though.
>
> That makes me question Dijkstra, not short circuiting.
He has specific reasons, having to do with programs being part of a
logical calculus. In logic, 'and' and 'or' are both commutative, so he
thinks it sim0plifies the formal calculus of programming to have them
behave the same in programs.
>
>
> Also useful is assignment being an expression.
> I wish it was in Modula-3.
So do I.
>
> Such things as:
>
>
> if ((f = fopen(..)) && fread(f,...)
>
>
> or if (p && *p)
>
>
> In the first case Modula-3 forces useless verbosity and indentation.
> In the second case Modula-3 gets it right but Quake fails.
>
> Lacking these features you end up contorting your code one way or another, such as duplicating things.
>
>
> I really can't stand code that looks like:
>
>
> result = do something
> if success(result)
> do more stuff
> if success
> do more stuff
> if succes
> do more stuff
>
>
> Modula-3 this wrong.
> Exceptions help.
> But basically I want to be able to introduce WITH or VAR anywhere, but not need to "END" them, and therefore no implied need for indentation..
It looks as if you want Modula 3 with Algol 68 syntax.
So do I.
-- hendrik
More information about the M3devel
mailing list