comp.lang.ada
 help / color / mirror / Atom feed
From: Craig Carey <research@ijs.co.nz>
Subject: Re: Better control of assignment
Date: Tue, 13 Nov 2001 08:53:21 GMT
Date: 2001-11-13T08:53:21+00:00	[thread overview]
Message-ID: <d1l1vtce81io2p9eamke6r2h6d7bifc0qr@4ax.com> (raw)
In-Reply-To: 3BEDA9C2.3FB191B7@acm.org

On Sat, 10 Nov 2001 22:27:25 GMT, Jeffrey Carter <jrcarter@acm.org>
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/ 





  parent reply	other threads:[~2001-11-13  8:53 UTC|newest]

Thread overview: 162+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-02  3:56 List container strawman Ted Dennison
2001-11-02  4:20 ` James Rogers
2001-11-02 14:23   ` Ted Dennison
2001-11-02 14:38     ` Preben Randhol
2001-11-02 15:15     ` Larry Kilgallen
2001-11-02  4:35 ` Eric Merritt
2001-11-02 15:46   ` Ted Dennison
2001-11-02  7:28 ` Ehud Lamm
2001-11-02 14:57   ` Marin David Condic
2001-11-02 15:57     ` Francisco Javier Loma Daza
2001-11-02 16:28       ` Marin David Condic
2001-11-02 17:08         ` Ted Dennison
2001-11-02 15:06   ` Ted Dennison
2001-11-02 15:32     ` Marin David Condic
2001-11-02 16:33       ` Ted Dennison
2001-11-02 16:43         ` Marin David Condic
2001-11-02 22:51           ` Jeffrey Carter
2001-11-03  0:24             ` Matthew Heaney
2001-11-03  2:21               ` Jeffrey Carter
2001-11-03 22:51                 ` Rosen Trick [List container strawman] Nick Roberts
2001-11-04 13:07                   ` Robert Dewar
2001-11-04 17:17                     ` Side-Effects in Functions [Rosen Trick] Nick Roberts
2001-11-05  2:46                       ` Robert Dewar
2001-11-05  7:26                         ` pete
2001-11-05 10:29                           ` Dmitry A. Kazakov
2001-11-05 11:19                             ` pete
2001-11-05 14:59                               ` Dmitry A. Kazakov
2001-11-05 15:21                                 ` Preben Randhol
2001-11-05 16:04                                   ` Ted Dennison
2001-11-05 16:33                                   ` Dmitry A. Kazakov
2001-11-05 17:42                                     ` Warren W. Gay VE3WWG
2001-11-05 18:11                                       ` Preben Randhol
2001-11-06  8:38                                       ` Dmitry A. Kazakov
2001-11-06  9:31                                         ` tgingold
2001-11-06  0:10                             ` Nick Roberts
2001-11-06  9:30                               ` Dmitry A. Kazakov
2001-11-06 16:18                                 ` Lazy Evaluation [Side-Effects in Functions] Nick Roberts
2001-11-07  3:42                                   ` Robert Dewar
2001-11-07  4:42                                     ` Darren New
2001-11-07 11:54                                       ` Robert Dewar
2001-11-07 13:32                                         ` Florian Weimer
2001-11-07 13:24                                           ` Jean-Marc Bourguet
2001-11-09 18:06                                         ` Ted Dennison
2001-11-09 18:27                                           ` M. A. Alves
2001-11-11 20:13                                           ` Georg Bauhaus
2001-12-06 17:47                                             ` Harri J Haataja
2001-11-07  9:28                                   ` Dmitry A. Kazakov
2001-11-06 20:08                               ` Side-Effects in Functions [Rosen Trick] Florian Weimer
2001-11-06 22:48                                 ` Nick Roberts
2001-11-07 10:46                                   ` Florian Weimer
2001-11-05 13:56                           ` Robert Dewar
2001-11-05 16:08                             ` Ted Dennison
2001-11-05 17:44                               ` Warren W. Gay VE3WWG
2001-11-05 15:56                         ` Ted Dennison
2001-11-05 18:46                         ` Nick Roberts
2001-11-08 11:51                           ` Georg Bauhaus
2001-11-16  0:31                 ` List container strawman Vincent Marciante
2001-11-05 15:10             ` Marin David Condic
2001-11-05 18:31               ` Ted Dennison
2001-11-05 19:09                 ` Marin David Condic
2001-11-05 21:23                   ` Ted Dennison
2001-11-07 19:27                   ` Stephen Leake
2001-11-02 18:11         ` Mark Johnson
2001-11-02 18:46           ` Marin David Condic
2001-11-02 19:21           ` Larry Kilgallen
2001-11-03 22:30         ` Nick Roberts
2001-11-02 16:26   ` Ted Dennison
2001-11-02 16:36     ` Marin David Condic
2001-11-02 19:31       ` Ted Dennison
2001-11-02 17:49     ` Jeffrey Carter
2001-11-08 10:34     ` Ehud Lamm
2001-11-08 18:53       ` Better Finalisation [List container strawman] Nick Roberts
2001-11-09 13:36         ` Robert Dewar
2001-11-09 15:04           ` Florian Weimer
2001-11-10  0:36           ` Nick Roberts
2001-11-09 15:16         ` Ted Dennison
2001-11-09 17:30         ` Better control of assignment Jeffrey Carter
2001-11-10  0:32           ` Nick Roberts
2001-11-10 22:27             ` Jeffrey Carter
2001-11-13  6:36               ` Craig Carey
2001-11-13  6:39               ` Craig Carey
2001-11-13  8:53               ` Craig Carey [this message]
2001-11-14  9:42                 ` Craig Carey
2001-11-09 14:49       ` List container strawman Ted Dennison
2001-11-09 16:12         ` Ehud Lamm
2001-11-09 17:12         ` Marin David Condic
2001-11-09 18:11           ` Ted Dennison
2001-11-09 18:42           ` Matthew Heaney
2001-11-10 17:54             ` Simon Wright
2001-11-02 14:49 ` Marin David Condic
2001-11-02 15:15   ` Ted Dennison
2001-11-02 15:37     ` Marin David Condic
2001-11-02 16:49       ` Ted Dennison
2001-11-02 17:09         ` Marin David Condic
2001-11-04  0:10           ` Nick Roberts
2001-11-03 23:41         ` Nick Roberts
2001-11-02 17:02 ` David Botton
2001-11-02 17:55   ` David Botton
2001-11-03 19:22 ` Nick Roberts
     [not found] ` <3BE29AF4.80804@telepath.com>
2001-11-02 13:14   ` Ted Dennison
2001-11-02 13:31     ` Larry Kilgallen
2001-11-02 15:09       ` Ted Dennison
2001-11-02 15:13         ` Preben Randhol
2001-11-02 20:48       ` David Starner
2001-11-02 22:49         ` Larry Kilgallen
2001-11-02 17:44     ` Jeffrey Carter
2001-11-02 20:07       ` Ted Dennison
2001-11-02 23:19         ` Jeffrey Carter
2001-11-03  6:56           ` Ted Dennison
2001-11-03 19:22             ` Jeffrey Carter
2001-11-04 18:58               ` Darren New
2001-11-04 19:40                 ` Larry Kilgallen
2001-11-04 20:49                   ` Darren New
2001-11-07 19:07                   ` ramatthews
2001-11-08  0:04                     ` Darren New
2001-11-08  4:50                     ` Jeffrey Carter
2001-11-08 23:26                       ` ramatthews
2001-11-09 18:00                     ` Ted Dennison
2001-11-09 18:13                       ` Jean-Marc Bourguet
2001-11-09 18:55                         ` Ted Dennison
2001-11-10  1:48                           ` Nick Roberts
2001-11-10 17:04                             ` Ted Dennison
2001-11-10 20:59                               ` Nick Roberts
2001-11-10 23:17                                 ` Larry Hazel
2001-11-11  3:27                                   ` Nick Roberts
2001-11-12 18:39                                     ` Darren New
2001-11-13  0:35                                       ` Nick Roberts
2001-11-10 19:36                             ` Ehud Lamm
2001-11-10 20:15                               ` Nick Roberts
2001-11-09 19:27                       ` Larry Kilgallen
2001-11-09 20:03                       ` Stephen Leake
2001-11-09 21:05                         ` Ted Dennison
2001-11-09 22:42                         ` Larry Kilgallen
2001-11-10  4:52                           ` Nick Roberts
2001-11-10 20:24                       ` ramatthews
2001-11-05 19:28                 ` Ted Dennison
2001-11-05 19:42                   ` Jean-Marc Bourguet
2001-11-05 20:40                     ` Ted Dennison
2001-11-05 20:24                   ` Darren New
2001-11-05 20:45                     ` Ted Dennison
2001-11-05 17:21         ` List container strawman; Construct alternatives Stephen Leake
2001-11-03  7:42       ` List container strawman Simon Wright
2001-11-05 14:00   ` Stephen Leake
2001-11-08 11:17     ` Simon Wright
2001-11-13 16:29       ` Stephen Leake
2001-11-13 22:43         ` Jeffrey Carter
2001-11-13 22:48         ` Jeffrey Carter
2001-11-14  3:46           ` Nick Roberts
2001-11-15 10:23             ` Ehud Lamm
2001-11-14 14:50           ` Marin David Condic
2001-11-14 16:53             ` Jeffrey Carter
2001-11-14 17:59               ` Marin David Condic
2001-11-15  3:33                 ` Nick Roberts
2001-11-15 15:10                   ` Marin David Condic
2001-11-16  1:29                     ` Nick Roberts
2001-11-16 16:03                       ` Marin David Condic
2001-11-16 20:19                         ` Nick Roberts
2001-11-15 18:08                   ` Matthew Heaney
2001-11-08 14:57 ` M. A. Alves
2001-11-09  2:00   ` Jeffrey Carter
2001-11-09 18:31   ` Ted Dennison
2001-11-10 19:56     ` Ehud Lamm
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox