• 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: To C++ users trying to use Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: To C++ users trying to use Cocoa


  • Subject: Re: To C++ users trying to use Cocoa
  • From: Erik Buck <email@hidden>
  • Date: Sat, 12 May 2007 20:01:49 -0400

Another related epiphany for me was that COM, DCOM, IUnknown, IDL, SOM, Signals and Slots, Event dispatch tables, and the "Command" design pattern are all partial attempts to replicate the built in dynamic message dispatch capability of Objective-C. Having one uniform fast dynamic message dispatch that is ubiquitous makes all of those other approaches mostly unnecessary and frankly reveals how impoverished they really are.

In recent years, there has also been a modest rebellion against "bondage and discipline" programming languages. <http:// www.answers.com/topic/bondage-and-discipline-language-computer-jargon>

Whatever else is said about Objective-C, it is a very small and very flexible language that is compatible with all of the ANSI/ISO C code ever written and most of the C++ code ever written. I have found that it takes less time to teach a C programmer the entire Objective- C language than it takes to teach a C programmer how to correctly declare an iterator for a std:set of std::map pointers including obligatory definition of overloaded assignment and comparison operators, an default constructor, and a copy constructor and what all those things are. e.g.

// Map column name to value within a row
typedef std::map<std::string, std::string>  ValueForColumnNameType;

// Provide copy constructor and assignment operator wrapper for ValueForColumnNameType
struct ValueForColumnNameContainer
{
ValueForColumnNameType *rowPtr;


ValueForColumnNameContainer() { this->rowPtr = NULL;};
ValueForColumnNameContainer(ValueForColumnNameContainer &aValueForColumnNameContainer) { this->rowPtr = aValueForColumnNameContainer.rowPtr;};
void operator= (const ValueForColumnNameContainer &aValueForColumnNameContainer) { this->rowPtr = aValueForColumnNameContainer.rowPtr;};
bool operator== (const ValueForColumnNameContainer &aValueForColumnNameContainer) { return (this->rowPtr == aValueForColumnNameContainer.rowPtr);};
};



// Set of unique ValueForColumnNameContainer pointers
typedef std::set< ValueForColumnNameContainer > ValueForColumnNameContainerSetType;


ValueForColumnNameContainerSetType sampleSet;
ValueForColumnNameContainerSetType::iterator rowsMapPtrInterator (sampleSet.begin());


Note: If using Microsoft Visual C++ 6.0 or earlier, nested template declarations are not supported so the above code will not compile because the compiler can't handle std::set< std::map<std::string, std::string> * > or equivalents.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: To C++ users trying to use Cocoa
      • From: Andy Lee <email@hidden>
  • Prev by Date: Shared Default Bindings not saving
  • Next by Date: Re: To C++ users trying to use Cocoa
  • Previous by thread: Re: To C++ users trying to use Cocoa
  • Next by thread: Re: To C++ users trying to use Cocoa
  • Index(es):
    • Date
    • Thread