Re: Doubts about the performance of array concatenation

2020-12-01 Thread Max Haughton via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 00:08:55 UTC, ddcovery wrote: On Tuesday, 1 December 2020 at 23:43:31 UTC, Max Haughton wrote: On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote: Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D,

Re: Dude about ~ array concatenation performance

2020-12-01 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote: Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...] Use ldc, rdmd can invoke it for you. DMD's optimizer is not even close to as advanced as

Re: How to unit-test a phobos module?

2020-11-25 Thread Max Haughton via Digitalmars-d-learn
On Wednesday, 25 November 2020 at 21:36:36 UTC, Q. Schroll wrote: On Wednesday, 25 November 2020 at 21:16:15 UTC, Steven Schveighoffer wrote: I typically do: make -f posix.mak std/.test -Steve For some reason, [1] says `make.exe` would be installed by the DMD installer, but I found none.

Re: How to construct a tree data structure with differently static nodes types

2020-11-22 Thread Max Haughton via Digitalmars-d-learn
On Monday, 23 November 2020 at 01:20:04 UTC, data pulverizer wrote: Hi all, I am trying to construct a tree data structure composed of differently (statically) typed nodes. The basic case is a binary tree. So you have a node like: ``` struct Node(T) { T value; Node* next; Node* prev;

Re: Request our suggestio: better way to insert data from Array!string[string] into a database table

2020-11-16 Thread Max Haughton via Digitalmars-d-learn
On Monday, 16 November 2020 at 17:44:08 UTC, Vino wrote: Hi All, Request your suggestion, we have a program which call's an api, the output of the api is parsed using json parser and the result is stored in an array(Array!string[string] data), then these stored result are inserted into

Re: presence of function template prevents diagnostic

2020-11-16 Thread Max Haughton via Digitalmars-d-learn
On Monday, 16 November 2020 at 17:03:32 UTC, Steven Schveighoffer wrote: On 11/14/20 5:44 PM, kdevel wrote: $ dmd -version=X -i foo $ ./foo void A.bar(int s) Is the latter behavior intended or a bug? That seems like a bug. It shouldn't be less ambiguous because you *added* an overload that

Re: Why was new(size_t s) { } deprecated in favor of an external allocator?

2020-10-15 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 15 October 2020 at 06:39:00 UTC, Patrick Schluter wrote: On Wednesday, 14 October 2020 at 20:32:51 UTC, Max Haughton wrote: On Wednesday, 14 October 2020 at 20:27:10 UTC, Jack wrote: What was the reasoning behind this decision? Andrei's std::allocator talk from a few years ago

Re: Why was new(size_t s) { } deprecated in favor of an external allocator?

2020-10-14 Thread Max Haughton via Digitalmars-d-learn
On Wednesday, 14 October 2020 at 20:27:10 UTC, Jack wrote: What was the reasoning behind this decision? Andrei's std::allocator talk from a few years ago at cppcon covers this (amongst other things)

Re: Range format specifiers in other languages?

2020-10-11 Thread Max Haughton via Digitalmars-d-learn
On Sunday, 11 October 2020 at 23:57:31 UTC, Ali Çehreli wrote: I find D's %( and %) range format specifiers very useful: import std.stdio; import std.range; void main() { 5.iota.writefln!"%(%s, %)"; // Prints 0, 1, 2, 3, 4 } Are there similar features in other languages? Thank you, Ali

Re: Taking arguments by value or by reference

2020-10-04 Thread Max Haughton via Digitalmars-d-learn
On Sunday, 4 October 2020 at 14:26:43 UTC, Anonymouse wrote: On Saturday, 3 October 2020 at 23:47:32 UTC, Max Haughton wrote: The guiding principle to your function parameters should be correctness - if I am passing a big struct around, if I want to take ownership of it I probably want to take

Re: Taking arguments by value or by reference

2020-10-03 Thread Max Haughton via Digitalmars-d-learn
On Saturday, 3 October 2020 at 23:00:46 UTC, Anonymouse wrote: I'm passing structs around (collections of strings) whose .sizeof returns 432. The readme for 2.094.0 includes the following: This release reworks the meaning of in to properly support all those use cases. in parameters will now

Re: Question about publishing a useful function I have written

2020-07-14 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote: I have written something which may or may not be novel and I’m wondering about how to distribute it to as many users as possible, hoping others will find it useful. What’s the best way to publish a D routine ? [...] GitHub is the

Re: Passing iterators into functions

2020-06-24 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 25 June 2020 at 03:35:00 UTC, repr-man wrote: I have the code: int[5] a = [0, 1, 2, 3, 4]; int[5] b = [5, 6, 7, 8, 9]; auto x = chain(a[], b[]).chunks(5); writeln(x); It produces a range of slices as is expected: [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] However, when I define a

Re: dmd memory usage

2019-11-18 Thread Max Haughton via Digitalmars-d-learn
On Monday, 18 November 2019 at 00:20:12 UTC, Steven Schveighoffer wrote: I'm fighting some out of memory problems using DMD and some super-template heavy code. I have ideas on how to improve the situation, but it involves redesigning a large portion of the design. I want to do it

Re: Execute certain Tests?

2019-11-02 Thread Max Haughton via Digitalmars-d-learn
On Saturday, 2 November 2019 at 17:27:14 UTC, Martin Brezel wrote: Is there a trick to execute only the test, defined in one file? Or the Tests of a certain Module? Or in general: How to avoid to execute all the tests, when running "dub test"? It doesn't has to be dub, though. Not by

Re: On D's garbage collection

2019-10-08 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 8 October 2019 at 16:28:51 UTC, Marcel wrote: I'm been thinking about using D in conjunction with C11 to develop a set of applications with hard real-time requirements. While initially the goal was to use C++ instead, it has become clear that D's introspection facilities will offer

Re: how to definition a non-const pointer that point a const var.

2019-08-24 Thread Max Haughton via Digitalmars-d-learn
On Saturday, 24 August 2019 at 05:03:43 UTC, Jonathan M Davis wrote: On Friday, August 23, 2019 10:14:56 PM MDT lili via Digitalmars-d-learn wrote: Hi: In C we can definition const int *ncp_to_cv; or int * const cp_to_ncv; How to do this in D. D uses parens to restrict how much of

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 18:54:58 UTC, H. S. Teoh wrote: On Tue, Aug 13, 2019 at 11:28:35AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] Summary: Ditch the linked list and put the elements into an array. :) [...] +1. The linked list may have been faster 20 years ago, before

Re: Desktop app with vibe.d

2019-08-12 Thread Max Haughton via Digitalmars-d-learn
On Monday, 12 August 2019 at 10:41:57 UTC, GreatSam4sure wrote: Pls I want to know if it is possible to build desktop app with vibe.d just like nodejs. I am not satisfy with the GUI of Dlang such as dlangui and gtkd. I don't think they have good styling capabilities like HTML and CSS. I will

Re: Question about ubyte x overflow, any safe way?

2019-08-04 Thread Max Haughton via Digitalmars-d-learn
On Sunday, 4 August 2019 at 18:22:30 UTC, matheus wrote: On Sunday, 4 August 2019 at 18:15:30 UTC, Max Haughton wrote: What do you want to do? If you just want to count to 255 then use a foreach This was just an example, what I'd like in this code is either: Get an error (exception) when

Re: Question about ubyte x overflow, any safe way?

2019-08-04 Thread Max Haughton via Digitalmars-d-learn
On Sunday, 4 August 2019 at 18:12:48 UTC, matheus wrote: Hi, The snippet below will produce an "infinite loop" because obviously "ubyte u" will overflow after 255: import std.stdio; void main(){ ubyte u = 250; for(;u<256;++u){ writeln(u); } } Question: Is there a way

Re: Calling / running / executing .d script from another .d script

2019-07-28 Thread Max Haughton via Digitalmars-d-learn
On Sunday, 28 July 2019 at 12:56:12 UTC, BoQsc wrote: Right now, I'm thinking what is correct way to run another .d script from a .d script. Do you have any suggestions? You'd need to bring a compiler with you and then build it into a shared library (then dlopen it). To do this you'd need a

Re: Is betterC affect to compile time?

2019-07-26 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 25 July 2019 at 14:20:03 UTC, Ali Çehreli wrote: On 07/25/2019 05:46 AM, Oleg B wrote: On Thursday, 25 July 2019 at 12:34:15 UTC, rikki cattermole wrote: Those restrictions don't stop at runtime. It's vary sad. What reason for such restrictions? It's fundamental idea or

Re: Is there a way to bypass the file and line into D assert function ?

2019-07-19 Thread Max Haughton via Digitalmars-d-learn
On Friday, 19 July 2019 at 15:30:25 UTC, Newbie2019 wrote: for example: void ASSERT(string fmt, string file = __FILE_FULL_PATH__, size_t line = __LINE__, T...) (bool c, scope T a) @nogc { assert(c, string, file, line); } but i get this error: error.d(39): Error: found file when

Re: How to use std.windows.registry, there are no documentations.

2019-07-11 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 11 July 2019 at 08:53:35 UTC, BoQsc wrote: https://dlang.org/phobos/std_windows_registry.html https://github.com/dlang/phobos/blob/master/std/windows/registry.d Can someone provide some examples on how to: set, change, receive something from the Windows registry using Phobos

Re: Memory allocation failed in CT

2019-07-09 Thread Max Haughton via Digitalmars-d-learn
Is this a 64 or 32 bit compiler? Also could you post the source code if possible? You could try "--DRT-gcopt=profile:1" druntime flag to see if the compiler is running out of memory for real

Re: Memory allocation failed in CT

2019-07-09 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 9 July 2019 at 17:48:52 UTC, Andrey wrote: Hello, I have got a problem with compile-time calulations. I have some code generator that should create some long string of code during CT and after generation I mixin it. If I run it normally - in run time - then there is no error and I

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Max Haughton via Digitalmars-d-learn
On Friday, 5 July 2019 at 16:25:10 UTC, Nick Treleaven wrote: On Thursday, 4 July 2019 at 11:06:36 UTC, Eugene Wissner wrote: static immutable arr = [1, 2]; You have to spell it out that the data is static. Yes, I was wondering why the compiler doesn't statically allocate it

Re: Transform a function's body into a string for mixing in

2019-06-20 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 20 June 2019 at 19:09:11 UTC, Emmanuelle wrote: Hello! Is there any trait or Phobos function for transforming a function/delegate/lambda/whatever's body into a string suitable for `mixin(...)`? For example: --- __traits(getBody, (int a, int b) => a + b); // returns "(int a,

Re: DIP 1016 and const ref parameters

2019-06-19 Thread Max Haughton via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 19:25:59 UTC, Jonathan M Davis wrote: On Wednesday, June 19, 2019 12:28:12 PM MDT XavierAP via Digitalmars-d-learn wrote: [...] The DIPs are here: https://github.com/dlang/DIPs [...] DIP1014 has not been implemented in DMD or druntime yet, AFAIK

Re: How to compile my DMD fork?

2019-06-14 Thread Max Haughton via Digitalmars-d-learn
On Friday, 14 June 2019 at 18:07:11 UTC, Q. Schroll wrote: Basically the headline. I want to try to implement my DIP. I've already forked DMD from GitHub. Now, what would I have to do in order to get a D compiler with my changes? I have Windows on x86-64 and Visual Studio on my machine. It

Re: Does slicing have an effect?

2019-05-25 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 21 May 2019 at 20:31:58 UTC, Dennis wrote: I was replacing a memcpy with a slice assignment and accidentally used == instead of =. Usually the compiler protects me from mistakes like that: ``` int[4] a; a == a; ``` Error: a == a has no effect However, because I was using slices it

Re: dmd -nodefaultlibs?

2019-05-21 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 21 May 2019 at 21:48:22 UTC, Jonathan Marler wrote: Is there a way to prevent dmd from adding any default libraries to its linker command? Something equivalent to "-nodefaultlibs" from gcc? https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html I'd still like to use the dmd.conf

Re: DIP1000: Should this compile

2019-05-16 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 16 May 2019 at 21:56:52 UTC, Steven Schveighoffer wrote: On 5/16/19 10:21 PM, Max Haughton wrote: https://run.dlang.io/is/cKFsXh Should this compile, or is return scope T* down to the user to not escape (Returning directly does not compile) Answer to subject: no. This is a

DIP1000: Should this compile

2019-05-16 Thread Max Haughton via Digitalmars-d-learn
https://run.dlang.io/is/cKFsXh Should this compile, or is return scope T* down to the user to not escape (Returning directly does not compile)