Re: Providing implicit conversion of

2024-01-21 Thread Danilo via Digitalmars-d-learn
On Sunday, 21 January 2024 at 16:05:40 UTC, Gavin Gray wrote: The following code: ulong charlie = 11; long johnstone = std.algorithm.comparison.max(0, -charlie); writeln(format!"johnstone %s"(johnstone)); Results in (without any warning(s)): johnstone -11 However you choose to look at

Re: Providing implicit conversion of

2024-01-21 Thread thinkunix via Digitalmars-d-learn
Gavin Gray via Digitalmars-d-learn wrote: The following code:   ulong charlie = 11;   long johnstone = std.algorithm.comparison.max(0, -charlie);   writeln(format!"johnstone %s"(johnstone)); Results in (without any warning(s)): johnstone -11 However you choose to look at it, this means -11

Re: Providing implicit conversion of

2024-01-21 Thread bachmeier via Digitalmars-d-learn
On Monday, 22 January 2024 at 01:14:06 UTC, Steven Schveighoffer wrote: On Sunday, 21 January 2024 at 16:05:40 UTC, Gavin Gray wrote: The following code: ulong charlie = 11; long johnstone = std.algorithm.comparison.max(0, -charlie); writeln(format!"johnstone %s"(johnstone)); Results in

Re: Providing implicit conversion of

2024-01-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 21 January 2024 at 16:05:40 UTC, Gavin Gray wrote: The following code: ulong charlie = 11; long johnstone = std.algorithm.comparison.max(0, -charlie); writeln(format!"johnstone %s"(johnstone)); Results in (without any warning(s)): johnstone -11 However you choose to look at

Re: vector crash

2024-01-21 Thread zjh via Digitalmars-d-learn
On Sunday, 21 January 2024 at 18:38:42 UTC, atzensepp wrote: What if you add more lines to the file. Does it crash then later? It's a problem with `vectors`. `vector!string` has a problem , I just use 'string []', and it's OK. The `vector` is unstable, possibly because the `later data`

Re: Delegates and values captured inside loops

2024-01-21 Thread An Pham via Digitalmars-d-learn
On Sunday, 21 January 2024 at 20:13:38 UTC, An Pham wrote: On Saturday, 20 January 2024 at 15:59:59 UTC, Anonymouse wrote: I remember reading this was an issue and now I ran into it myself. ```d import std.stdio; void main() { auto names = [ "foo", "bar", "baz" ]; void delegate()[]

Re: Delegates and values captured inside loops

2024-01-21 Thread atzensepp via Digitalmars-d-learn
In Ocaml this would look as: ```d let names =["foo";"bar";"baz"] in let funmap = List.map ( fun name -> ( fun () -> print_endline name)) names in List.iter ( fun f -> f () ) funmap ;; ~ ``` I think in the D-example it is basically one function and not 3.

Re: Delegates and values captured inside loops

2024-01-21 Thread atzensepp via Digitalmars-d-learn
On Sunday, 21 January 2024 at 20:13:38 UTC, An Pham wrote: On Saturday, 20 January 2024 at 15:59:59 UTC, Anonymouse wrote: I remember reading this was an issue and now I ran into it myself. ```d import std.stdio; void main() { auto names = [ "foo", "bar", "baz" ]; void delegate()[]

Re: Delegates and values captured inside loops

2024-01-21 Thread An Pham via Digitalmars-d-learn
On Saturday, 20 January 2024 at 15:59:59 UTC, Anonymouse wrote: I remember reading this was an issue and now I ran into it myself. ```d import std.stdio; void main() { auto names = [ "foo", "bar", "baz" ]; void delegate()[] dgs; foreach (name; names) { dgs ~= () =>

Re: Delegates and values captured inside loops

2024-01-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 21 January 2024 at 14:52:45 UTC, Renato wrote: On Saturday, 20 January 2024 at 16:53:12 UTC, ryuukk_ wrote: This is the workaround according to: https://issues.dlang.org/show_bug.cgi?id=21929#c9 Go used to have the same issue [but they fixed

Re: vector crash

2024-01-21 Thread atzensepp via Digitalmars-d-learn
On Sunday, 21 January 2024 at 03:54:35 UTC, zjh wrote: On Thursday, 18 January 2024 at 03:07:13 UTC, zjh wrote: ```d void toV(string a,ref vector!string b){ auto f=File(a,"r"); while(!f.eof()){ string l=strip(f.readln());push(b,l); } Qwk(b); }// ``` There is an issue

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-21 Thread Daniel Kozak via Digitalmars-d-learn
Dne so 20. 1. 2024 21:21 uživatel Renato via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> napsal: > On Saturday, 20 January 2024 at 19:45:19 UTC, Daniel Kozak wrote: > > On Sat, Jan 20, 2024 at 2:11 PM Renato via Digitalmars-d-learn > > < digitalmars-d-learn@puremagic.com> wrote: > >

Providing implicit conversion of

2024-01-21 Thread Gavin Gray via Digitalmars-d-learn
The following code: ulong charlie = 11; long johnstone = std.algorithm.comparison.max(0, -charlie); writeln(format!"johnstone %s"(johnstone)); Results in (without any warning(s)): johnstone -11 However you choose to look at it, this means -11 > 0 (regardless of all arguments concerning

Re: macOS Sonoma Linker Issue

2024-01-21 Thread Renato via Digitalmars-d-learn
On Saturday, 20 January 2024 at 21:12:12 UTC, ryuukk_ wrote: dub might not be passing this flag down to dependencies.. Try this env variable: ``LDFLAGS="$LDFLAGS -Wl,-ld_classic" dub build`` That didn't help. If that doesn't work, try this one: ``MACOSX_DEPLOYMENT_TARGET=11 dub build``

Re: Delegates and values captured inside loops

2024-01-21 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 20 January 2024 at 16:32:42 UTC, FeepingCreature wrote: ``` foreach (name; names) { dgs ~= ((name) => () => writeln(name))(name); } ``` lol Thanks, I'll try that.

Re: Error "Outer Function Context is Needed" when class declared in unittest

2024-01-21 Thread Jim Balter via Digitalmars-d-learn
On Thursday, 5 January 2023 at 13:47:24 UTC, Adam D Ruppe wrote: On Thursday, 5 January 2023 at 13:27:23 UTC, Vijay Nayar wrote: Why is this error only found when declaring a class in the unittest? A unittest is just a special function, it can run code and have local variables. classes and