Article View: net.lang.mod2
Article #353extensions, a modest question
From: Vincent Broman
Date: Fri, 21 Mar 1986 00:13
Date: Fri, 21 Mar 1986 00:13
31 lines
2069 bytes
2069 bytes
Twice (or more) I've bumped heads with a small shortcoming of M2 that may
eventually be best cured by a small extension of M2 syntax.
Both in writing an i/o buffering scheme and a command interpreter the problem
arose of accessing components of a big structure which needs to be viewed as
having two different types: "buft=ARRAY range1 OF WORD", say, and
"datat=ARRAY range2 OF somerecord". Unfortunately, type casts are syntactically
expressions and not "designators", and only designators may be called,
dereferenced, subscripted, or selected. So, "datat(buff)[sub].field" bums out.
The only methods I've found which don't copy the whole durned structure are:
TYPE dataptr = POINTER TO datat; VAR datap: dataptr
1. datap := dataptr(ADR(buff));
use(datap^[sub].field); (* not beautiful *)
2. deceiving the compiler with untagged variant records (which I am too
honest to do :-).
Has anyone a suggestion on how to type cast AND select components?
My preference would be to allow wild-and-wooly syntax like
ComponentValue ::=
Factor { "." Ident | "[" ExpList "]" | "^" | ActualParameters }.
ProcedureCall ::=
ComponentValue [ ActualParameters ].
Factor ::=
Set | Number | etc... | ComponentValue.
vincent broman, code 632, naval ocean systems center, san diego, ca 92152, usa
phone: +1 619 225 2365 starship: 32d 42m 22s n/ 117d 14m 13s w
arpa: broman@bugs.nosc.mil uucp: {sdcsvax,gould9,bonnie,hp-sdd}!noscvax!broman
Technical Details
Message-ID:
<8603210013.AA00587@bugs.ARPA>Path:
arc1-ca.pugleaf.net!utzoo!linus!decvax!ittatc!dcdwest!sdcsvax!ucbvax!nosc.arpa!broman%bugsShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ucbvax.BERKELEY.EDU Path: arc1-ca.pugleaf.net!utzoo!linus!decvax!ittatc!dcdwest!sdcsvax!ucbvax!nosc.arpa!broman%bugs From: broman%bugs@NOSC.ARPA (Vincent Broman) Newsgroups: net.lang.mod2 Subject: extensions, a modest question Message-ID: <8603210013.AA00587@bugs.ARPA> Date: Thu, 20-Mar-86 19:13:27 EST Article-I.D.: bugs.8603210013.AA00587 Posted: Thu Mar 20 19:13:27 1986 Date-Received: Sun, 30-Mar-86 07:59:14 EST Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 31