D - more or less power than C++?

Johan Granberg lijat.meREM at OVEgmail.com
Tue Mar 7 04:21:04 PST 2006


Tyler Knott wrote:
> In article <dui6d5$2134$1 at digitaldaemon.com>, Johan Granberg says...
>> Hasan Aljudy wrote:
>>>> Because then i would have to call a method to read bar and that would 
>>>> bee inefective. 
>>> You know, CPUs are fast now a days, a single function call is not 
>>> "ineffective".
>> That argument does not hold if you are in a tight loop it will matter.
> 
> Why not just use a method to return a pointer to the private member and use that
> within your hypothetical tight loop, then use proper get/set methods when CPU
> time is not important?  It shouldn't use any more CPU time than referencing the
> member directly (because both the object reference and pointer need to be
> deferenced before what they referenced can be used through them).  Or what about
> copying the member to a temporary variable in the scope above the loop's, using
> the temporary variable within the loop, then setting the member to the value of
> the temporary var when the loop is finished?  (And even if there is an exception
> thrown and you still want the member to be set to the same value as the temp
> var, you could use on_scope_failure to call the set method in that event.)
> 
> 
I'm avare you can do that but I see it as a ugly workaround rather than 
a solution.



More information about the Digitalmars-d mailing list