begin  quoting James G. Sack (jim) as of Sun, Oct 01, 2006 at 02:35:19PM -0700:
> Stewart Stremler wrote:
[snip]
> > First attempt is at:
> > 
> > http://www.stremler.net/temp/CBufObjC.tar
> >..
> 
> Neat. And thanks for including the typescript.

You're welcome. :)

> The syntax is mostly transparent. But can you humor me a couple of
> questions?
 
Ask away. That's why we're in LSPG....

> (I guess the 'id' is confusing me)
 
The "id" is a pointer-to-some-object -- in Java, one would use "Object"
as the type. Objective-C is single-inheritiance, but there is no
required root object, so you can have multiple inheritance trees.

> Q1. how does the constructor know what the 'id' type is?
 
I don't understand the question.

Objective C doesn't really have constructors. It just has class methods
(indicated with +) and instance methods (indicated with a -).

For single-threaded code, singletons are *easy* in Objective C.

> Q2. does the put do any type checking?

If not specified, the default type for return values and arguments is
"id" (i.e., some ObjC object).  If I would have declared a non-id type
in the prototype and implementation, the compiler would enforce the
type-checking; I could also add code to the -put: method to enforce
runtime type-checking, but my ObjC-fu isn't that strong yet.

(In other words, I think I know how to do it, but I haven't actually
done such a thing yet.)

-- 
_ |\_
 \|

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to