Overloads not returning appropriate info. [Field reflunkory]

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Apr 10 23:43:36 UTC 2019


On Wed, Apr 10, 2019 at 11:05:27PM +0000, Adam D. Ruppe via Digitalmars-d-learn wrote:
> On Wednesday, 10 April 2019 at 19:29:13 UTC, Alex wrote:
> > I wonder if there are some interesting patterns of nesting is's?
> > 
> > is(...is(...is(...)...)...)
> 
> No, at least not like that. You'd get nothing out of it, even if you
> made it work.
> 
> But, I have in the past nested static ifs with different is things in
> order to handle very complex patterns that are difficult to express in
> one.
> 
> I can't remember what those are right now though... but if one level
> fails, you might do
> 
> static if(is( something ))
>   static if(is( details )) {
> 
>   }
> 
> to drill down. But while I know I have done this before, it is rare
> enough that I cannot recall it!

It happens when your static if condition has two or more clauses, and
the compilability of one of the later clauses depend on the truth of a
previous clause. Static if conditions do respect && short-circuit
evaluation, but they do not allow you to bypass compilability, so if you
have something like:

	static if (A & B) { ... }

where B is not compilable unless A is true, then you cannot write it
this way, and have to nest it like you wrote above.


T

-- 
We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare.  Now, thanks to the Internet, we know this is not true. -- Robert Wilensk


More information about the Digitalmars-d-learn mailing list