Path: news.cs.au.dk!not-for-mail From: "Kasper Østerbye" Newsgroups: comp.lang.beta Subject: Re: How to do non-inner specialisation?? Date: Wed, 23 Feb 2000 11:14:10 +0100 Organization: University of Aarhus, Department of Computer Science (DAIMI) Lines: 90 Message-ID: <890bti$cd7a3$1@xinwen.cs.au.dk> References: <88urqu$ccagn$1@xinwen.cs.au.dk> NNTP-Posting-Host: xmas.cs.au.dk X-Trace: xinwen.cs.au.dk 951300850 13016387 255.255.255.255 (23 Feb 2000 10:14:10 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 23 Feb 2000 10:14:10 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Xref: news.cs.au.dk comp.lang.beta:12249 Hi, I found a "better" solution (together with Jørgen Knudsen), which goes like this (# MostSpecificFirstVirtual: (# exitBlock: ^Object; leaveVirtual: (# do exitBlock #) do skipThis: (# do & (# do leave skipThis #)[]->exitBlock[]; INNER MostSpecificFirstVirtual #) #); A: (# print:< MostSpecificFirstVirtual (# do INNER ; 'I am an A'->putline; leaveVirtual #) #); B: A (# print::< (# do INNER ; 'I am an B'->putline; leaveVirtual #) #); C: B (# print::< (# do INNER ; 'I am an C'->putline; leaveVirtual #) #); someB: ^B do &C[]->someB[]; someB.print #) The solution requires the disipline of writing each virtual as "do inner; ......; leaveVirtual", and that the virtual declaration is a specialization of MostSpecificFirstVirtual, which encapsulates a continuation. -- Kasper Kasper Osterbye wrote in message news:88urqu$ccagn$1@xinwen.cs.au.dk... > Hi, > > Sometimes I need to do virtuals as it is done in all the other OO languages, > especially I find it useful in connection with "print" methods that convert > an object to text. Here it is not at all obvious that I need to text from > the > super class at all. > > The text below does the job, but I would have liked to capture it in a > more compact abstraction - this is more of an ideom than an abstraction. > > printMS is short for printMostSpecific > > (# > Once: > (# > done: @boolean; > act: (# do (if not done then INNER ; true->done if) #) > do INNER > #); > A: > (# > print: (# do 'I am an A'->putline #); > printMS:< Once (# do INNER ; act (# do print #) #) > #); > B: A > (# > print: (# do 'I am a B'->putline #); > printMS::< (# do INNER ; act (# do print #) #) > #); > C: B > (# > print: (# do 'I am a C'->putline #); > printMS::< (# do INNER ; act (# do print #) #) > #); > someB: ^B > do &C[]->someB[]; someB.print; '-----------'->putline; someB.printMS > #) > > -- Kasper > > >