[Oberon] Oberon-07, recursion and type extension

D. E. Evans sinuhe at xmission.com
Thu Jul 28 02:17:21 CEST 2016


I had thought CASE was limited in 2011 (2013?) only to type checks in extended records, but sure enough, it is still in the report.

> On Jul 27, 2016, at 4:04 PM, Darren Bane <dbane at SDF-EU.ORG> wrote:
> 
> Thanks, that's perfect. Once I understood the problem, it was no problem. It reminds me of another caveat, that "CASE" doesn't work for INTEGERs yet. I have no problem with either decision, Oberon-07 is still a very useful programming language, it just might be nice to have them highlighted more.
> 
> 
>> On Wed, 27 Jul 2016, Paul Reed wrote:
>> 
>> Date: Wed, 27 Jul 2016 22:26:51 +0100
>> From: Paul Reed <paulreed at paddedcell.com>
>> To: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
>> Subject: Re: [Oberon] Oberon-07, recursion and type extension
>> Hi Darren,
>> 
>>> I always get "incompatible parameters" errors at the recursive calls to
>>> [Write]()....
>>>   PROCEDURE Write(o: Parent);
>>>   BEGIN CASE o OF
>>>       Son: Write(o.wife) |
>>>       Daughter: Write(o.husband)
>>>     END
>>>   END Write;
>> 
>> You've come across a nasty implementation issue - if you use CASE to
>> temporarily change the type of a parameter, it will temporarily change the
>> definition of the procedure too; so the recursive calls are expecting Son
>> and Daughter in each branch respectively.  I think the old WITH suffered
>> from the same problem.
>> 
>> Just in the case of recursive calls, you might want to stick with the old
>> pattern
>> 
>>  IF o IS Son THEN
>>    Write(o(Son).wife)
>>  ELSIF o IS Daughter THEN
>>    Write(o(Daughter).husband)
>>  END
>> 
>> or alternatively, assign the pointer o to a local variable of type Parent
>> and then change that with a CASE.
>> 
>> HTH
>> Paul
>> 
>> 
>> --
>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
>> https://lists.inf.ethz.ch/mailman/listinfo/oberon
> 
> dbane at sdfeu.org
> SDF-EU Public Access UNIX System - http://sdfeu.org
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon



More information about the Oberon mailing list