Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-05-04 09:57:52


Rob Stewart wrote:
> From: "Peter Dimov" <pdimov_at_[hidden]>
>> Beman Dawes wrote:
>>> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
>>> news:005701c55008$0eacc010$6401a8c0_at_pdimov2...
>>>> Rob Stewart wrote:
>>>>> I don't like the status()/symlink_status() split. How about
>>>>> overloading like this:
>>>>>
>>>>> struct follow_symlink_t { };
>>>>> extern const follow_symlink_t follow_symlink;
>>>>>
>>>>> status_flags status(path const &);
>>>>> status_flags status(path const &, follow_symlink_t);
>>>>
>>>> FWIW, I'm in favor of the current design.
>>>
>>> Rationale?
>>
>> I don't view overloading for overloading's sake as improvement;
>> there's nothing wrong with giving different names to different
>> behaviors.
>
> These functions do very nearly the same thing. That seems an
> ideal case for overloading.

This particular case is on the fence. One could think of the overloaded
interface as a typesafe approximation of

status_return_flags status( path const & p, status_option_flags flags =
status_option_default );

with follow_symlink being the only option flag at the moment.

In general, though, excessive overloading should be avoided. My usual litmus
test for appropriate overloading is: can you tell what this does:

    f( x, y );

without looking up the exact types of x and y.


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