Topic: New syntax proposal for attributes
Author: Phil Bouchard <philippe@fornux.com>
Date: Sun, 7 Aug 2011 13:08:31 CST Raw View
Hello,
The new syntax for attributes is horrifying and I would like to
propose a new one which is very neat.
Instead of:
class [[base_check, align(16)]] D : public B {
public:
virtual void f [[override, nodebug]] ();
virtual int g [[final, noexcept]] (int);
virtual void h [[hiding]] ();
};
Why not:
class D = base_check, align(16) : public B {
public:
virtual void f() = override, nodebug;
virtual int g(int) = final, noexcept;
virtual void h() = hiding;
};
This is much more readable and is consistent with the "= delete"
compile-time property as well.
-Phil
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Francis Glassborow <francis.glassborow@btinternet.com>
Date: Sun, 7 Aug 2011 17:58:23 CST Raw View
On 07/08/2011 20:08, Phil Bouchard wrote:
>
> Hello,
>
> The new syntax for attributes is horrifying and I would like to
> propose a new one which is very neat.
That is a matter of opinion. However even if I agreed with you, it is
almost a year too late. I think most people will become happier with the
syntax as they get used to it (after all a great number of programmers
have managed to become accustomed to large amounts of upper case along
with Hungarian notation, both of which I find much more horrific)
>
> Instead of:
> class [[base_check, align(16)]] D : public B {
> public:
> virtual void f [[override, nodebug]] ();
> virtual int g [[final, noexcept]] (int);
> virtual void h [[hiding]] ();
> };
>
> Why not:
> class D = base_check, align(16) : public B {
> public:
> virtual void f() = override, nodebug;
> virtual int g(int) = final, noexcept;
> virtual void h() = hiding;
> };
>
> This is much more readable and is consistent with the "= delete"
> compile-time property as well.
>
>
> -Phil
>
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Phil Bouchard <philippe@fornux.com>
Date: Mon, 8 Aug 2011 23:55:25 CST Raw View
On 8/7/2011 7:58 PM, Francis Glassborow wrote:
>
> On 07/08/2011 20:08, Phil Bouchard wrote:
>>
>> Hello,
>>
>> The new syntax for attributes is horrifying and I would like to
>> propose a new one which is very neat.
>
> That is a matter of opinion. However even if I agreed with you, it is
> almost a year too late. I think most people will become happier with the
> syntax as they get used to it (after all a great number of programmers
> have managed to become accustomed to large amounts of upper case along
> with Hungarian notation, both of which I find much more horrific)
My idea was perhaps wrong because an equal sign might be confused with
it's real purpose if we'd like to attach an attribute to a variable but
I see why attributes are declared between the function name and the
opening parenthesis. IDEs will make the text more readable I guess.
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: BGB <cr88192@hotmail.com>
Date: Mon, 8 Aug 2011 23:54:49 CST Raw View
On 8/7/2011 12:08 PM, Phil Bouchard wrote:
>
> Hello,
>
> The new syntax for attributes is horrifying and I would like to
> propose a new one which is very neat.
>
could be worse...
technically off-topic:
my own language uses "$[...]" as the attribute syntax, mostly because I
had originally intended to do "[...]" attributes like in C# but then
found that in some cases they would have made the syntax ambiguous, and
so tacking '$' on the front was a quick and easy way to fix the ambiguity.
I would have rather used #[...] except that I already use this syntax
(for vector and matrix literals), and $ was the next key over.
> Instead of:
> class [[base_check, align(16)]] D : public B {
> public:
> virtual void f [[override, nodebug]] ();
> virtual int g [[final, noexcept]] (int);
> virtual void h [[hiding]] ();
> };
>
> Why not:
> class D = base_check, align(16) : public B {
> public:
> virtual void f() = override, nodebug;
> virtual int g(int) = final, noexcept;
> virtual void h() = hiding;
> };
>
> This is much more readable and is consistent with the "= delete"
> compile-time property as well.
>
I don't like the proposed syntax, as it reeks of possible syntactic
ambiguities, as well as potential visual ambiguities (programmers
encountering this syntax and being like "WTF is this supposed to
mean?..."). at least "[[...]]" would be vaguely more easy to make an
accurate guess as to what it is.
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]