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

2025-07-29 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 23:48:58 UTC, H. S. Teoh wrote: `i` is immutable, so it's illegal to use mutating operations like ~= on it. @luna The question should be if programming in d (page 177 https://ddili.org/ders/d.en/Programming_in_D.pdf) should be authoritive here It is possible t

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

2025-07-29 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 29, 2025 at 10:57:50PM +, Brother Bill via Digitalmars-d-learn wrote: > ``` > import std.stdio; > > immutable int[] i; > > shared static this() { > writeln("In shared static this()"); > i ~= 43; > } `i` is immutable, so it's illegal to use mutating operations like ~=

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

2025-07-29 Thread Luna via Digitalmars-d-learn
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()"); writeln("i: ", i); } ``` Error messages: C:\D\dmd2\w

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

2025-07-29 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 23:18:18 UTC, Brother Bill wrote: Your changes do work, but at the cost of making i NOT deeply immutable: no assignment, no changing any elements, no appending, no setting length. if you insit on the type id suggest this code then ```d import std.stdio; immutabl

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()");

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

2025-07-29 Thread monkyyy via Digitalmars-d-learn
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()"); writeln("i: ", i); } ``` Error messages: C:\D\dmd2\w

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: Cannot instantiate ReturnType with lambda

2025-07-29 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 21:47:05 UTC, not monkyyy wrote: Who are you?

Re: Cannot instantiate ReturnType with lambda

2025-07-29 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 29 July 2025 at 20:34:27 UTC, Nick Treleaven wrote: On Monday, 28 July 2025 at 18:51:23 UTC, monkyyy wrote: On Monday, 28 July 2025 at 11:18:48 UTC, Nick Treleaven wrote: The solution I offered at the time while still fundamentally flawed was far more robust then what was merged W

Re: Cannot instantiate ReturnType with lambda

2025-07-29 Thread not monkyyy via Digitalmars-d-learn
On Monday, 28 July 2025 at 18:51:23 UTC, monkyyy wrote: The solution I offered at the time while still fundamentally flawed was far more robust Sounds a lot like… Whack-a-moleing

Re: Cannot instantiate ReturnType with lambda

2025-07-29 Thread Nick Treleaven via Digitalmars-d-learn
On Monday, 28 July 2025 at 18:51:23 UTC, monkyyy wrote: On Monday, 28 July 2025 at 11:18:48 UTC, Nick Treleaven wrote: The solution I offered at the time while still fundamentally flawed was far more robust then what was merged What solution?