<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">No overload, receives a tuple, and assumes that static-if the first<br>
tuple item is IMPLICITLY CONVERTIBLE to a Duration, I must be calling<br>
the 'overload'...<br>
<br>
I guess this means I can never pass a Duration in a message to the<br>
non-timeout receive()... or anything that is implicitly convertible to a<br>
Duration.<br>
</div></div></blockquote>
<br>
Sure, receive cannot be called with duration. You pass callbacks to it, not Durations. Callbacks are never implicitly convertible to Durations, so that is fine.</blockquote><div><br></div><div>Ah crap, I DID miss the magic detail in checkops() you mentioned below. That clears it up.</div>
<div>However I still feel this construct is quite dangerous. I'm looking at it from a programming 'pattern' point of view rather than the details of this case specifically. I don't know if I've illustrated my concern clearly though...</div>
<div> <div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This would seem to be a very obscure hidden bug to me. Is this a common<br>
pattern in D?<br>
</blockquote>
<br></div>
I don't see a 'pattern'.</div><div><br></div><div>I refer to the concept ('pattern' if you will) of receiving a tuple of args, and then comparing the first as a specific type instead of using a function overload.</div>
<div>ie. in this example with the optional first Duration parameter, but with the assumption that the following parameters may be of any type. This 'pattern' may lead to a bug where if the first Duration parameter were not desired, but the second parameter happened to be any type that implicitly converted to a Duration, then the wrong code path could be taken without the programmers knowledge... I hope that makes sense. :/</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I certainly wouldn't want to be tracking down this bug on build<br>
night... Is there something I've missed here? Some sort of safeguard<br>
I've overlooked?<br>
</blockquote>
<br></div>
Have a look at the checkops template. It catches your case.<br>
I just saw it contains another bug though:<br>
<br>
static assert( is( t1 == function ) || is( t1 == delegate ) );<br>
<br>
Obviously, the writer meant to check for function pointers and delegates. This is not what it does. Borken. I think the language should be fixed here.<br></blockquote><div><br></div><div>I can't see the problem >_<</div>
<div>I must confess, I'm finding some D code I look at REALLY hard to follow... like this code for instance (mbox.get()). Granted, I'm not yet very good at reading D code, which often appears nothing at all like C/C++, but I'm hoping the language is overall a <i>simplification</i> over C/C++ ;)</div>
</div>