🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3775

Re: Pointers and whatnot

#3775
From: Chris Torek
Date: Tue, 25 Aug 1987 09:58
46 lines
2714 bytes
In article <520@ivax.doc.ic.ac.uk> dcw@doc.ic.ac.uk (Duncan C White) writes:
>in Modula-2, POINTER TO CHAR is precisely what it says: a pointer to
>a SINGLE character.  Not a pointer to an array of characters, or
>anthing else...
>
>C, on the other hand, makes no distinction between POINTER TO CHAR,
>ARRAY OF CHAR, and [to an extent] POINTER TO ARRAY OF CHAR..

This is not quite true.  The key difference between the Modula-2
conception of a pointer to a character and that of C is that C
implicitly states that that character lives somewhere within a
flat address space that may encompass multiple characters.  If
there are such additional characters, they may be found by using
pointer arithmetic on the given pointer.

These characters will exist if and only if the character to which
the pointer points is in fact one element of an array of characters,
or is contained within a region of characters allocated by the
runtime system.

>Maybe the confusion arises due to the fact that the ALLOCATE procedure,
>being nothing but a library procedure, will happily let you:
>
>	ALLOCATE( Ptr^.Text, 10 );
>
>[ Despite the fact that the size of Ptr^.Text is one byte... not 10 words ]

If ALLOCATE will allocate a contiguous group of words, Modula-2
also makes a similar implication, although in this case it is
weaker.  C's pointer types rule out sparse arrays, for example,
while Modula-2's probably do not.  Another thing to consider is
that C's arrays are (or are allowed to be) compile-time entities:
Once the code is generated, C no longer deals in arrays.  All arrays
do is carry sizes around during compilation.  If a language has
both conformant arrays and dynamic array allocation, that language
perforce has run-time arrays.  I am not familiar enough with Modula-2
to know whether this is the case.

[Finally, in his signature:]
> This space intentionally left blank......
> (paradoxical excerpt from IBM manuals)

(We once used `This page accidentally left blank'.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain:	chris@mimsy.umd.edu	Path:	seismo!mimsy!chris
Technical Details
Message-ID: <8141@mimsy.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!mimsy!chris
References: <8708220025.AA10833@cayuga.cs.rochester.edu> <748@vixie.UUCP> <520@ivax.doc.ic.ac.uk>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!mimsy!chris
From: chris@mimsy.UUCP (Chris Torek)
Newsgroups: comp.lang.modula2
Subject: Re: Pointers and whatnot
Message-ID: <8141@mimsy.UUCP>
Date: Tue, 25-Aug-87 05:58:51 EDT
Article-I.D.: mimsy.8141
Posted: Tue Aug 25 05:58:51 1987
Date-Received: Wed, 26-Aug-87 05:07:46 EDT
References: <8708220025.AA10833@cayuga.cs.rochester.edu> <748@vixie.UUCP> <520@ivax.doc.ic.ac.uk>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 46