Hacker News new | past | comments | ask | show | jobs | submit login

Interfaces which use the pattern:

  struct foo bar;
  foo_init(&bar);
Can be very annoying in swift, it does play nicely with CoreFoundation which does not use this pattern



As of Swift 1.something, C structs get imported with an empty initializer that sets everything to zero. So that pattern can be written in Swift as:

    var bar = foo()
    foo_init(&bar)
No worse than the C version, as long as the unnecessary initialization is not a performance problem (which it usually isn't).




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: