const mapper functions

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

const mapper functions

Rik-4
jwe,

Is there any reason not to make the function reference passed in to
do_rc_map constant?

ov-flt-re-mat.cc (738)
    V669     The 'fcn' argument is a non-constant reference. The analyzer
is unable to determine the position at which this argument is being
modified. It is possible that the function contains an error.

Line 737-738 of ov-flt-re-mat.cc is

static octave_value
do_rc_map (const FloatNDArray& a, FloatComplex (&fcn) (float))

The other *-re-mat.cc have the same question.  The function passed in is a
mapper like sin, cos, etc. and I can't imagine we would change it mid-stream.

--Rik



Reply | Threaded
Open this post in threaded view
|

Re: const mapper functions

John W. Eaton
Administrator
On 1/8/19 3:24 PM, Rik wrote:

> jwe,
>
> Is there any reason not to make the function reference passed in to
> do_rc_map constant?
>
> ov-flt-re-mat.cc (738)
>      V669     The 'fcn' argument is a non-constant reference. The analyzer
> is unable to determine the position at which this argument is being
> modified. It is possible that the function contains an error.
>
> Line 737-738 of ov-flt-re-mat.cc is
>
> static octave_value
> do_rc_map (const FloatNDArray& a, FloatComplex (&fcn) (float))
>
> The other *-re-mat.cc have the same question.  The function passed in is a
> mapper like sin, cos, etc. and I can't imagine we would change it mid-stream.

I'm in favor of declaring any reference or pointer arguments and member
functions const if we can.  So yes, if you want to do i and have the
time, please fix them.

I generally don't see a need for doing that for local values that are
never modified after initialization, but I can also see the argument for
that in some cases.

jwe


Reply | Threaded
Open this post in threaded view
|

Re: const mapper functions

Rik-4
On 01/08/2019 01:03 PM, John W. Eaton wrote:

> On 1/8/19 3:24 PM, Rik wrote:
>> jwe,
>>
>> Is there any reason not to make the function reference passed in to
>> do_rc_map constant?
>>
>> ov-flt-re-mat.cc (738)
>>      V669     The 'fcn' argument is a non-constant reference. The analyzer
>> is unable to determine the position at which this argument is being
>> modified. It is possible that the function contains an error.
>>
>> Line 737-738 of ov-flt-re-mat.cc is
>>
>> static octave_value
>> do_rc_map (const FloatNDArray& a, FloatComplex (&fcn) (float))
>>
>> The other *-re-mat.cc have the same question.  The function passed in is a
>> mapper like sin, cos, etc. and I can't imagine we would change it
>> mid-stream.
>
> I'm in favor of declaring any reference or pointer arguments and member
> functions const if we can.  So yes, if you want to do i and have the
> time, please fix them.

I don't have time this cycle, but good to know we might change it later.

--Rik