Re: [eigen] API change proposal

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


I'll chime in here...When I see a function that takes any type of pointer (const/non-const) as a parameter, this signals to me that null is a valid value to pass to the function.  If null is not a valid value, then the argument should be passed by reference.  As far as whether or not it's obvious from the call site whether the argument may be modified, one has to assume that a user/maintainer will look at the signature of the function when trying to understand its purpose.  A function's signature is its public interface after all.

--- On Thu, 7/23/09, Markus Fröb <grey_earl@xxxxxx> wrote:

From: Markus Fröb <grey_earl@xxxxxx>
Subject: Re: [eigen] API change proposal
To: eigen@xxxxxxxxxxxxxxxxxxx
Date: Thursday, July 23, 2009, 5:37 AM


I agree with Patrick; as in what I have encountered so far, const (reference/pointer) always meant the object won't be modifed, non-const (reference/pointer) meant the object is potentially modified, thereby signaling this is an output argument. Insofar there is (for me) no difference between pointer and reference.

Markus

> Von: "Patrick Mihelich" <patrick.mihelich@xxxxxxxxx>
> I agree with Markus. Even ignoring the naming (ResultType, result),
> the fact that the reference is non-const signals that it is an output
> of the function.
>
> Patrick
>
> On Wed, Jul 22, 2009 at 3:30 PM, Andrea Arteaga <yo.eres@xxxxxxxxx>
> wrote:
> In principle, I'm agree with Markus, since pointers in C++ can be
> considered as low-level concept
> and Eigen allows a high-level manipulation of objects; that pointers
> could be "out of place".
>
> But: when a method of LU (or QR) takes a reference as argument, is it
> clear to users that the
> function will modify that argument? Pointers are the classical system
> to output something, which
> cannot be the return value. In spite of the practicality of
> references, pointers make clear that the
> argument is a "output argument", not an input one.
>
> However, Eigen could also provide both behaviours by overloading the
> method.
>
> Andrea Arteaga
>
>
>


________________________________________________________________
Neu: WEB.DE Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate
für nur 19,99 Euro/mtl.!* http://produkte.web.de/go/02/





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/