On Mon, Nov 14, 2011 at 1:29 PM, Timon Gehr <span dir="ltr"><<a href="mailto:timon.gehr@gmx.ch">timon.gehr@gmx.ch</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 11/14/2011 08:47 PM, Andrei Alexandrescu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 11/14/11 1:15 AM, Timon Gehr wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Looks good, I think this is the right direction.<br>
<br>
Nitpicks:<br>
<br>
1.<br>
<br>
// Type deduction works for function results. This is important for<br>
generic<br>
// functions, such as min below, which works correctly for all comparable<br>
// types.<br>
auto min(T1, T2)(T1 lhs, T2 rhs) {<br>
return rhs < lhs ? rhs : lhs;<br>
}<br>
<br>
It does not. The two types need to have a common type as well.<br>
</blockquote>
<br>
It's difficult to be concise and complete simultaneously. The underlying<br>
assumption is that if two types are comparable, they also have a common<br>
type.<br>
</blockquote>
<br></div>
hm, maybe call the them 'compatible comparable types'?<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2.<br>
<br>
The scope statement example should actually show transactional code.<br>
Otherwise the poor reader feels fooled into clicking "See example".<br>
Using scope(exit) to write something at function exit is useful for<br>
debugging, but scope(failure) is the real thing that is important to<br>
show.<br>
</blockquote>
<br>
Good point.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
3.<br>
<br>
If contract inheritance is to be promoted on the front page (and it is<br>
certainly something that may attract developers), it should actually<br>
work.<br>
</blockquote>
<br>
Absolutely.<br>
</blockquote>
<br></div>
There has been disagreement on whether or not my bug report on the matter was valid.<br>
<br>
What it means for your example:<br>
<br>
// Interfaces and classe<br>
interface Printable {<br>
    void print(uint level)<br>
    in { assert(level > 0); } // contract is part of the interface<br>
}<br>
<br>
// Interface implementation<br>
class Widget : Printable {<br>
    void print(uint level) { ... }<br>
}<br>
<br>
void main(){<br>
    Widget w = new Widget();<br>
    w.print(0); // passes through, but should not<br>
}<br>
<br>
Can you state in the issue tracker that the bug report is valid?<br>
<a href="http://d.puremagic.com/issues/show_bug.cgi?id=6856" target="_blank">http://d.puremagic.com/issues/<u></u>show_bug.cgi?id=6856</a><div class="im"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
4.<br>
<br>
If we can find a less buzzy word than 'Multi-paradigm power' to describe<br>
D's multi-paradigm power, that would be nice, but I am also fine with<br>
the current state of affairs.<br>
<br>
5.<br>
<br>
The most important language features are not displayed at all. Where are<br>
Metaprogramming, CTFE and code generation? It sure is hard to come up<br>
with a short but convincing example, but I think we should try to.<br>
</blockquote>
<br>
Those would be under the multi-paradigm thingie.<br>
<br>
</blockquote>
<br></div>
Ok. Maybe there could be a few LOC demonstrating the 'recurrence' function generating a few fibonacci numbers. I think it is a nice showcase, although I have never needed that particular function in real code :o). It has also the potential of showing Phobos' lazy functional style features. But unfortunately, most functional programmers will shriek for a moment when they see the argument order of 'take'.<br>


<br>
<br>
</blockquote></div><br><div>I think that's a good idea.  While learning D I became impressed with it when I solved Project Euler problem 2 ("By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.") with:</div>
<div><br></div><div>auto answer = reduce!"a + b"(filter!"a % 2 == 0"(until!"a > 4_000_000"(recurrence!"a[n-1] + a[n-2]"(1, 1))));</div><div><br></div><div>It'd look better with UFCS but it's still rather neat I think.</div>