[Oberon] Oberon for a C++ user.

Diego Sardina dsar at eml.cc
Tue Nov 15 07:40:07 CET 2016


 > Here's the code you are describing, and it has no extra keywords:

I don't understand your reply and I find it somewhat
provocative, like you are talking with a new comer.
I hope it's not.

Why did you reply me to not use TBPs? And what if
I really want to use them?

Classical procedures, with or without Method Suite,
are more convenient when you have one object (or
record) per module.
With this style having more is really troublesome.
It is easy to name clash when you have common
names like Write() or Print(). You have to append or
prepend the type name, like WriteClient() or PrintList(),
and one is often redundant with the module's name.
The situation is worse when you have to implement
the methods of extensions in the same module. So
the default code style is to append the type name to
all procedures.
The solution is to put the extended record and/or
other related records in separate modules, it seems
more natural with this style.

Type-bound procedures on the contrary are more
convenient when you have more objects/records
per module.
The problem of name clash simply doesn't exist,
every TBP is related to its record.
Also they visually help to group all related procedures
to its record. With Method Suite you have to look at
procedure's name or module's name, looking at the
receiver is often not helpful because it's contravariant
in plain Oberon.

Anyway, I've no problem with both styles, but
I don't like to mix the two. If I'm using Oberon-2
or Component Pascal I prefer to see the module
as a container of (cooperative) classes.
Especially when CP treats TBPs of final records
that extend no record like ordinary procedures.


--
Diego Sardina


More information about the Oberon mailing list