[OT] Re: programming in C++ ?
[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