• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: forward decls vs #import
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: forward decls vs #import


  • Subject: Re: forward decls vs #import
  • From: Lee Ann Rucker <email@hidden>
  • Date: Thu, 14 Mar 2013 18:42:58 -0700

On Mar 14, 2013, at 4:51 PM, Luther Baker wrote:

> Given today's computing power, is there a strong case that can be made for
> or against the general use of forward declarations?
>
> I grew up using them as a best practice in C++ projects ... but more
> recently, several seniors Obj-C devs have suggested that they prefer
> #import in the .h files.
>
> Initially, I thought this might be related to the prevalence of Java or C#
> (which don't deal with such things) ... but the suggestion today was that
> forward decls was actually unnecessary typing, not considered a best
> practice ... and that, indeed, #importing in the .h file could potentially
> actually help weed out bad code.
>
> Am I just from another era?

@class Foo;

has never caused any problems that I know of, but

@protocol Foo;

can result in the compiler thinking that Foo is an empty protocol if you don't import the .h that has the actual protocol.

And no matter how fast compilers get, projects get big enough that builds are slow. (But then I'm always measuring compile time against Smalltalk...)
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >forward decls vs #import (From: Luther Baker <email@hidden>)

  • Prev by Date: Re: forward decls vs #import
  • Next by Date: Re: Setting the position of new windows
  • Previous by thread: Re: forward decls vs #import
  • Next by thread: Re: forward decls vs #import
  • Index(es):
    • Date
    • Thread