From: "Ike" Newsgroups: comp.os.msdos.djgpp References: <3 DOT 0 DOT 32 DOT 19990801181614 DOT 007b9130 AT mail DOT colba DOT net> <37a5e4a8 AT news DOT ismi DOT net> Subject: Re: BITMAP pointers w/ Allegro. Date: Mon, 2 Aug 1999 19:58:26 -0700 Lines: 29 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 NNTP-Posting-Host: tc4-20.ismi.net Message-ID: <37a6305b@news.ismi.net> X-Trace: 2 Aug 1999 19:57:15 -0400, tc4-20.ismi.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com > > I've got a question about that, I was asking around on IRC about this > > problem and they said that its improper programming practice (wow that's > > hard to say) to have the return value of a function be a pointer. They > said > > that it violates the law of encapsulation. But I've noticed that the > > Allegro library does it all the time with BITMAP structures, is that > bad? > > You (or should I say they) just can't generalize like that - it depends on > the situation. In Allegro's case I can't remember any of such function > right now, other than load_bmp and create_bitmap which can be thought of as > a constructor (thus it has to be like that, and it is good). > > And that it should violate the law of encapsulation - hmm... I think they > were thinking about something slightly different, maybe. Well maybe it was the example that I gave, I asked if ... int *function(void); ... was the correct declaration of a function that returns a pointer and they said yes, but that it shouldn't be done, and they mumbled something about functions "being responsible for creating and destroying all dynamically allocated data" or something similar. Maybe I just interpreted it wrong.