Is there anyone who would like Objective-J to perform static type checking?

10 views
Skip to first unread message

JC

unread,
Jan 17, 2010, 5:46:02 AM1/17/10
to Cappuccino & Objective-J
I personally like to catch as many errors up front (at compile time)
as possible. Do others feel this way?
How hard might this be to implement?
It seems like it wouldn't be that hard. We would just need to clearly
define what the subtyping rules are in Objc/Objj and make sure that
every variable assignment adheres to the rules, right?

Right now, it's as if every type in Objj is of type (id).
id is a subtype of everything and everything is a subtype of id.
Making objective-j statically typed would just be a matter of
including other rules for "non id" type variables.


Tom Robinson

unread,
Jan 17, 2010, 7:01:15 AM1/17/10
to objec...@googlegroups.com
Yes, I (and I think most of the core team) would like to see optional
(and it *must* be optional) static typing in Objective-J at some point.

The current compiler does not do a full parse of the source, which
would be the first step. We've been wanting a new compiler for awhile
now, mostly for better syntax error reporting, and more advanced tools.


BTW, you know there's a dynamic type checker built into Objective-J?
Each time objj_msgSend is invoked it tries to check to make sure the
types are correct.

-tom

> --
> You received this message because you are subscribed to the Google
> Groups "Cappuccino & Objective-J" group.
> To post to this group, send email to objec...@googlegroups.com.
> To unsubscribe from this group, send email to objectivej+...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/objectivej?hl=en
> .
>
>

JC

unread,
Jan 17, 2010, 4:34:17 PM1/17/10
to Cappuccino & Objective-J
Very cool Tom (about the dynamic type checker!)
Now all that's left is to define what constitutes a subtype, and make
that step happen in the compile time step.
But IIRC if you have two methods:
-(void) myMethod:(int) x;
and
-(void) myMethod:(String) y;

and you call myMethod with an int, objj can't figure out which one to
call. Has this changed?

Ross Boucher

unread,
Jan 17, 2010, 5:04:28 PM1/17/10
to objec...@googlegroups.com
That is by design, and won't change. Objective-C has the same limitation.
Reply all
Reply to author
Forward
0 new messages