U++ framework
Do not panic. Ask here before giving up.

Home » Developing U++ » U++ Developers corner » Core chat... (reference counted pointers etc.)
Re: Core chat... [message #12332 is a reply to message #12331] Thu, 25 October 2007 14:34 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
mdelfede wrote on Thu, 25 October 2007 08:06

luzr wrote on Thu, 25 October 2007 05:33


Consider composition a.At(x).At(y)... It can become tedious.


yes, but finding At() kind of bugs can be even more tedious...



Well, sometimes finding bugs IS tedious. But this one was the first At related I had to spend more than 10 minutes.

Quote:


There you could write :
a.CheckSize(x).CheckSize(y);
a[x][y];

if [][] operators can be joined, if not
a.CheckSize(x).CheckSize(y);
a.At(x).At(y)

You need only CheckSize to return a reference to array a as usual in upp.



Hey, think about it a little bit more. To make what you suggest work, CheckSize has to return a reference to contained element. So it behaves exactly the same as At.

Quote:


Of course, all that cost something in term of code lines, (besides the Dup() example...) but nothing in terms of code speed, but avoids many possible caveats.



Actually, would be a bit slower, as you get the variable address evaluated in the At once. Your version evaluates it twice (and in composition example, access the outer container twice too).

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ValueMap
Next Topic: Quick and dirty solution to .icpp problem...
Goto Forum:
  


Current Time: Sun Aug 30 18:59:06 GMT+2 2026

Total time taken to generate the page: 0.01124 seconds