In http://reviews.llvm.org/D9044#161265, @eugenis wrote:

> In http://reviews.llvm.org/D9044#161258, @EricWF wrote:
>
> > In http://reviews.llvm.org/D9044#156827, @eugenis wrote:
> >
> > > In http://reviews.llvm.org/D9044#156813, @EricWF wrote:
> > >
> > > > You'll need to use reserved identifiers
> > >
> > >
> > > Do you mean for local variable names? Is there a technical reason for 
> > > this, or just a code style thing?
> >
> >
> > For any name not defined in the standard you should use reserved 
> > identifiers. Assume that the user of the standard library defines every 
> > non-reserved, non-defined name as a macro. We use reserved identifiers so 
> > that conforming programs can define non-reserved names globally and still 
> > use the standard library.
> >
> > For example:
> >
> >   #define PopulationIterator char*
> >   #define SampleIterator char*
> >   #define UniformRandomNumberGenerator &rand
> >   #include <experimental/algorithm>
> >
>
>
> Good point, will do.
>
> > 
>
> > 
>
> > > > and guard the definition of `sample` inside a C++14 only block because 
> > > > adding a new definition of could break existing code.
>
> > 
>
> > > 
>
> > 
>
> > > 
>
> > 
>
> > > n4335 does not seem to require that this is only available in C++14. And 
> > > aren't names under std:: already reserved, and an addition of a new std:: 
> > > name could not break compliant code?
>
> > 
>
> > 
>
> > I would prefer not to restrict these things to c++14 only, although there 
> > may be a reason that conforming implementations need to that isn't visible 
> > in n4335.
>
> > 
>
> > However because `sample` is a function it can be looked up by ADL. Since 
> > `sample` takes user-defined iterator types and RNG's it is possible that 
> > existing unqualified calls to `sample` in user code may now find 
> > `std::sample`.
>
>
> That's a valid concern, but limiting this definition to C++14 will still 
> break existing C++14 code. Is it really that much better than breaking C++11 
> and C++14 at the same time?
>  Also, that would be std::experimental::sample.


This is probably a conversation worth having on a larger scale. I think the 
rational for keeping in C++14 only is:

1. N4335 references the C++14 standard as its base document
2. C++11 should be "stable". Additions added to the language after C++11 not 
break valid code.

However I think these new features are useful enough that there is a strong 
motivation to provide them whenever possible. Also, in order for this to break 
existing code the user has to be including <experimental/*> headers anyway. 
Furthermore I believe we already allow `string_view` to be used in C++11.

I'll open up a bug to discuss this issue.


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9044

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/



_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to