🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2361

Re: Pointers

#2361
From: John Haxby
Date: Wed, 11 Nov 1992 15:51
48 lines
2982 bytes
In article <BxIoDv.72J@mentor.cc.purdue.edu>, hrubin@pop.stat.purdue.edu (Herman Rubin) writes:
	...

|> >ALGOL 68 and SIMULA 67 have user-defined types, dynamic memory, and
|> >free-form syntax, no?  And why do you need explicit pointers to functions
|> >when you can have procedure types, like Modula-2?
|> 
|> You need explicit pointers to functions when the caller does not know
|> the name of the function being called, but the caller has received a
|> pointer to the function.  The same holds for pointers to arrays of
|> pointers, and to array descriptors.  If several parts of a program
|> are using the same double buffer, and are even compiled separately,
|> using a pointer to the active buffer, and another one to the refill
|> buffer, would be an excellent way to do things.

No you don't.  In Algol 68, procedures are types like anything else
so you can pass a ref proc to a procedure and let the normal coercian
de-reference and de-procedure (ie call) as necessary.  The typing
system requires that only procedures with the right mode (signature) can
be passed as parameters in this way so that the mode of the procedure
is known at compile time.

In CLU, you can pass paramaters of type PROCTYPE to accomplish exactly
the same thing, or you can use type parameterization (genericism if you like)
for a similar mechanism for, often, much the same purpose.  CLU doesn't
have references, yet alone pointers.

In Modula 3, the type system allows you to pass things as REFANY to
allow the anonyimty you crave in C, but in a type-safe fashion.  Indeed,
the Modula 3 mechanism provides rather more than the C mechanism because
you can tell what you are doing so you don't need to worry about the
more bizarre syntactic mechanisms :-)

As someone said in response (I think) to something I said, everything begins
to look like a nail when you only have a pointer to a hammer. In other languages,
older and newer, you have a choice of tools and you can choose the right one
for the job.  [I have four planes and a bastard file: you can do anything with
a bastard file and enough patience and wood; but the right plane will do the job
in a fraction of the time and it will do it right first time].


-- 
John Haxby, Definitively Wrong.
Digital				<jch@rdg.dec.com>
Reading, England		<...!uknet!wessex!jch>

----------------------------------------------------------------
The opinions expressed herein are my own, not my employers.
Technical Details
Message-ID: <1992Nov11.155149.14744@rdg.dec.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!pa.dec.com!rdg.dec.com!jch
References: <1992Nov7.115620.29967@syacus.acus.oz.au> <1992Nov10.024021.8724@linus.mitre.org> <92Nov10.125426est.47525@neat.cs.toronto.edu> <BxIoDv.72J@mentor.cc.purdue.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!pa.dec.com!rdg.dec.com!jch
From: jch@rdg.dec.com (John Haxby)
Subject: Re: Pointers
Message-ID: <1992Nov11.155149.14744@rdg.dec.com>
Sender: news@rdg.dec.com (Mr News)
Organization: Digital Equipment Corporation
References: <1992Nov7.115620.29967@syacus.acus.oz.au> <1992Nov10.024021.8724@linus.mitre.org> <92Nov10.125426est.47525@neat.cs.toronto.edu> <BxIoDv.72J@mentor.cc.purdue.edu>
Date: Wed, 11 Nov 1992 15:51:49 GMT
Lines: 48