[Oberon] Clarifying type compatibility in Oberon-07

Richard Hable informujo at aon.at
Sun Oct 8 13:45:26 CEST 2017


On 2017-10-08 09:09, August Karlstrom wrote:
> On 2017-10-08 07:26, Jörg wrote:
>> PROCEDURE myDot = DotType; (* totally new syntax *)
> This would be problematic if you want to use an existing procedure, like
> Math.sin in .e.g. Integral(Math.sin, 0.0, Math.pi).

The programming language should then support anonymous procedures,
created e.g. with the following syntax:

	ProcedureType (?(parameters) body)

If the integral procedure was defined like this:

	TYPE RealFunction = PROCEDURE (v: REAL): REAL;
	PROCEDURE Integral (f: RealFunction; x, y: REAL);
	BEGIN ...
	END Integral;

Then, an existing sinus procedure could be called within an anonymous
procedure passed to the integral procedure:

	Integral (RealFunction (?(x) RETURN Math.sin(x)), 0.0, Math.pi)

If we accept this wrapping overhead, it is not necessary to declare
named procedure types for all procedures ever written, but only for
those which are passed around as parameters or stored in variables.

I do not propose this extension to Oberon, but I use a similar solution
in my own programming language project to allow flexible functional
programming without giving up the security of name equivalence.

Richard


More information about the Oberon mailing list