Re: Ada-Style Range Types with Value Range Propagation in Arithmetic

2014-03-19 Thread Nordlöw
Ideas anyone? I cracked it: auto opBinary(string op, U, string file = __FILE__, int line = __LINE__)(U rhs) { static if (is(U == Bound)) { alias C = CommonType!(T, U.type); Bound!(C, cast(C)m

Ada-Style Range Types with Value Range Propagation in Arithmetic

2014-03-19 Thread Nordlöw
I'm trying to extend my wrapper class Bound to support CTFE Value Range Propagation in primary in opUnary and opBinary similar to what Ada's Range Types. My current try so far for binary arithmetic is auto opBinary(string op, U, U lower_rhs = U.min, U up

Re: reflection over templates

2014-03-19 Thread simendsjo
On 03/19/2014 05:34 PM, Adam D. Ruppe wrote: On Wednesday, 19 March 2014 at 16:10:52 UTC, Dicebot wrote: Wait just a bit more https://github.com/D-Programming-Language/dmd/pull/3380 :) megarox. Make it so. Nice. I have some ugly hacks that's probably full of bugs for this (look at the botto

Re: reflection over templates

2014-03-19 Thread Andrej Mitrovic
On 3/19/14, Adam D. Ruppe wrote: > Is there anything we can do with static if to identify it as a > template? https://github.com/D-Programming-Language/dmd/pull/3380 > And after we determine it is a template, can we extract the > required arguments list like we can with a regular function at > a

reflection over templates

2014-03-19 Thread Adam D. Ruppe
Given: template Foo(string T) { enum Foo = to!int(T); } (or anything else, really) Is there anything we can do with static if to identify it as a template? I tried: static if(is(Foo == template)) {} // nope, basic type expected, not template Note that is(typeof(Foo) == function) {} is ho

Re: reflection over templates

2014-03-19 Thread Adam D. Ruppe
On Wednesday, 19 March 2014 at 16:10:52 UTC, Dicebot wrote: Wait just a bit more https://github.com/D-Programming-Language/dmd/pull/3380 :) megarox. Make it so.

Re: reflection over templates

2014-03-19 Thread Dicebot
Wait just a bit more https://github.com/D-Programming-Language/dmd/pull/3380 :)

Re: reflection over templates

2014-03-19 Thread Dicebot
As a workaround one can use set of relevant trait checks: 1) type is void 2) is not a variable or callable 3) .stringof fits "NAME(ARGS)" pattern

Re: reflection over templates

2014-03-19 Thread Dicebot
On Wednesday, 19 March 2014 at 16:18:17 UTC, Andrej Mitrovic wrote: And after we determine it is a template, can we extract the required arguments list like we can with a regular function at all? Well there's TemplateArgsOf for *instantiations*, but I'm not sure how one would do it with non-in

Re: Why does the following program write the message 'Foo' twice?

2014-03-19 Thread Gary Willoughby
On Wednesday, 19 March 2014 at 10:10:18 UTC, Vladimir Panteleev wrote: If you use rdmd, it will be printed twice, because rdmd invokes dmd once to gather the program's dependencies, and a second time to actually build the program. Yes i'm using rdmd. Thanks.

Re: Why does the following program write the message 'Foo' twice?

2014-03-19 Thread Dicebot
Disregard my comment, Vladimir is right :)

Re: Why does the following program write the message 'Foo' twice?

2014-03-19 Thread Dicebot
On Wednesday, 19 March 2014 at 10:08:50 UTC, Gary Willoughby wrote: Why does the following program write the message 'Foo' twice? void main(string[] args) { pragma(msg, "Foo"); } Once upon compilation and once upon run-time. I don't know if it is intended design but this is how `pragma

Re: Why does the following program write the message 'Foo' twice?

2014-03-19 Thread Vladimir Panteleev
On Wednesday, 19 March 2014 at 10:08:50 UTC, Gary Willoughby wrote: Why does the following program write the message 'Foo' twice? void main(string[] args) { pragma(msg, "Foo"); } The message is not printed by the program, but by the compiler. If you build the program via dmd, the mess

Why does the following program write the message 'Foo' twice?

2014-03-19 Thread Gary Willoughby
Why does the following program write the message 'Foo' twice? void main(string[] args) { pragma(msg, "Foo"); }