🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.oberon
Article #1279

Re: The Trouble with WITH...

#1279
From: Brian Hawley
Date: Fri, 05 Apr 1996 04:58
38 lines
1810 bytes
In article <4k11r7$k6b@newsbf02.news.aol.com>, mhamburg@aol.com (M Hamburg) wrote:
>Stefan H-M Ludwig writes:
>
>"I strongly advocate dropping WITH on pointers in commercial compilers."
>
>The canonical form for a frame handler in the Oberon system begins with a
>WITH on a pointer. (For example, see Reiser 19.4.1, p. 270.) One could
>redesign the system so that it either used type-bound procedures or passed
>the frame as a VAR parameter, but the former means that we lose the
>ability to change behavior just by using a different handler proc and the
>latter means that we don't have the pointer to the frame if we needed it
>for something like change notification.
>
>Mark

That particular problem is easy to solve:

TYPE
  Object = POINTER TO ObjectDesc;
  ObjectMsg = RECORD END;
  ObjectDesc = RECORD Handle*: PROCEDURE(o: Object; VAR msg: ObjectMsg) END;
  Frame = POINTER TO FrameDesc;
  FrameDesc = RECORD (ObjectDesc) x,y,w,h: INTEGER END;

PROCEDURE *Handle(o: Object; VAR msg: ObjectMsg);
VAR f: Frame;
BEGIN
  f := o(Frame);
  ... (* operations on f instead of o *)
END Handle;

You just manually implement my earlier solution (no reason for the syntactic 
sugar I guess). I agree with Stephen on this: WITH on pointers should be 
dumped. The alternative used above is much more typesafe and is no more 
difficult.

Brian Hawley
bhawley@luc.edu
Technical Details
Message-ID: <4k299u$dgm@artemis.it.luc.edu>
Path: arc1-ca.pugleaf.net!news.luc.edu!bhawley
References: <4jvvs3$93h@lillian.inf.ethz.ch> <4k11r7$k6b@newsbf02.news.aol.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.luc.edu!bhawley
From: bhawley@luc.edu (Brian Hawley)
Newsgroups: comp.lang.oberon
Subject: Re: The Trouble with WITH...
Date: Fri, 05 Apr 96 04:58:37 GMT
Organization: Loyola University Chicago
Message-ID: <4k299u$dgm@artemis.it.luc.edu>
References: <4jvvs3$93h@lillian.inf.ethz.ch> <4k11r7$k6b@newsbf02.news.aol.com>
NNTP-Posting-Host: 147.126.1.125
X-Newsreader: News Xpress 2.0 Beta #0