I'm an ordinary Cocoa developer with no knowledge of Pascal/
Modula-2. I've just looked at the Wikipedia page and it's quite
interesting for me, but there's still a lot of information missing.
Indeed, the wiki page is just an overview and represents that which
we have a pretty good consensus on. Yet, it is work in progress, so
details may still change and there are still many other issues to be
sorted out.
For example, we intend to map nil, Nil and M2's own NIL all to a
single NIL, BOOL to M2's BOOLEAN, YES to TRUE and NO to FALSE, which
all looks like a non-issue but there are some details to work out.
Another example are exceptions, where one might think it would be as
easy as calling @try TRY, @catch CATCH and @finally FINALLY. Yet the
ISO M2 standard defines M2 exceptions which are quite different.
There is no explicit try block. Instead, the module's main block
(BEGIN ... END) is one try block and its termination block (a clean-
up sequence executed on termination) is another. We felt that we
shouldn't try to consolidate the two and decided to keep them apart
at least for now. This means we have to use non overlapping syntax,
so FINALLY is off-limits.
Visibility of instance variables is another matter where the devil is
in the detail. Modula-2 is based on the concept of data encapsulation
and information hiding, much more so than other languages. Therefore,
providing direct access to instance variables to world + dog is not a
very M2 like thing to do. True M2 style would be to only distinguish
between private and visibility to the immediate neighbourhood, that
is within the module enclosing the class module. To make those
variables visible beyond the enclosing module, that module would need
to explicitly export their identifiers and other classes would have
to explicitly import them. In fact, in ISO M2's OO extensions, even
methods have to be exported to be visible outside the enclosing module.
There is also the problem with @protected. Not only is it not
descriptive, but from a M2 point of view this is a misnomer because
it makes instance variables unprotected. In fact, in a pure M2
implementation the access mode ObjC calls protected would probably
not be there in the first place.
However, in order to fit in well with the Cocoa/GNUstep environments,
we have to find a solution that is both in line with M2 concepts and
compatible with Cocoa/GNUstep and ObjC. This has turned out to be a
challenge and the visibility of instance variables has been very
prominent in our discussion group. So far our solution, which is
still not finalised, looks like this ...
- all methods are public, but classes need to be imported to become
available
- by default all instance variables are private
- variables declared after PUBLIC makes them public
- variables declared after PUBLIC TO SUBCLASSES makes them protected
- variables declared after PUBLIC TO NEIGHBORS makes them visible
only within the enclosing module and classes also defined within that
enclosing module
- a keyword PRIVATE is also available to allow switching back to default
What we don't like about this is the fact that it is not an
internationally acceptable solution because of the US American
spelling of NEIGHBORS.
Many C programmers may say, "ouch, this is a lot of stuff to type"
and we'd reply to them that we are quite happy with the idea that
dangerous programming techniques should take a little longer to type
so that programmers get a little more time to think about whether
they should really use this technique or perhaps consider the use of
a safer technique that requires less effort. In this respect, the
keyword PUBLIC may need some ballast added to it, like PUBLIC TO ALL,
etc.
Now, since this is an ObjC list, it should be mentioned that PUBLIC
TO NEIGHBORS would be mapped to @private when using an ObjM2 class
from ObjC. Ideally though, ObjC would gain class library modules and
@neighbors at some point in the future.
So, as you can see, all those issues look rather trivial at first
sight, but they are not, at least not if you want to do consolidate
both of the environments in a fashion that is just to both. Creating
a good hybrid language isn't all that easy.
I have just one remark about the proposed syntax:
Thanks for the feedback.
Category syntax is a bit odd from my point of view. Their name
doesn't always appear together with the respective class name (in
ObjC: Class(Category)). This fact and the EXTENDS keyword makes me
think of inheritace (that's also what it means in Java - another
Cocoa/GNUstep language) rather than categories. Also as noted on
the Wikipedia page categories don't necessarily "extend" the class,
they can just replace some methods.
First, the term category itself would have been a preferred candidate
for a keyword to tell the compiler that the module is what ObjC calls
a category, ie ...
INTERFACE MODULE MyCategory CATEGORY OF SomeClass;
... and we may yet use this syntax instead of EXTENDS.
However, category is yet another misnomer. In English the word
category has a dividing nature. It is used to describe "division" of
a bigger entity into smaller sub-entities. That's a bad choice of a
word for something that means both "addition" and "modification".
This creates a conflict for us. On the one hand, existing terminology
should be retained, on the other hand Modula-2 is all about clarity,
all about avoiding ambiguity. Keywords and standard identifiers
should speak for themselves. We write "POINTER TO Foobar" instead of
the much shorter ^Foobar in Pascal. Before this background you can
probably see that CATEGORY doesn't ring a bell with Modula-2 folks.
Yet, you are right, EXTENDS isn't necessarily the best choice because
it has a different meaning in Java which may well be confusing for
those familiar with Java.
However, when it comes to expressing "addition" versus
"modification", there will likely have to be a choice in favour of
one over the other.
What about using this more ObjC-like syntax:
INTERFACE MODULE ClassY(CategoryX);
(* ... *)
END ClassY(CategoryX).
A possibility but not very M2 like.
But thanks again for the feedback, we'll certainly revisit the syntax
of categories once more.
rgds
ObjM2 project
___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/objc-language/email@hidden