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++ » UppHub » Anonymous delegates
Re: Anonymous delegates [message #13019 is a reply to message #12541] Wed, 05 December 2007 15:33 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14266
Registered: November 2005
Ultimate Member
Zardos wrote on Wed, 07 November 2007 21:17

If you use it, please be aware it's still only a macro.

To illustrate the fundamentel problem a simple example:

Vector<int> CreateResultVector() {
   Vector<int> r;
   r.Add(1);
   r.Add(2);
   r.Add(3);
   return r;
}

...

foreach(int e, CreateResultVector())
   DUMP(e);


Basically the code is stupidly translated to something like this:
for(int i = 0; i < CreateResultVector().GetCount(); i++)
   DUMP(CreateResultVector()[i]);


... CreateResultVector is called multiple times!
But this is probably not what you would expect from a real foreach build into the language!



Curiously, this is exactly what I would expect... (I mean, called multiple times).

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: FontSel dialog
Next Topic: ChessBoard
Goto Forum:
  


Current Time: Fri Jul 18 14:29:05 CEST 2025

Total time taken to generate the page: 0.02793 seconds