Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Core chat... (reference counted pointers etc.)
Re: Core chat... [message #12331 is a reply to message #12325] Thu, 25 October 2007 14:06 Go to previous messageGo to previous message
mdelfede is currently offline  mdelfede
Messages: 1308
Registered: September 2007
Ultimate Contributor
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...
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.

Quote:


Also, this is not the only place you need be aware of the problem:

a.Add() = a[0];


That could be solved with a construct like
a.Dup(0);

where Dup() should have an obvious function.or
a.Grow(1);
a.Last() = a[0]


for example, or something similar. The point is to avoid potentially dangerous cases.
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.
I *do not* criticize retourning references, that's needed for speed sakes, but I think a generic class like an array should make potentially dangerous constructs impossible.

Ciao

Max
 
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 May 11 22:50:34 CEST 2025

Total time taken to generate the page: 0.03915 seconds