Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #207 > unrolled thread

New syntax proposal for attributes

Started byPhil Bouchard <philippe@fornux.com>
First post2011-08-07 13:08 -0600
Last post2011-08-08 23:54 -0600
Articles 4 — 3 participants

Back to article view | Back to comp.std.c++


Contents

  New syntax proposal for attributes Phil Bouchard <philippe@fornux.com> - 2011-08-07 13:08 -0600
    Re: New syntax proposal for attributes Francis Glassborow <francis.glassborow@btinternet.com> - 2011-08-07 17:58 -0600
      Re: New syntax proposal for attributes Phil Bouchard <philippe@fornux.com> - 2011-08-08 23:55 -0600
    Re: New syntax proposal for attributes BGB <cr88192@hotmail.com> - 2011-08-08 23:54 -0600

#207 — New syntax proposal for attributes

FromPhil Bouchard <philippe@fornux.com>
Date2011-08-07 13:08 -0600
SubjectNew syntax proposal for attributes
Message-ID<4e3d8b2b$1@news.x-privat.org>
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                      ]

[toc] | [next] | [standalone]


#209

FromFrancis Glassborow <francis.glassborow@btinternet.com>
Date2011-08-07 17:58 -0600
Message-ID<jIqdnYyHL6UJnqLTnZ2dnUVZ8j-dnZ2d@bt.com>
In reply to#207
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                      ]

[toc] | [prev] | [next] | [standalone]


#210

FromPhil Bouchard <philippe@fornux.com>
Date2011-08-08 23:55 -0600
Message-ID<4e3f4f71$1@news.x-privat.org>
In reply to#209
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                      ]

[toc] | [prev] | [next] | [standalone]


#211

FromBGB <cr88192@hotmail.com>
Date2011-08-08 23:54 -0600
Message-ID<j1nbbl$5vf$1@news.albasani.net>
In reply to#207
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                      ]

[toc] | [prev] | [standalone]


Back to top | Article view | comp.std.c++


csiph-web