Re: books for learning D

2020-01-31 Thread Ron Tarrant via Digitalmars-d-learn
On Wednesday, 29 January 2020 at 11:57:14 UTC, Jan Hönig wrote: I am also curious. Where can i find the revised book. Sorry for the delay, guys. I thought I'd posted the link earlier. Here it is: http://ddili.org/ders/d.en/index.html

Is it possible to use DMD as a library to compile strings at runtime?

2020-01-31 Thread Saurabh Das via Digitalmars-d-learn
I see that DUB has DMD as a library package, but I was not able to understand how to use it. Is it possible to use DMD as a library within a D program to compile a string to machine code and run the compiled code at runtime? Thanks, Saurabh

Re: Cannot implicitly convert expression [[0, -1, 2], [4, 11, 2]] of type int[][] to const(int[2])[]

2020-01-31 Thread MoonlightSentinel via Digitalmars-d-learn
On Friday, 31 January 2020 at 12:37:43 UTC, Adnan wrote: What's causing this? You mixed up the array lengths: const int[3][2] matA = [[0, -1, 2], [4, 11, 2]]; const int[2][3] matB = [[3, -1], [1, 2], [6, 1]]; matA is an SA containing <2> elements of type int[3]. matB is an SA containing <3>

Re: wordladder - code improvement

2020-01-31 Thread mark via Digitalmars-d-learn
I forgot to mention: I know it isn't worth bothering with const/immutable for this tiny example. But I want to learn how to write large D programs, so I need to get into the right habits and know the right things.

Re: books for learning D

2020-01-31 Thread Jan Hönig via Digitalmars-d-learn
On Friday, 31 January 2020 at 10:51:07 UTC, mark wrote: On Wednesday, 29 January 2020 at 11:57:14 UTC, Jan Hönig wrote: On Monday, 13 January 2020 at 16:37:31 UTC, Ron Tarrant wrote: On Monday, 13 January 2020 at 10:28:48 UTC, mark wrote: [...] Actually, Andrei's book has been updated a few

Cannot implicitly convert expression [[0, -1, 2], [4, 11, 2]] of type int[][] to const(int[2])[]

2020-01-31 Thread Adnan via Digitalmars-d-learn
https://wiki.dlang.org/Dense_multidimensional_arrays#Static_arrays describes a way to create static arrays: int[3][3] matrix = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; However my complains that I can't implicitly create static arrays from dynamic arrays. private T[R1][C2]

Re: books for learning D

2020-01-31 Thread mark via Digitalmars-d-learn
On Wednesday, 29 January 2020 at 11:57:14 UTC, Jan Hönig wrote: On Monday, 13 January 2020 at 16:37:31 UTC, Ron Tarrant wrote: On Monday, 13 January 2020 at 10:28:48 UTC, mark wrote: I'm just starting out learning D. Andrei Alexandrescu's "The D Programming Language" is 10 years old, so is

Re: wordladder - code improvement

2020-01-31 Thread dwdv via Digitalmars-d-learn
On 2020-01-31 09:44, mark via Digitalmars-d-learn wrote: I can't use the levenshtien distance because although it is a better solution, [...] Nah, it isn't, sorry for the noise, should have slept before sending the message, was thinking of hamming distance: auto a = "abcd"; auto b =

Re: Constant GC allocations when sending large messages to threads?

2020-01-31 Thread bauss via Digitalmars-d-learn
On Friday, 31 January 2020 at 07:14:30 UTC, cc wrote: On Wednesday, 29 January 2020 at 21:10:53 UTC, Steven Schveighoffer wrote: I'm pretty sure std.concurrency uses Variant to pass message data, which boxes when it gets over a certain size. You are probably crossing that threshold. The

Re: format with floating points GC allocating in DMD 2.090

2020-01-31 Thread bauss via Digitalmars-d-learn
On Friday, 31 January 2020 at 07:20:17 UTC, cc wrote: char[4096] buf; writeln(GC.stats.usedSize); foreach (i; 0 .. 10) { sformat(buf, "%f", 1.234f); writeln(GC.stats.usedSize); } Output with DMD32 D Compiler v2.089.1-dirty (Win10

Re: wordladder - code improvement

2020-01-31 Thread mark via Digitalmars-d-learn
Thanks for your implementation. I can't use the levenshtien distance because although it is a better solution, I want to keep the implementation as compatible with those in the other languages as possible. Your main() is much shorter than mine, but doesn't match the behaviour (and again I

Re: format with floating points GC allocating in DMD 2.090

2020-01-31 Thread Andrea Fontana via Digitalmars-d-learn
On Friday, 31 January 2020 at 08:45:55 UTC, bauss wrote: On Friday, 31 January 2020 at 07:20:17 UTC, cc wrote: char[4096] buf; writeln(GC.stats.usedSize); foreach (i; 0 .. 10) { sformat(buf, "%f", 1.234f); writeln(GC.stats.usedSize);

Re: DMD won't compile re-init of variable

2020-01-31 Thread Minty Fresh via Digitalmars-d-learn
On Thursday, 30 January 2020 at 21:36:53 UTC, Adam D. Ruppe wrote: On Thursday, 30 January 2020 at 21:09:41 UTC, Simon wrote: How do I revert my variable to the init state? null is the initial state for those. More generally, .init can be used as to get the initial state for any type.

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-01-31 Thread Basile B. via Digitalmars-d-learn
On Friday, 31 January 2020 at 11:19:37 UTC, Saurabh Das wrote: I see that DUB has DMD as a library package, but I was not able to understand how to use it. Is it possible to use DMD as a library within a D program to compile a string to machine code and run the compiled code at runtime?

Re: iopipe: Writing output to std.io File

2020-01-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/30/20 12:59 AM, Jesse Phillips wrote: On Tuesday, 28 January 2020 at 16:09:55 UTC, Steven Schveighoffer wrote: Everything is pulled with iopipe, even output, so it's just a matter of who is pulling and when. Pushing is a matter of telling the other end to pull. That statement I

Re: Template Usage with Eponymous Trick

2020-01-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/30/20 9:10 AM, ShadoLight wrote: Why does the 'classical' template calling convention not work anymore in this case? (if the template name and function name are different it obviously still works). Note the templates were not defined in the simplified 'Eponymous Trick' style i.e.: I

Re: Constant GC allocations when sending large messages to threads?

2020-01-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/31/20 2:14 AM, cc wrote: On Wednesday, 29 January 2020 at 21:10:53 UTC, Steven Schveighoffer wrote: I'm pretty sure std.concurrency uses Variant to pass message data, which boxes when it gets over a certain size. You are probably crossing that threshold. The allocations should level out

Re: Cannot implicitly convert expression [[0, -1, 2], [4, 11, 2]] of type int[][] to const(int[2])[]

2020-01-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 31, 2020 5:43:44 AM MST MoonlightSentinel via Digitalmars-d-learn wrote: > On Friday, 31 January 2020 at 12:37:43 UTC, Adnan wrote: > > What's causing this? > > You mixed up the array lengths: > > const int[3][2] matA = [[0, -1, 2], [4, 11, 2]]; > const int[2][3] matB = [[3,

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-01-31 Thread Saurabh Das via Digitalmars-d-learn
On Friday, 31 January 2020 at 14:25:30 UTC, Basile B. wrote: On Friday, 31 January 2020 at 11:19:37 UTC, Saurabh Das wrote: [...] Fundamentally DMD as a library is a front-end. Jitting is to the backend side. You'll be able to lex and parse the source to get an AST, to perform the semantic

How make Executable Dlang EXE ask for "Run as Administrator"?

2020-01-31 Thread Marcone via Digitalmars-d-learn
I created a program in Dlang and compiled to exe using dmd. But my program need administrator privileges. How can I make executable dlang program ask for administrator privileges on start up program?