Kim, DoHyung
2004-06-24 19:01:12 UTC
Hello,
I'm relatively new to Oberon-2 and Component Pascal. While I'm playing
with them, I found that the following is possible with them while it
shouldn't.
Below, I declared a record on stack and passed its pointer to a global
variable. And then called a method on the stored pointer after the
stack frame where the record is allocated disappears.
Is this a well known feature of Oberon-2 and Component Pascal?
I think this kind of thing should not be possible if they are aiming a
robust, type-safe language.
Thanks in advance.
DoHyung
@ I'm investigating on them to see whether they are appropriate for
the development of my company's product. Though I'm sure they are far
better than C and complex C++ thing, just hope to check whether
there's any pitfall.
MODULE test;
IMPORT CPmain;
TYPE
R0 = RECORD i: INTEGER END; P0 = POINTER TO R0;
VAR
global: P0;
PROCEDURE (p: P0) Proc1, NEW;
BEGIN
global := p
END Proc1;
PROCEDURE (VAR r: R0) Proc2, NEW;
BEGIN
END Proc2;
PROCEDURE call;
VAR
r: R0;
BEGIN
r.Proc1;
global.Proc2;
END call;
BEGIN
call
END test.
I'm relatively new to Oberon-2 and Component Pascal. While I'm playing
with them, I found that the following is possible with them while it
shouldn't.
Below, I declared a record on stack and passed its pointer to a global
variable. And then called a method on the stored pointer after the
stack frame where the record is allocated disappears.
Is this a well known feature of Oberon-2 and Component Pascal?
I think this kind of thing should not be possible if they are aiming a
robust, type-safe language.
Thanks in advance.
DoHyung
@ I'm investigating on them to see whether they are appropriate for
the development of my company's product. Though I'm sure they are far
better than C and complex C++ thing, just hope to check whether
there's any pitfall.
MODULE test;
IMPORT CPmain;
TYPE
R0 = RECORD i: INTEGER END; P0 = POINTER TO R0;
VAR
global: P0;
PROCEDURE (p: P0) Proc1, NEW;
BEGIN
global := p
END Proc1;
PROCEDURE (VAR r: R0) Proc2, NEW;
BEGIN
END Proc2;
PROCEDURE call;
VAR
r: R0;
BEGIN
r.Proc1;
global.Proc2;
END call;
BEGIN
call
END test.