• 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
[OT] Re: programming in C++ ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[OT] Re: programming in C++ ?


  • Subject: [OT] Re: programming in C++ ?
  • From: Alastair Houghton <email@hidden>
  • Date: Sun, 3 Feb 2008 18:16:54 +0000

On 3 Feb 2008, at 16:44, Thomas Engelmeier wrote:

On 01.02.2008, at 18:35, John Stiles wrote:

Well, most C++ code should be using new and not malloc() anyway. malloc() is a holdover from the Bad Untyped Days of C.

That particular API has some semantics that proliverate bad programming practice, anyway - structs with trailing variable length data buffers. A lot of C casts, offsetof and whatever.

Structs with variable length data buffers are not "bad programming practice".


You may not *like* them, but that's different from them being inherently bad, even if it's a sentiment shared by many others. In some circumstances they are the best way to solve a problem. This is primarily the case where the overhead from keeping the variable length data separate would be too high; a straightforward example is with strings, which are *often* represented with a struct with variable- length trailing data. (Indeed, I think NS/CFString does exactly this in some cases.)

Put another way, eschewing malloc() or variable length structs in all situations is not pragmatic---it's dogmatic, and that's never a good way to make a decision.

Kind regards,

Alastair.

--
http://alastairs-place.net



_______________________________________________

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: 
 >Re: programming in C++ ? (From: Thomas Engelmeier <email@hidden>)
 >Re: programming in C++ ? (From: John Stiles <email@hidden>)
 >Re: programming in C++ ? (From: Thomas Engelmeier <email@hidden>)

  • Prev by Date: Re: NSCollectionView's newItemForRepresentedObject Method
  • Next by Date: Re: [Moderator] Re: MacBook Air multitouch trackpad API
  • Previous by thread: Re: programming in C++ ?
  • Next by thread: Plugin locks widget under Tiger
  • Index(es):
    • Date
    • Thread