Topic: syntax for attributes


Author: fwl@sei.cmu.edu (Fred Long)
Date: Thu, 13 Sep 2007 19:25:17 GMT
Raw View
The document n2379 "Towards support for attributes in C++ (Revision 2)"
proposes that the syntax for attributes be:

     [[attribute]]

Wouldn't it be better to make them formal comments?  For example:

     /*@attribute*/

(Of course, the formal comment indicator after the /* need not be an
at-sign, and could even be more than one character.)

Using a formal comment notation would mean strict upward compatibility,
and would mean that any implementors who wanted to ignore all attributes
would not need to do anything.

 Fred Long,
 Software Engineering Institute,
 Carnegie Mellon University.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: =?iso-8859-1?q?Pedro_Lamar=E3o?= <pedro.lamarao@gmail.com>
Date: Thu, 13 Sep 2007 17:42:06 CST
Raw View
On Sep 13, 4:25 pm, f...@sei.cmu.edu (Fred Long) wrote:

> Wouldn't it be better to make them formal comments?  For example:
>
>      /*@attribute*/

Think doxygen.

/**
 * @brief This class does foo.
 *
 * Class foo encapsulates bar applying pattern Whatever.
 */
class foo;

--
 Pedro Lamar   o


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: James Kanze <james.kanze@gmail.com>
Date: Fri, 14 Sep 2007 11:44:44 CST
Raw View
On Sep 14, 1:42 am, Pedro Lamar   o <pedro.lama...@gmail.com> wrote:
> On Sep 13, 4:25 pm, f...@sei.cmu.edu (Fred Long) wrote:

> > Wouldn't it be better to make them formal comments?  For example:

> >      /*@attribute*/

> Think doxygen.

As he said, the sequence could be anything; he just used @ as an
example.  And the problem is somehow ensuring that the sequence
isn't already used for some meta-tool, like Doxygen.  But @
doesn't cause any problems with Doxygen (although ! or * would).

> /**
>  * @brief This class does foo.
>  *
>  * Class foo encapsulates bar applying pattern Whatever.
>  */
> class foo;

But here, it is the /** which makes the comment significant to
Doxygen; the @ only has meaning within such comments.  And
/*@attribute*/ doesn't start with a /** (nor any of the other
sequences Doxygen recognizes).  On the other hand, I wouldn't be
surprised if some other tool used @ for this; it's a fairly
obvious choice.

--
James Kanze (GABI Software)             email:james.kanze@gmail.com
Conseils en informatique orient   e objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S   mard, 78210 St.-Cyr-l'   cole, France, +33 (0)1 30 23 00 34


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]