BCS:
I like the idea, but how should it interact with overloaded templates?
The syntax/semantics I have shown is just a starting point, there are probably
way better ways to reach the same goal. For example a kind of run-time
error/exception for templates that shows an error message and
Leandro Lucarella llu...@gmail.com wrote:
it would be nice
to have some sort of way to tell the compiler to write the template
constraints for us (the obvious ones at least, there might be other
template constraints desired besides the ones the ones the compiler can
figure out). This way, the
Simen kjaeraas Wrote:
Leandro Lucarella llu...@gmail.com wrote:
it would be nice
to have some sort of way to tell the compiler to write the template
constraints for us (the obvious ones at least, there might be other
template constraints desired besides the ones the ones the compiler can
Simen kjaeraas wrote:
Leandro Lucarella llu...@gmail.com wrote:
it would be nice
to have some sort of way to tell the compiler to write the template
constraints for us (the obvious ones at least, there might be other
template constraints desired besides the ones the ones the compiler can
figure
Don nos...@nospam.com wrote:
This can be trivially shown to be NP-complete.
void bar(T)()
{
static if ( big_function!T) {
T t;
t.flabbergast( );
}
}
Compiler cannot determine if T needs flabbergast(), unless it evaluates
big_function. Which can be arbitrarily
Yao G.:
Something I would like to see with template constraints, is the ability to
show text messages, like when static if is used.
This is a problem I too have.
In D1 I used to write code like:
template Foo(T) {
static assert(condition1, error message1);
static assert(condition2, error
Hello bearophile,
A syntax like the following allows to add the user-defined error
messages too, but it's bad looking, so probably something quite better
can be invented:
template Foo(T)
if (condition1) else pragma(msg, error message1)
if (condition2) else pragma(msg, error message2) {
}
I
http://www.drdobbs.com/blog/archives/2010/06/constrained_tem.html
Anyone want to do the honors and post to reddit, ycombinator, etc. ?
Walter Bright, el 13 de junio a las 12:01 me escribiste:
http://www.drdobbs.com/blog/archives/2010/06/constrained_tem.html
Anyone want to do the honors and post to reddit, ycombinator, etc. ?
Nice article, but when I read:
T gcd(T)(T a, T b)
if (is(typeof(a % b)))
Andrei used that idiom quite extensive in Phobos, unfortunately, I dare to
say. It makes the code a lot harder to read. But the alternative, using
__traits(compiles, ... ) is even worse IMO, because even as is a little
more obvious, is quite verbose.
Something I would like to see with
Yao G. wrote:
Maybe I did something wrong at the moment I submitted the article. :(
I sent an email to the reddit moderators asking what's up with that.
Leandro Lucarella wrote:
Walter Bright, el 13 de junio a las 12:01 me escribiste:
http://www.drdobbs.com/blog/archives/2010/06/constrained_tem.html
Anyone want to do the honors and post to reddit, ycombinator, etc. ?
Nice article, but when I read:
T gcd(T)(T a, T b)
if
Walter Bright wrote:
Yao G. wrote:
Maybe I did something wrong at the moment I submitted the article. :(
I sent an email to the reddit moderators asking what's up with that.
I posted this as a test:
http://www.reddit.com/r/reddit.com/comments/cemtc/tech_talk_tips/
Andrei
It is now displayed in the front page.
http://www.reddit.com/r/programming/
On Sun, 13 Jun 2010 15:42:13 -0500, Walter Bright
newshou...@digitalmars.com wrote:
Yao G. wrote:
Maybe I did something wrong at the moment I submitted the article. :(
I sent an email to the reddit moderators
Walter Bright newshou...@digitalmars.com wrote in message
news:hv39tt$87...@digitalmars.com...
http://www.drdobbs.com/blog/archives/2010/06/constrained_tem.html
Anyone want to do the honors and post to reddit, ycombinator, etc. ?
and a line number pointing into the template body. The error is
Leandro Lucarella llu...@gmail.com writes:
When you get used to this idiom, it might not look to bad, but I'm
seeing people new to D wonder why in the hell was that syntax used?
while they try to decode what is(typeof()) means.
The syntax doesn't bother me as much as the suggestion to repeat
Hello Ali,
The method that I learned from Phobos is not the best, but at least
the function interface reads better:
T gcd(T)(T a, T b)
if (supports_modulus!T)
{
T result;
// ...
return result;
}
That makes it clear that T must support the modulus operation.
Here is how supports_modulus may
Hello Nick,
Walter Bright newshou...@digitalmars.com wrote in message
news:hv39tt$87...@digitalmars.com...
http://www.drdobbs.com/blog/archives/2010/06/constrained_tem.html
Anyone want to do the honors and post to reddit, ycombinator, etc. ?
and a line number pointing into the template
Yao G. wrote:
It is now displayed in the front page.
http://www.reddit.com/r/programming/
On Sun, 13 Jun 2010 15:42:13 -0500, Walter Bright
newshou...@digitalmars.com wrote:
Yao G. wrote:
Maybe I did something wrong at the moment I submitted the article. :(
I sent an email to the
Nick Sabalausky wrote:
and a line number pointing into the template body. The error is being
reported as occurring somewhere other than where the actual problem is
That would be a good place to point out that recent versions of DMD display
template instantiation traces upon template
Walter Bright wrote:
Nick Sabalausky wrote:
and a line number pointing into the template body. The error is being
reported as occurring somewhere other than where the actual problem is
That would be a good place to point out that recent versions of DMD
display template instantiation traces
Andrei Alexandrescu seewebsiteforem...@erdani.org wrote in message
news:hv46bv$1kp...@digitalmars.com...
Walter Bright wrote:
Nick Sabalausky wrote:
and a line number pointing into the template body. The error is being
reported as occurring somewhere other than where the actual problem is
Walter Bright wrote:
Yao G. wrote:
It is now displayed in the front page.
http://www.reddit.com/r/programming/
On Sun, 13 Jun 2010 15:42:13 -0500, Walter Bright
newshou...@digitalmars.com wrote:
Yao G. wrote:
Maybe I did something wrong at the moment I submitted the article. :(
I sent
23 matches
Mail list logo