[Developers] return_arrays_increment();

dave fournier davef at otter-rsch.com
Tue Sep 15 10:03:45 PDT 2009


Arni Magnusson wrote:

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.
Interesting that you think of this as low level housekeeping, but R
users are happy to  calculate the derivatives by hand
which strikes me as low level, boring, and error prone.

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.

There are a number of areas where it really shows its age.

> Modellers would be very grateful if they wouldn't have to do this kind
> of low-level housekeeping. Do you think it would be feasible to make
> tpl2cpp insert
>
>   RETURN_ARRAYS_INCREMENT();
>
> and
>
>   RETURN_ARRAYS_DECREMENT();
>
> automatically into the C++ source code, if the return value is of
> dvariable type? This would make ADMB code clearer and much more robust
> to user mistakes.
>
> In terms of backward compatibility, does anyone know if it would be
> okay to repeat the "protective braces" like this,
>
>   RETURN_ARRAYS_INCREMENT();
>   RETURN_ARRAYS_INCREMENT();
>   // code
>   RETURN_ARRAYS_DECREMENT();
>   RETURN_ARRAYS_DECREMENT();
>
> in case the user has also included them in the TPL?
>
> Arni
>
>
>
> On Fri, 4 Sep 2009, Richard Methot wrote:
>
>> There is no mention of this return_arrays queue issue in the ADMB
>> manual. Is there any reason for this being specific to AUTODIF?
>>
>> Rick
>>
>>
>>
>> John Sibert wrote:
>>
>>> Dave provides the "bullet proof" solution. Look near page 3-7 in the
>>> AUTODIF manual.
>>>
>>> John
>>>
>>>
>>>
>>> dave fournier wrote:
>>>
>>>> In this case you can get rid of the error in this way but as I
>>>> already said in general you should read about
>>>>
>>>>    return_arrays_increment();
>>>>    return_arrays_decrement();
>>>>
>>>> if you have functions that return a dvariable object.
>>>
>>
> _______________________________________________
> 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