🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #402

Re: The WITH statement

#402
From: jbaker
Date: Mon, 20 Nov 1989 05:35
33 lines
2025 bytes
In article <89321.154018ODX@PSUVM.BITNET> ODX@PSUVM.BITNET (Tim Larson) writes:
.   couldn't until now.  The code in question is too large to post here,
.   but it was essentially equivalent to:
.
.      WITH A[i] DO REPEAT WrInt(f, -1); INC (i) UNTIL i > 3 END;
.
.   (see the program following this message) which I intended to mean:
.
.      REPEAT WrInt(A[i].f, -1); INC (i) UNTIL i > 3;
.
.   I believe that the WITH statement as defined in Modula-2 is a bad idea.
.   Informally, we often think of the WITH statement as a way of reducing
.   the size of the source code, and that we may simply replace the field
.   names within the WITH block by the name in the WITH designator.  This

I always thought of a WITH statement differently.  It computes the location
of the record just once, freezes it, and uses that record throughout the
WITH statement.  Thus, not only does it reduce source code size, it also
increases program efficiency.

.   In any case, since Modula-2 is a good language in so many respects, and
.   assuming that the semantics will not now be changed, the compiler should
.   be made to produce a warning at the least, or perhaps even an error
.   message if the designator's value changes in the body of a WITH block.

A warning might be a good idea - but remember, it may happen frequently that
correct code would recieve a warning.  No, forget the warning.  When
looking at a WITH statement, you should always go to the WITH to find out
which record is being referred to - and remember that any computations
were made when the WITH was entered.

John Baker
Fairfax, Virginia
Technical Details
Message-ID: <2353@gmu90x.gmu.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!pyrdc!gmu90x!jbaker
References: <89321.154018ODX@PSUVM.BITNET>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!pyrdc!gmu90x!jbaker
From: jbaker@gmu90x.gmu.edu (jbaker)
Newsgroups: comp.lang.modula2
Subject: Re: The WITH statement
Message-ID: <2353@gmu90x.gmu.edu>
Date: 20 Nov 89 05:35:41 GMT
References: <89321.154018ODX@PSUVM.BITNET>
Reply-To: jbaker@gmu90x.UUCP ()
Organization: George Mason University, Fairfax, Va.
Lines: 33