December 03, 2018
On Tue, Dec 04, 2018 at 12:59:00AM +0000, Neia Neutuladh via Digitalmars-d wrote:
> On Mon, 03 Dec 2018 16:02:30 -0800, H. S. Teoh wrote:
> > Furthermore, it's not just off by 1, since i=1 is a redundant case. The loop really ought to start with 2.
> 
> factorial(0) is 1 because it's the product of an empty sequence.

No doubt, but the loop should start at 2 because the first two elements of the sequence are 1, and it's a waste of computation to multiply that by 1 yet again.


T

-- 
Without geometry, life would be pointless. -- VS
December 04, 2018
On Mon, 2018-12-03 at 23:42 +0000, Q. Schroll via Digitalmars-d wrote:
> […]
> 
> ulong factorial(ulong n) {
>    ulong result = 1;
>    foreach (i; 0 .. n) result *= i; // off by one.
>    return result;
> }
> 
> Even the best make mistake ;)

Being serious for a moment: anyone implementing factorial using ulong is doing it wrong.  std.bigint.BigInt is the only type that makes sense in a D implementation of factorial – also fibonacci.

And remember, these calculations are actually required in many bioinformatics
and hedge fund models. Trust me on this, I found out the hard way presenting
Python workshops to such folk. Fortunately, in Python int means either
hardware int or software "big integer" depending on value. Except when using
NumPy which is when things get tricky.

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



December 04, 2018
On Saturday, 1 December 2018 at 21:53:00 UTC, Walter Bright wrote:
> I tried hard to make them not special in D, they were just arrays.

Yeah, a very elegant design, like it a lot.
December 04, 2018
On Tue, Dec 04, 2018 at 07:31:28AM +0000, Russel Winder via Digitalmars-d wrote:
> On Mon, 2018-12-03 at 23:42 +0000, Q. Schroll via Digitalmars-d wrote:
> > […]
> > 
> > ulong factorial(ulong n) {
> >    ulong result = 1;
> >    foreach (i; 0 .. n) result *= i; // off by one.
> >    return result;
> > }
> > 
> > Even the best make mistake ;)
> 
> Being serious for a moment: anyone implementing factorial using ulong is doing it wrong.  std.bigint.BigInt is the only type that makes sense in a D implementation of factorial – also fibonacci.
[...]

And this is where a simple code example explodes into a hairy over-engineered mess. Totally correct, mind you, but totally missing the point of being an example of D code. :-P


T

-- 
What's an anagram of "BANACH-TARSKI"?  BANACH-TARSKI BANACH-TARSKI.
December 04, 2018
On 12/3/18 6:42 PM, Q. Schroll wrote:
> On Friday, 30 November 2018 at 19:34:58 UTC, Andrei Alexandrescu wrote:
>> Over the past few months, Walter, Mike, and myself have been working on a draft submission for the HOPL 2020 conference (History of Programming Languages).
>>
>> The submission proceeds in several stages. Currently we've been through one round of preliminary review. Here is the current draft:
>>
>> http://erdani.com/hopl2020-draft.pdf
>>
>> We'd appreciate feedback and additional historical details.
>>
>>
>> Thanks,
>>
>> Andrei (on behalf of Walter and Mike as well)
> 
> ulong factorial(ulong n) {
>    ulong result = 1;
>    foreach (i; 0 .. n) result *= i; // off by one.
>    return result;
> }
> 
> Even the best make mistake ;)

Ouch, thanks.
December 04, 2018
On Friday, 30 November 2018 at 19:34:58 UTC, Andrei Alexandrescu wrote:
> Over the past few months, Walter, Mike, and myself have been working on a draft submission for the HOPL 2020 conference (History of Programming Languages).
>
> The submission proceeds in several stages. Currently we've been through one round of preliminary review. Here is the current draft:
>
> http://erdani.com/hopl2020-draft.pdf
>
> We'd appreciate feedback and additional historical details.
>
>
> Thanks,
>
> Andrei (on behalf of Walter and Mike as well)

The timeline does not have when work started on D 2.0 and when the first release was or what have you.
December 04, 2018
On 2018-12-02 16:21, Jonathan M Davis wrote:

> Tango was eventually ported to D2, but it hasn't been maintained. I tried to
> compile it to benchmark its XML parser against dxml when preparing my dconf
> talk this year, and Tango wouldn't compile anymore.

The latest tested version of DMD which compiles Tango is supposed to be 2.068.

-- 
/Jacob Carlborg
December 04, 2018
On Tuesday, 4 December 2018 at 19:04:35 UTC, jmh530 wrote:
> The timeline does not have when work started on D 2.0 and when the first release was or what have you.

D 2.0 started in 1999.

The truth is D has just been constantly evolving from the beginning. All D1 is was an arbitrary snapshot on the path, which briefly branched off with just bug fixes (of course, one user's bug fix is another user's breaking change).

Then, the D language continued evolving the same has it has the last 8 years, just now that one random snapshot got labeled D1, the ongoing evolution got rebranded D2, since it would sound silly is D 0.xxx was considered newer than 1.0.


The officially labeled 2.0 came out in July 2007, six months after the officially labeled 1.0, but really that is just because of a brief freeze to focus more on bugs than any real "it's done" materializing.
December 04, 2018
On 12/4/18 2:23 PM, Adam D. Ruppe wrote:
> On Tuesday, 4 December 2018 at 19:04:35 UTC, jmh530 wrote:
>> The timeline does not have when work started on D 2.0 and when the first release was or what have you.
> 
> D 2.0 started in 1999.
> 
> The truth is D has just been constantly evolving from the beginning. All D1 is was an arbitrary snapshot on the path, which briefly branched off with just bug fixes (of course, one user's bug fix is another user's breaking change).
> 
> Then, the D language continued evolving the same has it has the last 8 years, just now that one random snapshot got labeled D1, the ongoing evolution got rebranded D2, since it would sound silly is D 0.xxx was considered newer than 1.0.
> 
> 
> The officially labeled 2.0 came out in July 2007, six months after the officially labeled 1.0, but really that is just because of a brief freeze to focus more on bugs than any real "it's done" materializing.

From my memory, I remember the big thing of D 2.0 was immutable/const. Essentially there was no way to shoehorn immutable (then called invariant) and const into the D compiler without breaking everything (and as one who tried to port Tango to D2, I experienced this first-hand), so the fork was made. I'm sure there was a definitive point at which this was decided. Unfortunately, I don't think DMD was even using subversion back then, so the code history may be hard to construct.

-Steve
December 04, 2018
On Tuesday, 4 December 2018 at 19:37:04 UTC, Steven Schveighoffer wrote:
> From my memory, I remember the big thing of D 2.0 was immutable/const.

Well, it is certainly the most definitive change of the era, but if not that, it would have just been something else - D has always been evolving and that wasn't going to actually stop.

D1 wasn't some designed end point that reached completion... it was just a random spot along the path.

> Unfortunately, I don't think DMD was even using subversion back then, so the code history may be hard to construct.

The changelog can help piece it together.