C++0x Concepts - Dead?
aarti_pl
aarti at interia.pl
Thu Jul 16 15:46:31 PDT 2009
Walter Bright pisze:
> aarti_pl wrote:
>> Walter Bright pisze:
>>> aarti_pl wrote:
>>>> My proposal would make meta programing in D much more intuitive
>>>> (because of using rules - not bunch of corner cases as it is today).
>>>> Unfortunately almost no one from NG commented on that...
>>>
>>> Thank you, but I don't see in your proposal a method that can:
>>>
>>> 1. instantiate templates only if a value argument is prime or odd.
>>>
>>> 2. instantiate templates only on a type which supports addition and
>>> has the method foo.
>>>
>>> Note that C++ Concepts could do (2) but could not do (1).
>>
>> ad.1
>>
>> template normalizedType((T U N : U[N=size_t]) && (N & 1))
>>
>> As it is stated in proposal commas are only syntax sugar for more
>> general form with '&&'.
>
> How do you distinguish a type from an expression?
Type is in fact the same thing as reduced expression. Please look at
grammar. Everything except first type is *OPTIONAL*. So in fact you need
always look for ctexpr (compile time expression) until you find some
logical or grouping operator.
>> ad.2.
>>
>> This case is in fact the same as 1. Because of the fact that A, B, C
>> <=> A && B && C, you can create expressions as you want just using
>> second form with logical operators. In this case you should just use
>> proper compile time reflection mechanism in D to get information about
>> type properties.
>
> class C {
> int opAdd(C);
> }
>
> How would I write the parameter to accept any type that supports
> addition? I want to support int, float, C, etc., without having to
> exhaustively enumerate them.
I will give you another question instead :-)
How would you do currently in D?
(In fact I just forgot how to do it in D now :-) But give me current
syntax and I will rewrite it in my syntax)
BR
Marcin Kuszczak
More information about the Digitalmars-d-announce
mailing list