From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ce0900b60ca3f616 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-13 00:53:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!sunqbc.risq.qc.ca!nf3.bellglobal.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!nntp3.aus1.giganews.com!bin2.nnrp.aus1.giganews.com.POSTED!not-for-mail From: Craig Carey Newsgroups: comp.lang.ada Subject: Re: Better control of assignment Message-ID: References: <9rti6v$hcu$1@news.huji.ac.il> <9sdnb2$dd4$1@news.huji.ac.il> <9seup3$12h0ar$2@ID-25716.news.dfncis.de> <3BEC12BA.E72A81EC@boeing.com> <9sib24$13aeg3$2@ID-25716.news.dfncis.de> <3BEDA9C2.3FB191B7@acm.org> X-Newsreader: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Organization: Customer of Mercury Telecommunications Ltd Cache-Post-Path: drone4.qsi.net.nz!unknown@tnt1-150.quicksilver.net.nz X-Cache: nntpcache 2.4.0b3 (see http://www.nntpcache.org/) X-Original-NNTP-Posting-Host: drone4-svc-skyt.qsi.net.nz X-Original-Trace: 13 Nov 2001 21:53:18 +1300, drone4-svc-skyt.qsi.net.nz X-GC-Trace: gv1-nU9u/VUq5gu+MpXiz31QnpwZ5TCdLJPmV8AQqT4MZt35/3oQ3E= NNTP-Posting-Date: Tue, 13 Nov 2001 02:53:21 CST X-Trace: sv3-SKs2pDF9ZwJ5747r0eVWJYueOmRZoz+SoEucvvCb/8myuUPdxGT1j50AHJt6a7svQB6Uk/Vi+G67kbH!1RSitjae6vb3a9CsW+ub5cBj5JNkOqD6/sQPta8Xm/4XytJxbXj9ciglY7ijygt5ENphZSsBjs1/!VIavzgY0QSnVspq8cIc= X-Complaints-To: abuse@GigaNews.Com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly Date: Tue, 13 Nov 2001 08:53:21 GMT Xref: archiver1.google.com comp.lang.ada:16400 Date: 2001-11-13T08:53:21+00:00 List-Id: On Sat, 10 Nov 2001 22:27:25 GMT, Jeffrey Carter wrote: >s only invoked for a copy (including parameter passing >> by copy (if selected)) from one variable object of type T to another. If >> this does not deliver enough control, you must make the type private. For >> example: >> >> type Odd_Counter is new Integer; >> procedure Assign_O The Oberon-2 language implements a feature of read-only record field components. Also it allows package spec variables (Module identifiers) to be exported read-only. A page on Oberon-2, that mentions the "read-only" "export mark" feature of Oberon-2, is here: http://www-cse.ucsd.edu/classes/sp01/cse131B_A/oberon2.htm | |[Module] Identifiers [variables] marked with " - " in their declaration | are read-only in importing modules. | Qualident = [ident "."]ident. | IdentDef = ident [" * " | " - "]. ... |If a [an array] or r [a record or a component record in a record] are | read-only, then also a[e] and r.f are read-only. ... |MODULE Trees; (* exports: Tree, Node, Insert, Search, Write, Init *) | IMPORT Texts, Oberon; (* exports read-only: Node.name *) | | TYPE | Tree* = POINTER TO Node; | Node* = RECORD | name-: POINTER TO ARRAY OF CHAR; | left, right: Tree | END; ... I never saw a comment saying that a using module can't assign chars to x.name^ [X.name.all]. If Ada were following closely an Oberon-2 style, then this could a the way to make Ref be read-only: type Unbounded_String is [? new Ada.Finalization.Controlled with] record Length : Natural := 0; Ref- : String_Access := ...; end record; That is sure to be rejected: the modifier ought be on the right of the ":" since it affects the type and not the name. More on Modula-2: http://www.cetus-links.org/oo_oberon.html Some selected Error messages of the "Optimizing Oberon-2 Compiler", follow. Error messages 244 & 245 imply that in Oberon, making X.Ref be exported as read-only [either the type of a module variable], where X is a record type and Ref is a pointer, does not cause X.Ref.all (i.e. X.Ref^) to be read-only. Just as is hoped for. http://ooc.sourceforge.net/OOCref/OOCref_19.html | |*201: Can only be exported with **'' | |Constants, types, and procedures cannot be exported with *-' |because the notion of a restricted, read-only access doesn't make |sense for these objects. | | |*244: This isn't a variable designator' | |This applies to the following cases: | Only a modifiable variable designator may appear on the left | side of an assignment statement. The variable designator may | not refer to a variable or record field that has been | exported as read-only. | The control variable of a FOR statement has to be an | unqualified (i.e., local) variable identifier. |Note that dereferencing a read-only pointer variable will grant |unrestricted access to the pointer's contents. | | |*245: This is imported read-only' | |This applies to the left side of an assignment statement and to |variables passed to a VAR parameter as part of a procedure call. |This means that the destination variable (or designator) has to be |either | 1. imported as read-write (and no following selector accesses | a read-only record field), or | 2. the value of a dereferenced pointer variable. |Contrary to a pointer dereference, an element of a read-only array |is read-only, just like a field of a read-only record variable. | I have doubts about Mr Carter's assignment, with its familiar right hand side is read only and left hand side is written too nature. I my proposal, the left side is read-only [i.e. writable to only by subprocedures in its package], and the right hand side can be written to (pointers swapped) even though an "in" mode parameter [this last may need to be checked]. Either that or C-isms of pointers to pointers may appear. --------- PS. I accidentally 'double posted' the same message. In some cases the duplicate could be deleted. PS. By sending data through a debugging TCP proxy, such accidents ought be harder to do. Here is Win32 GUI debugging proxy that shows bytes passing through it: TCP Viewer: http://www.westbrooksoftware.com/