Consider the following examples. IF ch = 'U' THEN outputProc := WriteToUART I remember in the module Serial you used procedure types for writing to the UART0. The LPC2148 has two uarts and I adpted the code in a new module to use the other UART. Now I understand procedure types are a way to select the desired IO device. Do I recall correctly that you rewrote Serial to meet this flexibility?
Greets, F.P
-----Original Message----- From: Frans-Pieter Vonck [mailto:fp@vonck.nl] Sent: Wednesday, 20 February 2013 5:42 AM To: Felix Friedrich Cc: ETH Oberon and related systems Subject: Re: [Oberon] objects and jewels
An attempt to call a non-initialized procedure variable usually results in a trap. I'm curious, do you think this an code error that should be discovered by the compiler instead of generating a trap at runtime?
No. In most non-trivial cases it is not possible to determine, at the time a program is compiled, if a procedure variable will have a valid value at runtime whenever the procedure variable is called.
Consider the following examples. Apart from the first (which is both legal and very useful), all only have a *possibility* that the procedure variable is initialised, but it is not until runtime that you will know for sure.
---------------------------------
procVar := NIL;
---------------------------------
read(ch); IF ch = 'U' THEN outputProc := WriteToUART ELSIF ch = 'L' THEN outputProc := WriteToLCD END;
---------------------------------
SomeOtherModule.SomeProcedure(procVar);
---------------------------------
procVar := someOtherProcVar;
---------------------------------
TYPE ProcType = PROCEDURE(param1, param2: INTEGER); ProcArray = ARRAY 10 OF ProcType; VAR p1, p2: ProcArray; param1, param2: INTEGER; ... ... p1 := p2; p1[7](param1, param2);
---------------------------------
etc. etc.
Regards,
Chris Burrows CFB Software Astrobe v4.3 - Oberon for ARM Cortex-M3 Microcontrollers http://www.astrobe.com
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon