Oberon in Python, ala Pyrex but instant compile?

Greg Ewing look at replyto.address.invalid
Mon May 27 00:53:23 EDT 2002


Janto Dreijer wrote:
> 
>   obj.SomeStringValue := GetA; (* bind handler *)
>
>   ...
>
>   Out.String(obj.SomeStringValue(obj));

You had to do things like that in early versions of
Oberon, but not in more recent versions. It's a
while since I looked at it, but if I remember
rightly, you do something like

PROCEDURE (obj: Obj) SomeStringValue: String;
...

which declares a real honest-to-goodness method
that you can call with

   obj.SomeStringValue()

i.e. no need to pass in the obj.

> TYPE String = ARRAY 1024 OF CHAR;
> PROCEDURE f() : String;
> BEGIN
>     RETURN "abc";
> END f;
> 
> This is one of the classic cases where the compiler crashes.

That sounds like a compiler bug, which you can
hardly blame on the language.

But I think the main reason for passing things
like strings back in VAR parameters is so they
can be declared as ARRAY OF CHAR and so avoid
coding in any fixed limit on the size.

I believe you can also have POINTER TO ARRAY
OF CHAR for heap-allocated variable-sized
strings.

-- 
Greg Ewing, Computer Science Dept, 
University of Canterbury,	  
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list