Re: Programming in D, page 155. shared static this() fails

2025-07-29 Thread Brother Bill via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 23:03:41 UTC, monkyyy wrote: On Tuesday, 29 July 2025 at 22:57:50 UTC, Brother Bill wrote: ``` import std.stdio; immutable int[] i; shared static this() { writeln("In shared static this()"); i ~= 43; } void main() { writeln("In main()");

Programming in D, page 155. shared static this() fails

2025-07-29 Thread Brother Bill via Digitalmars-d-learn
``` import std.stdio; immutable int[] i; shared static this() { writeln("In shared static this()"); i ~= 43; } void main() { writeln("In main()"); writeln("i: ", i); } ``` Error messages: C:\D\dmd2\windows\bin64\..\..\src\druntime\import\core\internal\array\appe

Re: Examples from "Programming in D" book

2025-07-26 Thread Brother Bill via Digitalmars-d-learn
On Saturday, 26 July 2025 at 17:48:43 UTC, Monkyyy wrote: On Friday, 25 July 2025 at 21:27:55 UTC, Brother Bill wrote: On Friday, 25 July 2025 at 18:47:19 UTC, Ali Çehreli wrote: On 7/25/25 4:10 AM, Brother Bill wrote: > On Friday, 25 July 2025 at 10:56:08 UTC, novicetoo wrote: >> check https:/

Re: Examples from "Programming in D" book

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
On Friday, 25 July 2025 at 18:47:19 UTC, Ali Çehreli wrote: On 7/25/25 4:10 AM, Brother Bill wrote: > On Friday, 25 July 2025 at 10:56:08 UTC, novicetoo wrote: >> check https://ddili.org/ders/d.en/index.html >> under "Code samples as a .zip file" > > Checked that out. These are not in order, nor

Re: Inherited constructor

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
On Friday, 25 July 2025 at 03:57:34 UTC, Andy Valencia wrote: On Friday, 25 July 2025 at 02:40:35 UTC, H. S. Teoh wrote: In D, constructors are not inherited, so yes, unfortunately you have to write a forwarding ctor that passes the arguments along to the base class. My OO worldview goes bac

Re: Examples from "Programming in D" book

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
On Friday, 25 July 2025 at 10:56:08 UTC, novicetoo wrote: check https://ddili.org/ders/d.en/index.html under "Code samples as a .zip file" Checked that out. These are not in order, nor exhaustive. I'll create my own code samples, then post them here first.

Eiffel like reports for Design by Contract contracts

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
In Eiffel, it is trivial to get a report for Subject Matter Experts (SMEs) that will provide feedback that the DbC contracts are what they agreed to. It would be nice to have this in D. Does D already have this, or should this be added to DIP Ideas forum? Imagine a sample contract for Vats

Examples from "Programming in D" book

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
Has anyone already published the D examples from the "Programming in D" book? If not, I'll do it, and publish it here first. It would be good to have this on dlang.org for D newbies.

Re: std.random.uniform(1, 101) crashes. Why, and workaround.

2025-07-25 Thread Brother Bill via Digitalmars-d-learn
On Friday, 25 July 2025 at 07:16:55 UTC, evilrat wrote: On Friday, 25 July 2025 at 01:04:31 UTC, Brother Bill wrote: From "Programming in D" book: import std.stdio; import std.random; void main() { int number = uniform(1, 101); writeln("Edit source/app.d to start your proj

Re: Inherited constructor

2025-07-24 Thread Brother Bill via Digitalmars-d-learn
On Thursday, 24 July 2025 at 17:19:17 UTC, Andy Valencia wrote: What is considered the "clean" way to address this error: ``` tst60.d(7): Error: class `tst60.B` cannot implicitly generate a default constructor when base class `tst60.A` is missing a default constructor ``` Yes, this is a toy

std.random.uniform(1, 101) crashes. Why, and workaround.

2025-07-24 Thread Brother Bill via Digitalmars-d-learn
From "Programming in D" book: import std.stdio; import std.random; void main() { int number = uniform(1, 101); writeln("Edit source/app.d to start your project."); } Running it generates: phobos64.lib(random_6ea_855.obj) : error LNK2019: unresolved external sym

Re: D Book page 402 Concurrency FAIL

2016-02-14 Thread Brother Bill via Digitalmars-d-learn
On Sunday, 14 February 2016 at 23:39:33 UTC, cym13 wrote: On Sunday, 14 February 2016 at 22:54:36 UTC, Brother Bill wrote: In "The D Programming Language", page 402, the toy program fails. [...] Can't reproduce with DMD 2.0.70, LDC 0.16.1 or GDC 5.3.0 on Linux x86_64. The code seems to work

D Book page 402 Concurrency FAIL

2016-02-14 Thread Brother Bill via Digitalmars-d-learn
In "The D Programming Language", page 402, the toy program fails. The first fail is that enforce() needs: import std.exception; The second fail is that when debugging, in Visual Studio 2015 Community Edition, it fails with this error: First-change exception: std.format.FormatException Unterm