Clarifying type compatibility in Oberon-07
On Sun Oct 8 02:26:53 CEST 2017 Chris Burrows wrote:
If the programmer has chosen to use anonymous arrays it might well be reasonable to assume he is not concerned about name equivalence so why should he be inconvenienced but prohibiting assignments? Surely not just because it conflicts with somebody else's personal taste?
It all boils to the question of whether we view the text “ARRAY 10 OF INTEGER” in an anonymous array declaration as a) a name in its own right b) a name with a parameter 10 c) not a name (anonymous entity) Different programmers will have different points of views on this. -AP
EDIT: "boils down" to instead of “boils" ADDITION: There probably is no one “right” answer that suits everyone’s needs (or tastes..), otherwise it would surely have been found in the past 50+ years.. it hasn’t.
On 08 Oct 2017, at 07:12, Andreas Pirklbauer <andreas_pirklbauer@yahoo.com> wrote:
On Sun Oct 8 02:26:53 CEST 2017 Chris Burrows wrote:
If the programmer has chosen to use anonymous arrays it might well be reasonable to assume he is not concerned about name equivalence so why should he be inconvenienced but prohibiting assignments? Surely not just because it conflicts with somebody else's personal taste?
It all boils to the question of whether we view the text “ARRAY 10 OF INTEGER” in an anonymous array declaration as
a) a name in its own right b) a name with a parameter 10 c) not a name (anonymous entity)
Different programmers will have different points of views on this.
-AP
Unnamed entities (or is it structural equivalence?) can create troubles. See yourself TYPE DotType = PROCEDURE (col, x, y: INTEGER); VAR dot: DotType; PROCEDURE myDot(x, y, col:: INTEGER); BEGIN END myDot; dot := myDot; (* allowed in Oberon, structurally equivalent, but the formal parameters are totally scrambled *) Here you see, how the unnamed formal parameters (or the structural equivalence) can generate a complete mess! The compiler should not only check the types of the formal parameters but their names as well. Or: to be extremely consequent(!!) A PROCEDURE (especially those to be used as variables) should get a named TYPE. Something like PROCEDURE myDot = DotType; (* totally new syntax *) But this is too far off-topic. Jörg
Am 08.10.2017 um 07:12 schrieb Andreas Pirklbauer <andreas_pirklbauer@yahoo.com>:
On Sun Oct 8 02:26:53 CEST 2017 Chris Burrows wrote:
If the programmer has chosen to use anonymous arrays it might well be reasonable to assume he is not concerned about name equivalence so why should he be inconvenienced but prohibiting assignments? Surely not just because it conflicts with somebody else's personal taste?
It all boils to the question of whether we view the text “ARRAY 10 OF INTEGER” in an anonymous array declaration as
a) a name in its own right b) a name with a parameter 10 c) not a name (anonymous entity)
Different programmers will have different points of views on this.
-AP
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 2017-10-08 07:26, Jörg wrote:
Or: to be extremely consequent(!!) A PROCEDURE (especially those to be used as variables) should get a named TYPE. Something like
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).
-- August
Hi
Am 08.10.2017 um 09:09 schrieb August Karlstrom <fusionfile@gmail.com>:
On 2017-10-08 07:26, Jörg wrote:
Or: to be extremely consequent(!!) A PROCEDURE (especially those to be used as variables) should get a named TYPE. Something like 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).
I’m absolutely aware of this. This is the discussion named vs unnamed types. Two approaches: - Allow structural comparison (as it is today anyhow) but include the parameter names as well. Not only types have a semantic meaning but names bear semantic info as well. - If this new procedure type thingy is introduced, Math obviously exports a new procedure type „RealFunc“ br Jörg
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
No. If we allow anonymous procedures, you don't have to declare parameters again. They are stated in RealFunction already. It should be enough to write Integral ( RealFunction(RETURN Math.sin(v)), 0.0, Math.pi)); Jörg
Am 08.10.2017 um 13:45 schrieb Richard Hable <informujo@aon.at>:
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 -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 2017-10-08 13:55, Jörg wrote:
No. If we allow anonymous procedures, you don't have to declare parameters again. They are stated in RealFunction already. It should be enough to write Integral ( RealFunction(RETURN Math.sin(v)), 0.0, Math.pi));
This is a matter of taste. In my opinion, omitting formal parameter names in anonymous functions makes source code difficult to read. Richard
Richard If you use the type „Texts.Frame" you have to know that you can use „hasCar", „lsp" or „selbeg“. You don’t repeat all RECORD fields. If you use the type „RealFunction“, you have to know that „v“ is part of it. Why shall it be different? Jörg
Am 08.10.2017 um 14:10 schrieb Richard Hable <informujo@aon.at>:
On 2017-10-08 13:55, Jörg wrote:
No. If we allow anonymous procedures, you don't have to declare parameters again. They are stated in RealFunction already. It should be enough to write Integral ( RealFunction(RETURN Math.sin(v)), 0.0, Math.pi));
This is a matter of taste. In my opinion, omitting formal parameter names in anonymous functions makes source code difficult to read.
Richard -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 2017-10-08 14:24, Jörg wrote:
If you use the type „Texts.Frame" you have to know that you can use „hasCar", „lsp" or „selbeg“. You don’t repeat all RECORD fields.
Record fields are only used in combination with their record variable. Thus, “myFrame.selbeg” clearly indicates that “selbeg” refers to a field of “myFrame”.
If you use the type „RealFunction“, you have to know that „v“ is part of it. Why shall it be different?
In the expression “RealFunction(RETURN Math.sin(v))” the variable “v” could be anything: a variable defined within the calling function, some global variable with this name, or actually the name of a formal parameter of “RealFunction”. You have to examine the exact definition of “RealFunction” including its formal parameter names, to find out. Richard
participants (4)
-
Andreas Pirklbauer -
August Karlstrom -
Jörg -
Richard Hable