News for hackers. Stuff that matters.
Re:Dart language by SeoxyS on Monday October 10, 2011 @08:00PM (#3096434)
Not true, look at Objective-C for an example of how it's done. Broken up into two methods, the first of which is a static method which creates an uninitialized instance, and the second which is a plain method which initializes the instance and returns self (or rarely, nil):

    + alloc // reserves memory and creates an instance
    - init // initializes the instance
    - initWithSomething: // can have multiple inits
Re:Dart language by ajanuary on Tuesday October 11, 2011 @07:51AM (#3098186)
I go back and forth on whether I like this. On the one hand, the clean split makes it conceptually simple what's going on. On the other hand, you can have allocated, uninitialized code, which makes me uneasy.
Re:Dart language by SeoxyS on Tuesday October 11, 2011 @02:21PM (#3099708)
You always chain together `alloc` / `init` calls, and so you're hardwired never to have a situation where you don't initialize something you've allocated. I think the compiler even knows to warn you about it, now.