gnu3dkit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnu3dkit-dev] another tuple q


From: Philippe C . D . Robert
Subject: Re: [Gnu3dkit-dev] another tuple q
Date: Tue, 15 Oct 2002 08:12:18 +0200

On Tuesday, October 15, 2002, at 04:49  Uhr, Brent Gulanowski wrote:

- (float *)elements
{
  return tuple;
}

Here you are giving away the goods, so to speak. At which point, I'm wondering why use an Obj-C class instead of a struct? I am not saying it's a bad thing, only that I'm getting mixed signals here. Would you consider returning a (const float *) to make it read only? If one wants to use the elements of a tuple/vector in a loop, wouldn't one be able to request a copy of the elements (using -setElements: ) before doing the loop work?

Well, often in APIs like OpenGL you need to pass the elements of a tuple as float*, so the functionality is required. It could be const float* but then you would have to cast it for OpenGL everywhere you use it, and this is ugly...

So this is a good example where I sacrifice elegance and OO concepts for performance and usability.

I'm just being the encapsulation religious purist for devil's advocate reasons. My personal feeling is that users are welcome to hang themselves if they want to use the rope for that purpose. But in case you've got a particular reason, I'm curious to hear it.

In general I agree, but here ... see above.

-Phil
--
Philippe C.D. Robert
http://www.nice.ch/~phip





reply via email to

[Prev in Thread] Current Thread [Next in Thread]