Boost logo

Boost :

Subject: Re: [boost] [system][filesystem v3] Question about error_code arguments
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-10-27 09:26:58


Peter Foelsche wrote:
> "Stewart, Robert" <Robert.Stewart_at_[hidden]> wrote in message
> news:DF2E67F3D097004694C8428C70A3FD69046934E01F_at_msgbal516.ds.s
> usq.com...
> > As Scott McMurray noted, the call doesn't transfer
> > ownership and isn't
> > polymorphic. However, using a null
> > pointer to indicate the absence of something is idiomatic
> > as Peter Dimov
> > noted. From a purely esthetic point of
> > view, I prefer not having to take the address of the
> > error_code to call
> > such a function.
>
> How does having to pass an address screw up your esthetic
> view of the code?

Have you looked at the definition of (a)esthetic? It is based upon one's notions of beauty, etc. I dislike putting the "&" wart in front of a variable when calling a function versus the "cleanliness" of not. It isn't as if I was saying doing so was wrong. I just like avoiding it when it isn't needful.

> I usually try to avoid non-constant references in my own
> code, since they are obfuscating the code.

I recognize that deficiency of non-const references, but even when taking the address of something, it isn't clear whether the caller's object will be changed or the function merely allows for a value's absence (using a null pointer). Both approaches require knowledge of the function's signature, at least, to understand the effects on the arguments, so neither is superior in this regard.

> I prefer the clarity of using the address operator to tell the person
> reading the code, what is happening.

All that does -- at the call site -- is indicate that the function takes a pointer. Whether the caller's object is modified, the argument is optional, or both is not indicated. There is no additional clarity over references.

I prefer to use raw pointers to make an argument optional, smart pointers to transfer or otherwise control ownership, and references for all else. You have other ideas. It's aesthetics.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk