Post by Marco van de VoortFor the non initiated, annotated the methods with what kind it is. (virtual
etc, when it is overrriden).
The Objective-C runtime (which Objective Modula-2 plugs into) treats
all methods the same because all methods are added to a class at
runtime. There is no distinction between adding and overriding. There
is however a distinction between class and instance methods. In a
nutshell, class methods return instances of a class, they are used as
factory or initilisation methods.
Post by Marco van de VoortHow is self typed for overriden virtual methods
self is always of the type indicated in the method declaration, that
is, given
CLASS METHOD ( self : Foo ) init : Foo;
self is of type Foo.
Post by Marco van de VoortAnother thing is that the matrix PDF rambles on about "class modules", while
the text doesn't seem to define them. Are FooBar class modules? Can modules
have multiple classes? Questions that aren't answered.
The matrix represents the class-is-a-module approach which the class-
is-a-record approach discussed in the article is intended to replace.
Consequently, there are no more class nor category modules in the
class-is-a-record based syntax. That's the whole rationale of it
all ;-)
Post by Marco van de VoortI also miss examples how to handle forward class defines (Defining a
collection that knows its items and the other way around is the classic
example).
Yes, this isn't shown in the article, but will be in the revised
grammar and language overview document. As in Objective-C, a forward
declaration of a class will be an incomplete type declaration such as:
TYPE Foobar = CLASS;
Post by Marco van de VoortThe advantages of pulling the methods out of the container are not really
clear to me either. There is first a clutter argument, and then a "you can
add methods everywhere" argument. The first is subjective, the second, while
possibly a major feat is not explained.
No, clutter was a problem of the earlier attempt to use class-is-a-
record with methods inside the record declaration. Another problem of
the class-is-a-record with methods inside the record declaration is
that it doesn't work for categories because you would have to declare
the class multiple times.
The class-is-a-module approach solved both the clutter and the
category problem. However, it broke orthogonality. It requires eight
different modules each of which have different rules for what is
allowed in them and what isn't. Further, the same kind of directives
in different kinds of module have different semantics, var
declarations for instance. This is a potential source of programmer
confusion and thus prone to programming errors. It also makes syntax
and semantic analysis more complex than it ought to be.
The benefit of the class-is-a-record with type bound methods outside
the class record declaration is that orthogonality is reinstated while
clutter is avoided and the functionality that categories provide is
preserved.
When I say methods declarations to add methods to a class can be
anywhere, that is to say, there is no special syntax required for a
special container. You can use an ordinary library as a container for
your add-on methods. An example of this is shown in the article. The
important thing is that no special category record or category module
is required.
Post by Marco van de VoortHow does it work? How does the compiler know which modules the include so
that all methods are found (IOW is this real, or some "class helper" hack?)
Through import lists as usual.
Post by Marco van de VoortFinally we come to the "protocol". Apparantly the source fragment "Barbaz"
should fully explain it, but I honestly have no clue. I don't even know
where it comes from, is it something from later Wirthian languages, or a
COCOA concept, or both (Obj-C/COCOA concept matched to similar Wirthian
concept) ? Is it an interface or other kind of class contract?
A protocol is an instrument to implement multiple inheritance of
specification (not implementation). Both the instrument and the
terminology comes from Smalltalk from where Objective-C inherited it.
If you are familiar with Java, the same facility is called interface
there. If you are not, basically this is a collection of method
declarations that a class must implement if it adopts the protocol.
Post by Marco van de VoortThere might be more detail points to clear up, but since the text doesn't
really make me understand it, I can't come up with them before it is
improved :-)
The article does assume that you have read the language overview
document so you know the current syntax to compare the new syntax to.
I will update the article to recommend reading that first. Sorry for
the inconvenience.
Nevertheless, thanks for the feedback.