Niklaus Wirth: The Human 
Author Message
 Niklaus Wirth: The Human


Quote:
> >EDU () writes:

writes
> >:
> >>I don't know what his preference would be, but I can specify the form of
> >>his preference rule:
> >>   case SoftDrink of
> >>     Pepsi: ;
> >>     Coke: ;
> >>     7Up: ;
> >     MountainDew:
> >else
> >     water:
> >end;

> Ummm. Shouldn't that be:

> CASE SoftDrink OF
>   aPepsi: ;
> | aCoke: ;
> | a7Up: ; (* I don't think # are valid as 1st char of identifier *)
> | aMountainDew: ;
> | water: ; (* `CASE ... ELSE water: END' has label without matching case *)
> END;

> ?

> -jonathan

Nearly. Acording to my specs of Modula-2 this should be:

CASE SoftDrink OF
  aPepsi: |
  aCoke: |
  a7Up: |
  aMountainDew:
ELSE
  water:
END;

(* some compilers want OTHERWISE instead of ELSE *)

--
Robert Frank                         tel. + (061) 321 99 67                
Institut fuer Informatik             fax  + (061) 321 99 15                
University of Basel, Switzerland                                            

CH-4056 Basel          X400: S=frank;OU=ifi;O=unibas;P=switch;A=arcom;C=ch



Sat, 09 Sep 1995 19:26:03 GMT  
 Niklaus Wirth: The Human

Quote:

>> CASE SoftDrink OF
>>   aPepsi: ;
>> | aCoke: ;
>> | a7Up: ; (* I don't think # are valid as 1st char of identifier *)
>> | aMountainDew: ;
>> | water: ; (* `CASE ... ELSE water: END' has label without matching case *)
>> END;

>Nearly. Acording to my specs of Modula-2 this should be:

>CASE SoftDrink OF
>  aPepsi: |
>  aCoke: |
>  a7Up: |
>  aMountainDew:
>ELSE
>  water:
>END;

>(* some compilers want OTHERWISE instead of ELSE *)

The position of the '|' character is irrelevant so long as it is
before the next identifier and after the last statement in the
previous block.  Modula2 is fairly free format in that respect.
Still, I could not get the ... ELSE water: ... portion of the
structure to compile.  If memory serves correctly, the ELSE
statement is a catch all for a condition that does not match any of
the identifiers in the CASE statement.  Therefore, it cannot contain
further identifiers (without another invocation of the CASE
statement).  Just substituting 'water;' for 'water:' would compile
if 'water' were a defined procedure.  Or perhaps...

TYPE drinks=(aPepsi, aCoke, a7Up, aMountainDew, water);
VAR SoftDrink, Glass: drinks;     (* Just for completeness :*)
[...]
CASE SoftDrink OF
  aPepsi:
| aCoke:
| a7Up:
| aMountainDew:
ELSE
 CASE
   Glass OF water:
 END;
END;

Will.

---------------------------------------- William Burrow


Fidonet:  1:255/14.1                        | someone else...



Sun, 10 Sep 1995 07:55:45 GMT  
 Niklaus Wirth: The Human
FROM HimSelf IMPORT HisChoice;

 TYPE drinks=(aPepsi, aCoke, a7Up, aMountainDew, water);
      drinkSET = SET OF drinks;
 VAR DrinkTray, Wirth: drinkSET;

 DrinkTray:=drinkSET{aPepsi, aCoke, a7Up, aMountainDew, water};

 Wirth:=DrinkTray * HisChoice();

Error: client takes exception, client module requires runtime type
       extensibility, enumeration not well received.

  TC.



Mon, 11 Sep 1995 01:50:07 GMT  
 Niklaus Wirth: The Human

       writes:

Quote:
>> >>I don't know what his preference would be, but I can specify the form of
>> >>his preference rule:
>> >>   case SoftDrink of
>> >>     Pepsi: ;
>> >>     Coke: ;
>> >>     7Up: ;
>> >     MountainDew:
>> >else
>> >     water:
>> >end;

>> Ummm. Shouldn't that be:

>> CASE SoftDrink OF
>>   aPepsi: ;
>> | aCoke: ;
>> | a7Up: ; (* I don't think # are valid as 1st char of identifier *)
>> | aMountainDew: ;
>> | water: ; (* `CASE ... ELSE water: END' has label without matching case *)
>> END;

>> ?

>> -jonathan

>Nearly. Acording to my specs of Modula-2 this should be:

>CASE SoftDrink OF
>  aPepsi: |
>  aCoke: |
>  a7Up: |
>  aMountainDew:
>ELSE
>  water:
>END;

>(* some compilers want OTHERWISE instead of ELSE *)

All right. Last time. This is your brain. This is your brain on Pascal:

CASE Softdrink OF
     Pepsi: <statementsequence>;
    |Coke: <statementsequence>;
    |SevenUP: <statementsequence>;
    |MountainDew: <statementsequence>
OTHERWISE (*or ELSE*)
     water: <statementsequence>
END Softdrink; (*or END; depending on your local version*)
--
*******************************************************************************
 Hi.    COLOR                 RAINBOW                   FRACTAL           Hi.
                          Bryan D Levenson  d:)
*******************************************************************************



Mon, 11 Sep 1995 23:11:48 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Niklaus Wirth: The Human

2. New Book: The School of Niklaus Wirth

3. Interview with Niklaus Wirth

4. 'Compiler Construction' by Niklaus Wirth

5. Who are the 2 Niklaus Wirth's

6. Niklaus Wirth's EULER

7. New Book: The School of Niklaus Wirth

8. Niklaus Wirth

9. Niklaus Wirth

10. Niklaus Wirth's compiler book (was Re: Compiler.)

11. Availability of "Project Oberon" by Niklaus Wirth

12. New ModulaTor issue: A news:digital contrarian retires (Prof. Niklaus Wirth)

 

 
Powered by phpBB® Forum Software