Is it worth having const/immutable functions on ranges? [was: Re: std.path review: second update]
Jonathan M Davis
jmdavisProg at gmx.com
Fri Jul 29 13:43:58 PDT 2011
On Friday 29 July 2011 15:58:14 Steven Schveighoffer wrote:
> On Fri, 29 Jul 2011 15:47:55 -0400, KennyTM~ <kennytm at gmail.com> wrote:
> > Comments:
> >
> > - pathSplitter: empty, front, back could be const.
>
> I know it seems like "if it could be const, we should mark it const", but
> does it always make sense? I mean, consider this example. Should
> front/back/empty be const? What are ever the chance that someone has a
> const range? Consider that a const range is near useless (it can't do
> it's primary function -- iterate).
>
> Just wondering...
I'd generally argue that if it can be const, it should be const. So, it's
probably better to make empty, front, and back const. However, const functions
_range_ rather pointless for ranges. So, I'm not really sure that it matters.
It could go either way.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list