Naming template parameters

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Naming template parameters

Mateusz Loskot
Administrator
Hi,

What do you think about stealing template parameters naming from Spirit
so they are yet easier to recognize.

We've agreed to use CamelCase, but Spirit proposes a slight
modification: CamelCaseT with T postfix.

Personally, I've found it very helpful to visually
recognize parts of Spirit code. What you think about this?

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
--
Mateusz Loskot
http://mateusz.loskot.net
Reply | Threaded
Open this post in threaded view
|

Naming template parameters

Barend Gehrels
Hi,

> What do you think about stealing template parameters naming from Spirit
> so they are yet easier to recognize.
>
> We've agreed to use CamelCase, but Spirit proposes a slight
> modification: CamelCaseT with T postfix.
>  
I thought about it. It sounds not too attractive to me. The changes we
made until sofar were to comply to the Boost Guidelines. I'm slowly
getting used to them. These guidelines are not too strict, there is some
variation among different boost libraries. I think Spirit uses such a
deviation, indeed to make it clear what is a template. I don't know why,
the CamelCase is unique and clear enough (now that typedefs are or will
be in lower case). Spirit also has the _t postfix for typedefs, which is
also a bit too much for me.

Regards, Barend


Reply | Threaded
Open this post in threaded view
|

Naming template parameters

Mateusz Loskot
Administrator
Barend Gehrels wrote:

> Hi,
>
>> What do you think about stealing template parameters naming from
>> Spirit so they are yet easier to recognize.
>>
>> We've agreed to use CamelCase, but Spirit proposes a slight
>> modification: CamelCaseT with T postfix.
>>
> I thought about it. It sounds not too attractive to me. The changes
> we made until sofar were to comply to the Boost Guidelines. I'm
> slowly getting used to them. These guidelines are not too strict,
> there is some variation among different boost libraries. I think
> Spirit uses such a deviation, indeed to make it clear what is a
> template. I don't know why, the CamelCase is unique and clear enough
> (now that typedefs are or will be in lower case). Spirit also has the
> _t postfix for typedefs, which is also a bit too much for me.

OK. It was just a loose idea. GGL heavily uses templates so I thought it
may be reasonable to make some parts of code yet more visible.

Sticking to our guidelines.

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
--
Mateusz Loskot
http://mateusz.loskot.net
Reply | Threaded
Open this post in threaded view
|

Naming template parameters

Mateusz Loskot
Administrator
In reply to this post by Barend Gehrels
Barend Gehrels wrote:

> Hi,
>
>> What do you think about stealing template parameters naming from
>> Spirit so they are yet easier to recognize.
>>
>> We've agreed to use CamelCase, but Spirit proposes a slight
>> modification: CamelCaseT with T postfix.
>
> I thought about it. It sounds not too attractive to me. The changes
> we made until sofar were to comply to the Boost Guidelines. I'm
> slowly getting used to them. These guidelines are not too strict,
> there is some variation among different boost libraries. I think
> Spirit uses such a deviation, indeed to make it clear what is a
> template. I don't know why, the CamelCase is unique and clear enough
> (now that typedefs are or will be in lower case). Spirit also has the
> _t postfix for typedefs, which is also a bit too much for me.

Barend, Bruno,

I've applied some refactoring to ggl/geometries/* and for instance, for
polygon class, I decided to use _type postifx for typedef declarations.
I'm not sure about it, however.

I thought it makes sense to distinct class name of alias name,
especially name of public alias. Also, std library uses _type
postfix for aliases exposed as public interface of a class.

For example, I changed  "B" alias this way:

template <typename P, std::size_t C, std::size_t D>
struct indexed_access<box<P>, C, D>
{

    typedef box<P> box_type;
};

What do you think about it?

As I've said, for now I cleaned up ggl/geometries, not more.
But if we accept this suffix, then I'll use it in other modules.

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
--
Mateusz Loskot
http://mateusz.loskot.net
Reply | Threaded
Open this post in threaded view
|

Naming template parameters

Mateusz Loskot
Administrator
Mateusz Loskot wrote:

> Barend Gehrels wrote:
>> Hi,
>>
>>> What do you think about stealing template parameters naming from
>>> Spirit so they are yet easier to recognize.
>>>
>>> We've agreed to use CamelCase, but Spirit proposes a slight
>>> modification: CamelCaseT with T postfix.
>> I thought about it. It sounds not too attractive to me. The changes
>> we made until sofar were to comply to the Boost Guidelines. I'm
>> slowly getting used to them. These guidelines are not too strict,
>> there is some variation among different boost libraries. I think
>> Spirit uses such a deviation, indeed to make it clear what is a
>> template. I don't know why, the CamelCase is unique and clear enough
>> (now that typedefs are or will be in lower case). Spirit also has the
>> _t postfix for typedefs, which is also a bit too much for me.
>
> Barend, Bruno,
>
> I've applied some refactoring to ggl/geometries/* and for instance, for
> polygon class, I decided to use _type postifx for typedef declarations.
> I'm not sure about it, however.
>
> I thought it makes sense to distinct class name of alias name,
> especially name of public alias. Also, std library uses _type
> postfix for aliases exposed as public interface of a class.
>
> For example, I changed  "B" alias this way:
>
> template <typename P, std::size_t C, std::size_t D>
> struct indexed_access<box<P>, C, D>
> {
>
>     typedef box<P> box_type;
> };
>
> What do you think about it?
>
> As I've said, for now I cleaned up ggl/geometries, not more.
> But if we accept this suffix, then I'll use it in other modules.

One more thing, as these aliases are public, we should expect
that some users may want to use it in their code.
Thus, I believe it's worth to work out some convention used across the
code. So, users can familiarize with code easier and public
aliases won't change in future.

Summary:

1. tags use ::type as alias name, for instance:


template <typename P>
struct tag< box<P> >
{
    typedef box_tag type;
};

2. all other public aliases use _type postfix, as in the example
in my previous post (above).

How do you find it?

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
--
Mateusz Loskot
http://mateusz.loskot.net