D/Objective-C 64bit

Christian Schneider via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Wed Nov 26 15:04:26 PST 2014


> Why not use a constructor and let the compiler manage the 
> boilerplate?
>
> 	this(NSRect frame) [initWithFrame:] {
> 		//my stuff
> 		super(frame);
> 	}
>
> This should emit the same code as the function above (but I 
> haven't tested). And then you can write:
>
> 	auto view = new KeyboardView(someFrame);
>
> and have proper type safety.

Thanks Michel, my question was based on a completely wrong 
assumption (really sorry, my bad), the code of course works, 
which is again really cool about the D/Objective-C bridging.

When I prepare the framework glue headers I usually add both 
variations init.. and this(), so the coder who uses it can take 
the shortcut if he prefers. I try to stay as close as possible to 
the naming conventions of the Cocoa framework, it facilitates 
somewhat the documentation lookup in Xcode. Named parameters is 
probably the feature I like most about Objective-C, it makes the 
code so much more readable and auto-documents, if one is careful.


More information about the Digitalmars-d-announce mailing list