[Developers] return_arrays_increment();

dave fournier davef at otter-rsch.com
Tue Sep 15 11:16:06 PDT 2009


Arni Magnusson wrote:
> I appreciate your thoughts on this, Dave.
The right way would be


  if (A)
 {
     RETURN_ARRAYS_DECREMENT();
     return X;
 }

It migth be possible to turn FUNCTIONS  into function objects (maybe
that is what they call functors (not to be confused with category theory))
and overload the function call to

call

RETURN_ARRAYS_INCREMENT();
 
and
 
RETURN_ARRAYS_DECREMENT();


at the beginning and end.
>
>
>> Well it is not just a matter of sticking a
>>
>>  RETURN_ARRAYS_DECREMENT();
>>
>> at the end of the function because there may be a complicated set of
>> returns in the function.
>
> You mean that there might be "if (A) then return X" in the middle of
> the function, and then "return Y" much later, at the end of the
> function? I'm not sure how to code that with a dvariable function. Is it:
>
> FUNCTION dvariable f
>   RETURN_ARRAYS_INCREMENT();
>   // ...
>   RETURN_ARRAYS_DECREMENT();
>   if (A) return X;
>   RETURN_ARRAYS_INCREMENT();
>   // ...
>   RETURN_ARRAYS_DECREMENT();
>   return Y;
>
> That rule might be almost as complicated to explain to users, as it is
> to take care of it in tpl2cpp. That is my question, at least.
>
>
>
>> However the entire return arrays construction is probably not needed
>> any more.  Compiler optimization may have made it redundant and even
>> inefficient. You should keep in mind that the code was designed to
>> run on the first Borland Turbo C++ compiler with 640K under DOS in 1990.
>
> You mean that the linad99/gradstrc.cpp definition of void
> RETURN_ARRAYS_INCREMENT(void) and void RETURN_ARRAYS_DECREMENT(void)
> could be simplified? My understanding of Kasper's example is that the
> return arrays construction is still needed.
>
>
>
>> There are a number of areas where it really shows its age.
>
> ADMB is still the best tool for fitting large models, and I'm
> confident it will improve with age. I anticipate that once the source
> is opened, the developer team will have a busy time sorting out code
> patches contributed by users, many of whom know C++ much better than I
> do. (And hopefully some that know flex.)
>
>
> Arni
> _______________________________________________
> Developers mailing list
> Developers at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/developers
>


-- 
David A. Fournier
P.O. Box 2040, 
Sidney, B.C. V8l 3S3
Canada
Phone/FAX 250-655-3364
http://otter-rsch.com



More information about the Developers mailing list