I really like it. One question I would have is how this works with template specializations.
I would propose it just looks like the current class syntax, just with the template parameters after the class.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
Just in case people are opposed to "namespace" (or any other existing
keyword that doesn't "quite fit").
(2) Why the necessity to repeat the template arguments in
template<class T>
namespace class B<T> { }
?
template<typename T>
class B
{
};
template<>
class B<X>
{
};
template<typename T>
namespace class B<T>
{
}
template<>
namespace class B<X>
{
}
The leading template declaration should be unambiguous and IMHO the
syntax should be as analogous to a normal class definition as possible,
including the use for (partial) template specializations
I think that it shouldn't look like a regular class definition for the reasons above.
It could become really misleading to the programmers that have to learn about this stuff.
Then again, the namespace class idea isn't exactly intuitive either, but at least it doesn't feel like you can declare stuff.
PS sorry for emailing the template specialization question after it had already asked. I wrote it then sent it later.
Also, what about the final semicolon? The nice thing about `class namespace` is that, since it has `namespace` there, you can argue that you don't need a semicolon. But since this looks exactly like a class definition, people will be expecting the semicolon.
Just in case people are opposed to "namespace" (or any other existing
keyword that doesn't "quite fit").
(2) Why the necessity to repeat the template arguments in
template<class T>
namespace class B<T> { }
?
So that you can have template specialization syntax:
template<typename T>
class B
{
};
template<>
class B<X>
{
};
template<typename T>
namespace class B<T>
{
}
template<>
namespace class B<X>
{
}
The leading template declaration should be unambiguous and IMHO the
syntax should be as analogous to a normal class definition as possible,
including the use for (partial) template specializations
No, it should not be analogous to a class definition. "Normal class definitions" can add members; these declarations cannot. "Normal class definitions" can declare access classes; these declarations cannot.
This is not a normal class definition, and attempting to make it look like it is is not a good idea.
// in-line definition:
template <typename T>struct B { enum E { E1, E2 };
B& operator=(const B& other) { return *this; } void foo(E e) { }};
// interface
template <typename T>struct B { enum E { E1, E2 }; B& operator=(const B& other);
void foo(E e);};
// implementation
template <typename T>namespace struct B { B& operator=(const B& other) { return *this; } void foo(E e) { }};
--
---
You received this message because you are subscribed to a topic in the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this topic, visit https://groups.google.com/a/isocpp.org/d/topic/std-proposals/MPFsRM9qQm0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to std-proposal...@isocpp.org.
// Foo.h
namespace Foo {
void method();
}
namespace Foo {
void method() {
// ...
}
}
// or
or Foo::method() {
// ...
}
I like this idea a lot, but I'm sceptical to the reuse of the word namespace. There is also another proposal that uses the same syntax with a different meaning, which indicates that it may be non-intuitive. I like that proposal too, which is using namespace as another protection level besides private, protected and public; with the obvious meaning.
I also want to comment on the idea of allowing additional methods inside such an implementation clause. I think it is doable, and a good thing, given the right rules: Only methods declared in the "real" class head have access to private members, or maybe even better: Such extra methods must be private so that they can be used only by the "real" methods of the class (directly or indirectly). Their visibility would have to be limited to the SAME implementation clause as we would otherwise run into trouble with what happens with two such clauses in different TUs requiring magic (aka modules) to transfer the information between the clauses.
This said, it would of course not be possible to add virtual methods or non-static data members, i.e. anything that affects the memory layout of the objects (by this rule local class declarations would be allowed).I know there have been proposals in this direction before, and I think this is the right time to cater for those needs without creating yet another feature.
As far as I'm concerned, syntax should be apportioned on two bases: merit and first-come-first-serve.
The merits of this proposal may be syntactic sugar, but basically nobody liked the "namespace protection level" idea except the person who suggested it.
On 2015-11-24 17:39, Bengt Gustafsson wrote:
> Maybe I was over-reading the suggestion about a namespace protection level.
> To me it was obvious that the most common use case would be to protect some
> of the classes from outside access, as is today commonly done using the
> detail sub-namespace. So I assumed that this would be possible:
>
> namespace my_namespace {
> namespace class Foo { // A namespace local helper class.
What do you think the use of "namespace" here means? (It's not currently
allowed; why would namespace access protection allow it, and what would
it mean?)
> public:
> ...
> private:
> ...
> namespace: // new
> ...
> };
> }
>
> Anyhow, maybe this purpose would be better served by allowing private: and
> public: on the namespace level. This of course offers more protection than
> the current detail:: system but I will not say more about it as it is off
> topic here.
I'm not aware of any proposal like this, even for namespace as the
access level. (What, for example, would private mean, anyway? Private to
what?)
On Sat, Nov 21, 2015 at 3:01 AM, Nicol Bolas <jmck...@gmail.com> wrote:As far as I'm concerned, syntax should be apportioned on two bases: merit and first-come-first-serve.Ummm. Yes, proposals are evaluated based on their merits. The merits in the opinion of people who show up to meetings and vote, after a presentation and discussion (and some of those present will have actually read the paper carefully from the mailing).I have no idea what the "first-come-first-serve" part is you are talking about. If there are competing/conflicting proposals, which one came first has no bearing on how people vote as far as I can tell. It's not even clear why it would or should.
The merits of this proposal may be syntactic sugar, but basically nobody liked the "namespace protection level" idea except the person who suggested it.You can't tell that from a std-proposals thread. The general sentiment on std-proposals doesn't really correlate well with how proposals go at meetings.
A new access mode needs very strong motivation; it's not sufficient that it doesn't cause damage, or that it would be nice for a few selected examples. It must be of fundamental importance. Is it?
On Wednesday, November 25, 2015 at 2:37:45 AM UTC-5, Andrew Tomazos wrote:On Sat, Nov 21, 2015 at 3:01 AM, Nicol Bolas <jmck...@gmail.com> wrote:As far as I'm concerned, syntax should be apportioned on two bases: merit and first-come-first-serve.Ummm. Yes, proposals are evaluated based on their merits. The merits in the opinion of people who show up to meetings and vote, after a presentation and discussion (and some of those present will have actually read the paper carefully from the mailing).I have no idea what the "first-come-first-serve" part is you are talking about. If there are competing/conflicting proposals, which one came first has no bearing on how people vote as far as I can tell. It's not even clear why it would or should.
But that's usually because people avoid conflicting syntax in the first place. If there's a proposal that uses some syntax that has general committee approval and standard wording, and you're starting a proposal that would rather use that syntax for something else, odds are really good that among the suggestions for improving it will be "Proposal X has dibs on that syntax; find something else."
For example, right now I would not suggest making a proposal that uses `auto {...}` syntax in a way that conflicts with P0144.
So I'd say that, while approval here doesn't mean that it will pass muster, widespread dislike here probably is a bad sign. Especially when that widespread dislike includes the EWG chair saying this:
A new access mode needs very strong motivation; it's not sufficient that it doesn't cause damage, or that it would be nice for a few selected examples. It must be of fundamental importance. Is it?
This is hardly a guarantee of failure, but I wouldn't be too hopeful just the same. Not until you can find a really good answer to that question.
On 2016-03-22 15:47, Paul wrote:
> Has there been any updates on this proposal (Maybe in Jacksonville?) ?.
It wasn't presented. A few individuals expressed that they thought it
doesn't go far enough, i.e. that 'using <classname>' should also be
supported. Others waved their arms making noises of doom and gloom
regarding name lookup.
On 2016-03-22 16:46, Paul wrote:
> On Tuesday, March 22, 2016 at 9:08:00 PM UTC+1, Matthew Woehlke wrote:
>> On 2016-03-22 15:47, Paul wrote:
>>> Has there been any updates on this proposal (Maybe in Jacksonville?) ?.
>>
>> It wasn't presented.
>
> That's really disappointing. I have just started again using C++ and
> of course there were tons of class templates everywhere with these
> awful long instantiation names.
Do you have examples you can share? Anything that can add to the
motivation would help...
I prefer keeping "interface and implementation" separate just for the sake of more code clarity
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/nct4ch%24emp%241%40ger.gmane.org.