FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

asserts are useless
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
Pse



Joined: 13 Dec 2007
Posts: 36

PostPosted: Thu Dec 20, 2007 10:17 pm    Post subject: Reply with quote

ShprotX, those are some good points.

1) I agree, it's not really necessary to create a temporary object, compare, and return accordingly. Either by throwing an exception or by returning what gtk returned, if object construction fails, we'll still end up a with a null object.
2) Yes, it'd be bad if the user bypassed gtkd and then passed the object to gtkd without first checking it. I think this provides a good example of when exceptions might provide good information for unhandled cases.

However, I'd like to address your point about unnecessary memory copies. Object construction should not be considered a cheap operation: resources are being assigned, base class constructors getting called, etc. Therefore, a simple pointer copy operation is virtually free. There's no point trying in trying to optimize them out. However, I do agree they're not really needed (not even for code clarity), so it might be in place to avoid them, as you propose.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> gtkD All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group