概念的语法建议 [英] syntax suggestion for concepts

查看:62
本文介绍了概念的语法建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

概念的恐惧因素会略微减少,如果,

而不是:


概念C< typename T>

{

typename T :: S;

int T :: mem();

int nonmem();

};


a新增用::使用概念/

概念图与类接口更加一致:


概念C< typename T>

{

typename S

int mem();

int :: nonmem();

};


这可能是一个不好的方面就是多类型

概念只能指定前缀为::,

的名称,即现有提案下的名称:


概念D< typename U,typename V>

{

int U :: umem();

int uandv(U u,V v);

} ;


必须改为:


概念DD< typename U>

{

int umem();

};

概念D< typename U,typename V:DD< U>

{

int :: uandv();

};


(或者,一个保留字概念)可能是

替换为两个:代数对于单一类型

概念和几何概念对于多种类型

概念。这样可以避免几何中无处不在的

::。


对于正交性,可以在
$ b $中使用:: b类接口也是如此。概念和类接口

都是描述类型用法的方式,因此对我来说似乎更直观,它们与

可能相似。

Would the fear factor for concepts be slightly reduced if,
instead of:

concept C<typename T>
{
typename T::S;
int T::mem();
int nonmem();
};

a new usage of :: was added to make concepts/
concept maps more consistent with class interfaces:

concept C<typename T>
{
typename S
int mem();
int ::nonmem();
};

A perhaps bad aspect of this is that multi-type
concepts could ONLY specify names prefixed with ::,
that is, this under the existing proposal:

concept D<typename U, typename V>
{
int U::umem();
int uandv(U u, V v);
};

would have to be changed to something like:

concept DD<typename U>
{
int umem();
};
concept D<typename U, typename V: DD<U>
{
int ::uandv();
};

(Or, the one reserve word "concept" could be
replaced with two: "algebra" for single-type
concepts, and "geometry" for multi-type
concepts. This would avoid the ubiquitous
:: in geometries.)

For orthogonality, this use of :: could be allowed in
class interfaces as well. Concepts and class interfaces
are both ways of describing type usage, so it seems
more intuitive to me that they be as similar as
possible.

推荐答案

2月25日14:57,W Karas < wka ... @ yahoo.comwrote:
On 25 Feb, 14:57, "W Karas" <wka...@yahoo.comwrote:

如果,

而不是:$,概念的恐惧因素会略微减少吗? b $ b
Would the fear factor for concepts be slightly reduced if,
instead of:



....


你最好把上面的内容转发给comp.std.c ++。

他们通常会讨论这类事情。


(他们中的许多人不喜欢与像我这样的低级生活联系起来

在comp.lang.c ++ ;-))


问候

Andy Little


....

Your probably better off reposting the above to comp.std.c++.
That where they usually discuss this type of thing.

(Many of them don''t like to associate with lowlife such as meself here
on comp.lang.c++ ;-) )

regards
Andy Little



2月25日上午9:57,W Karas < wka ... @ yahoo.comwrote:
On Feb 25, 9:57 am, "W Karas" <wka...@yahoo.comwrote:

如果,

而不是:概念的恐惧因素会略微减少吗? br />

概念C< typename T>

{

typename T :: S;

int T :: mem();

int nonmem();

};


a添加了::的新用法概念/

概念图与类接口更加一致:


概念C< typename T>

{

typename S

int mem();

int :: nonmem();

};


这可能是一个不好的方面,多类型

概念只能指定前缀为::,

的名称,即现有提案下的名称:


概念D< typename U,typename V>

{

int U :: umem();

int uandv(U u,V v);

};


必须改为li ke:


概念DD< typename U>

{

int umem();

};

概念D< typename U,typename V:DD< U>

{

int :: uandv();

};


(或者,一个保留字概念)可能是

替换为两个:代数对于单一类型

概念和几何概念对于多种类型

概念。这样可以避免几何中无处不在的

::。


对于正交性,可以在
$ b $中使用:: b类接口也是如此。概念和类接口

都是描述类型用法的方式,因此对我来说似乎更直观,它们与

可能相似。
Would the fear factor for concepts be slightly reduced if,
instead of:

concept C<typename T>
{
typename T::S;
int T::mem();
int nonmem();
};

a new usage of :: was added to make concepts/
concept maps more consistent with class interfaces:

concept C<typename T>
{
typename S
int mem();
int ::nonmem();
};

A perhaps bad aspect of this is that multi-type
concepts could ONLY specify names prefixed with ::,
that is, this under the existing proposal:

concept D<typename U, typename V>
{
int U::umem();
int uandv(U u, V v);
};

would have to be changed to something like:

concept DD<typename U>
{
int umem();
};
concept D<typename U, typename V: DD<U>
{
int ::uandv();
};

(Or, the one reserve word "concept" could be
replaced with two: "algebra" for single-type
concepts, and "geometry" for multi-type
concepts. This would avoid the ubiquitous
:: in geometries.)

For orthogonality, this use of :: could be allowed in
class interfaces as well. Concepts and class interfaces
are both ways of describing type usage, so it seems
more intuitive to me that they be as similar as
possible.



另一个想法,不一定取决于上面的

,将允许类接口

be使用现有概念定义。如果C是

a概念,一个可能的sytax可能是:


class X使用C

{

// ...未申报的其他内容

//由C ...

};


但是这确实间接地引入了一种在命名空间范围内定义事物的方式

作为类接口声明的一部分,

这似乎是另一个原因允许在类

接口中定义名称上的

::前缀,用于在类中的直接定义
命名空间作用域

界面。


---

[comp.std.c ++经过审核。要提交文章,请尝试发布]

[您的新闻阅读器。如果失败,请使用mailto:st ***** @ ncar.ucar.edu]

[---请在发布前查看常见问题解答。 ---]

[常见问题: http:/ /www.comeaucomputing.com/csc/faq.html ]

Another thought, not necessarily depedent on the
above, would be to allow class interfaces to
be defined using existing concepts. If C is
a concept, one possible sytax could be:

class X using C
{
// ... additional stuff not declared
// by C ...
};

But since this does indirectly introduce a
way of defining things in namespace-scope
as a part of a class interface declaration,
this seems another reason to allow the
:: prefix on defined names in a class
interface, for direct definition in
namespace scope within the class
interface.

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


3月5日上午9:12,W Karas < wka ... @ yahoo.comwrote:
On Mar 5, 9:12 am, "W Karas" <wka...@yahoo.comwrote:

如果,
概念的恐惧因素会略微减少吗?
而不是:
Would the fear factor for concepts be slightly reduced if,
instead of:



[现有语法的示例]

[snip example of existing syntax]


a新增用::使用概念/

概念图与类接口更加一致:
a new usage of :: was added to make concepts/
concept maps more consistent with class interfaces:


概念C< typename T>

{

typename S

int mem();

int :: nonmem();

};
concept C<typename T>
{
typename S
int mem();
int ::nonmem();
};



[snip]


我从未见过原始邮件,所以我会回复此第一部分。


使概念语法与类接口更加一致不会让b $ b帮助程序员更好地理解概念。它可能会减少最初的焦虑,因为概念看起来像面向对象的接口,但是相似之处只会是肤浅的。概念支持

不同的编程范例---泛型编程---以及我所看到的关于概念的大部分混淆来自试图想到的概念/>
它们是面向对象的术语。新的想法和构造应该有新的语法,以强调它们与现有的想法/

构造不同。有时句法相似性可能是一件好事,但是当它导致许多不正确的假设时,它们就不会出现。

[snip]

I never saw the original message, so I''ll reply to this part first.

Making concept syntax more consistent with class interfaces would not
help programmers understand concepts any better. It may reduce initial
anxiety, because concepts would look like object-oriented interfaces,
but the resemblance would only be skin-deep. Concepts support a
different programming paradigm---Generic Programming---and much of the
confusion I''ve seen about concepts comes from attempts to think of
them in object-oriented terms. New ideas and constructs should have
new syntax, to emphasize that they are different from existing ideas/
constructs. Sometimes syntactic similarity can be a good thing, but
not when it leads to many incorrect assumptions.


(或者,一个保留字概念可以用两个替换为:b $ b代替单个类型

概念的代数和几何代表多种类型

概念。这样可以避免无处不在的几何中的
::。
(Or, the one reserve word "concept" could be
replaced with two: "algebra" for single-type
concepts, and "geometry" for multi-type
concepts. This would avoid the ubiquitous
:: in geometries.)



我的印象是,许多程序员会对代数做出反应,而b&b和几何代价很高。作为特定实体的关键字。理论上讲,概念是多分类代数,多分类代数。但我们已被禁止

在公开场合说出这句话:

My impression is that many programmers would react badly to "algebra"
and "geometry" as keywords for specific entities. Concepts are,
theoretically speaking, "multi-sorted algebras," but we''ve been banned
from saying that phrase in public :)


另一个想法,不一定依赖于

以上,将允许使用现有概念定义类接口

。如果C是

a概念,一个可能的sytax可能是:


class X使用C

{

// ...未申报的其他内容

//由C ...

};
Another thought, not necessarily depedent on the
above, would be to allow class interfaces to
be defined using existing concepts. If C is
a concept, one possible sytax could be:

class X using C
{
// ... additional stuff not declared
// by C ...
};



我们已经考虑过这样的事情,但有两个原因我们

不包括它:


- 它再次以

方式混合面向对象和通用编程思想,这将导致混乱。我保证,在向观众展示如上所述的例子后,我会得到两个问题:(1)

为什么我不能只使用'' :''继承自C? (2)我可以声明一个类型为C *的

变量吗?如果没有

假设概念只是另一种面向对象的b
编程(它们不是),那么这两个问题都不会出现,我们需要非常小心不要给予

它们的印象。


- 如果你想要X满足C的要求,写一个concept_map

C x。然后,你干净地分开X是什么。 (即,它是数据成员,

成员函数,超类等),从X映射到C。


干杯,

Doug


---

[comp.std.c ++经过审核。要提交文章,请尝试发布]

[您的新闻阅读器。如果失败,请使用mailto:st ***** @ ncar.ucar.edu]

[---请在发布前查看常见问题解答。 ---]

[常见问题: http:/ /www.comeaucomputing.com/csc/faq.html ]

We''ve thought about something like this, but there are two reasons we
did not include it:

- It again mixes object-oriented and generic programming ideas in a
way that will lead to confusion. I guarantee that, after showing an
example like the above to an audience, I will get two questions: (1)
why can''t I just use '':'' to inherit from C? and (2) can I declare a
variable of type C*? Neither question would arise without the
assumption that concepts are just another take on object-oriented
programming (they aren''t), and we need to be very careful not to give
the impression that they are.

- If you want X to meet the requirements of C, write a concept_map
C<X>. Then, you cleanly separate what X "is" (i.e., it''s data members,
member functions, superclasses, etc.) from how X maps onto a C.

Cheers,
Doug

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


这篇关于概念的语法建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆