Re: Can you explain this?

2014-08-21 Thread Colin via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 20:18:15 UTC, Dicebot wrote: On Wednesday, 20 August 2014 at 20:01:05 UTC, Colin wrote: I see 3 distinct parts playing a role in my confusion: A) The 'is' keyword. What does it do when you have is(expression); http://dlang.org/expression.html#IsExpression It

Can you explain this?

2014-08-20 Thread Colin via Digitalmars-d-learn
Hi, I'm implementing some template checks on some types I'm using in a project, and went to phobos for some indications on how to use them. In std.range, I see this construct quite a bit: template isInputRange(R) { enum bool isInputRange = is(typeof( (inout int = 0) { R

Re: Can you explain this?

2014-08-20 Thread Justin Whear via Digitalmars-d-learn
On Wed, 20 Aug 2014 20:01:03 +, Colin wrote: It looks veryhacky. I see 3 distinct parts playing a role in my confusion: A) The 'is' keyword. What does it do when you have is(expression); B) typeof( expression ); whats this doing? Particularly when the expression its acting on is a

Re: Can you explain this?

2014-08-20 Thread Dicebot via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 20:01:05 UTC, Colin wrote: I see 3 distinct parts playing a role in my confusion: A) The 'is' keyword. What does it do when you have is(expression); http://dlang.org/expression.html#IsExpression It is a tool for type checking. It has many options but plain

Re: Can you explain this?

2014-08-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 20:12:58 UTC, Justin Whear wrote: On Wed, 20 Aug 2014 20:01:03 +, Colin wrote: It looks veryhacky. I see 3 distinct parts playing a role in my confusion: A) The 'is' keyword. What does it do when you have is(expression); B) typeof( expression ); whats

Re: Can you explain this?

2014-08-20 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 20:39:42 UTC, Jonathan M Davis wrote: is(typeof(foo)) and __traits(compiles, foo) are not the same. The first tests for the existence of the symbol, whereas the second checks whether the code will actually compile. Is that even true? I mean, are you just

Re: Can you explain this?

2014-08-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 21:06:49 UTC, monarch_dodra wrote: On Wednesday, 20 August 2014 at 20:39:42 UTC, Jonathan M Davis wrote: is(typeof(foo)) and __traits(compiles, foo) are not the same. The first tests for the existence of the symbol, whereas the second checks whether the code