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)

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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: 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: 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: low-latency GC

2020-12-06 Thread Max Haughton via Digitalmars-d-learn
On Sunday, 6 December 2020 at 05:29:37 UTC, Ola Fosheim Grostad wrote: On Sunday, 6 December 2020 at 05:16:26 UTC, Bruce Carneal wrote: How difficult would it be to add a, selectable, low-latency GC to dlang? Is it closer to "we cant get there from here" or "no big deal if you already have

Re: low-latency GC

2020-12-06 Thread Max Haughton via Digitalmars-d-learn
On Sunday, 6 December 2020 at 11:07:50 UTC, Ola Fosheim Grostad wrote: On Sunday, 6 December 2020 at 10:44:39 UTC, Max Haughton wrote: On Sunday, 6 December 2020 at 05:29:37 UTC, Ola Fosheim Grostad wrote: It has to be either some kind of heavily customisable small GC (i.e. with our resources

Re: low-latency GC

2020-12-06 Thread Max Haughton via Digitalmars-d-learn
On Sunday, 6 December 2020 at 11:35:17 UTC, Ola Fosheim Grostad wrote: On Sunday, 6 December 2020 at 11:27:39 UTC, Max Haughton wrote: [...] No, unique doesnt need indirection, neither does ARC, we put the ref count at a negative offset. shared_ptr is a fat pointer with the ref count as a

Re: If statements and unused template parameters in Phobos documentation

2020-12-20 Thread Max Haughton via Digitalmars-d-learn
On Sunday, 20 December 2020 at 13:51:08 UTC, Rekel wrote: I found a lot of the Phobos documentation to contain template arguments and if statements that made no sense to me, for example: ``` uint readf(alias format, A...) ( auto ref A args ) if (isSomeString!(typeof(format))); uint

Re: Get the code of any D-entity as string?

2020-12-26 Thread Max Haughton via Digitalmars-d-learn
On Friday, 25 December 2020 at 21:25:40 UTC, sighoya wrote: I've read a bit in Dlang traits. It now has the ability to retrieve all method signatures of an overload set. Big plus from me. Is generally possible to get the declaration of a type/module/value as string in traits? I didn't

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: 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: 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: DConf talk : Exceptions will disappear in the future?

2021-01-05 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 5 January 2021 at 19:42:40 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 5 January 2021 at 18:23:25 UTC, sighoya wrote: No error handling model was the HIT and will never be, therefore I would recommend to leave things as they are and to develop alternatives and not to replace

Re: Why many programmers don't like GC?

2021-01-15 Thread Max Haughton via Digitalmars-d-learn
On Friday, 15 January 2021 at 21:49:07 UTC, H. S. Teoh wrote: On Fri, Jan 15, 2021 at 09:04:13PM +, welkam via Digitalmars-d-learn wrote: [...] As the joke goes, "you can write assembly code in any language". :-D If you code in a sloppy way, it doesn't matter what language you write

Re: Minimize GC memory footprint

2021-01-31 Thread Max Haughton via Digitalmars-d-learn
On Saturday, 30 January 2021 at 16:42:35 UTC, frame wrote: Is there a way to force the GC to re-use memory in already existing pools? I set maxPoolSize:1 to gain pools that can be quicker released after there no longer in use. This already reduces memory usage to 1:3. Sadly the application

Re: Refactoring tools

2021-02-03 Thread Max Haughton via Digitalmars-d-learn
On Wednesday, 3 February 2021 at 07:20:06 UTC, Imperatorn wrote: As the title says: 1. Are there any (automated) refactoring tools for D? 2. If not, why? (Is D still too small?) D is also designed to not need as much refactoring as other languages, so even for our size there isn't a huge

Re: Can change vtbl record at runtime ?

2021-02-03 Thread Max Haughton via Digitalmars-d-learn
On Wednesday, 3 February 2021 at 05:30:37 UTC, Виталий Фадеев wrote: Reason: Reuse component, bind custom callback without creating new class. Concept example: class SaveFilePopup { void onSuccess() { /* default operations */ } } auto saveFile = new

Re: do I incur a penality on compile time if I explicitly declare default behavior ?

2021-06-22 Thread max haughton via Digitalmars-d-learn
On Monday, 21 June 2021 at 04:12:55 UTC, someone wrote: I mean, coding as following: ```d int intWhatever = 0; /// default being zero anyway foreach (classComputer objComputer, objComputers) { ... } /// explicitly declaring the type instead of letting the compiler to figure it out struc

Re: My simple internet client made in Dlang.

2021-02-04 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 4 February 2021 at 20:54:15 UTC, Ali Çehreli wrote: On 2/3/21 8:44 AM, Marcone wrote: [...] I think the following would be improvements: >[...] I don't know the protocol but obviously 8192 must be sufficient. [...] Less calls to std.conv can also mean less surface area

Re: GC.addRange in pure function

2021-02-09 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 9 February 2021 at 19:53:27 UTC, Temtaime wrote: On Sunday, 7 February 2021 at 14:13:18 UTC, vitamin wrote: Why using 'new' is allowed in pure functions but calling GC.addRange or GC.removeRange isn't allowed? pure is broken. Just don't [use it] [Citation needed]

Re: Profiling

2021-02-10 Thread Max Haughton via Digitalmars-d-learn
On Wednesday, 10 February 2021 at 13:31:09 UTC, Guillaume Piolat wrote: On Wednesday, 10 February 2021 at 11:52:51 UTC, JG wrote: [...] Here is what I use for sampling profiler: (On Windows) Build with LDC, x86_64, with dub -b release-debug in order to have debug info. Run your program

Re: dub support for Mac M1?

2021-03-04 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 4 March 2021 at 22:30:17 UTC, tastyminerals wrote: I got a company MacBook with M1 chip and gradually migrate all the stuff from Linux machine. I got precompiled ldc binary installed without any problem now is the time for dub since I have couple of D projects I use at work and

Re: Problem Computing Dot Product with mir

2021-02-22 Thread Max Haughton via Digitalmars-d-learn
On Monday, 22 February 2021 at 07:14:26 UTC, 9il wrote: On Sunday, 21 February 2021 at 16:18:05 UTC, Kyle Ingraham wrote: I am trying to convert sRGB pixel values to XYZ with mir using the following guide: http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html [...] mir-glas is

Re: Can't I allocate at descontructor?

2021-03-05 Thread Max Haughton via Digitalmars-d-learn
On Friday, 5 March 2021 at 20:03:58 UTC, Jack wrote: On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote: On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: The following code returns a memory error. I did notice it did happens whenever I did a memory allocation. Is this not possible

Re: Can't I allocate at descontructor?

2021-03-05 Thread Max Haughton via Digitalmars-d-learn
On Friday, 5 March 2021 at 20:13:54 UTC, Jack wrote: On Friday, 5 March 2021 at 20:10:39 UTC, Max Haughton wrote: On Friday, 5 March 2021 at 20:03:58 UTC, Jack wrote: On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote: On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote: [...]

Re: How can I make this work?

2021-02-28 Thread Max Haughton via Digitalmars-d-learn
On Sunday, 28 February 2021 at 09:18:56 UTC, Rumbu wrote: On Sunday, 28 February 2021 at 09:04:49 UTC, Rumbu wrote: On Sunday, 28 February 2021 at 07:05:27 UTC, Jack wrote: I'm using a windows callback function where the user-defined value is passed thought a LPARAM argument type. I'd like to

Re: Mixed language projects (D and C++)

2021-02-19 Thread Max Haughton via Digitalmars-d-learn
On Friday, 19 February 2021 at 09:44:15 UTC, Preetpal wrote: I want to reuse existing C++ code in a new project that I am writing in D and I want to use D in an existing C++ code base (it is not large). I do not anticipate interop being an issue. [...] C++ interop is used every day. The

Re: Mixed language projects (D and C++)

2021-02-19 Thread Max Haughton via Digitalmars-d-learn
On Friday, 19 February 2021 at 10:18:28 UTC, Preetpal wrote: On Friday, 19 February 2021 at 10:01:36 UTC, Max Haughton wrote: On Friday, 19 February 2021 at 09:44:15 UTC, Preetpal wrote: I want to reuse existing C++ code in a new project that I am writing in D and I want to use D in an

Re: Development of the foundation of a programming language

2021-09-12 Thread max haughton via Digitalmars-d-learn
On Monday, 13 September 2021 at 00:53:06 UTC, leikang wrote: I want to contribute to the development of the dlang language, but I feel that I am insufficient, so I want to ask the big guys, can I participate in the development of the Dlang language after learning the principles of compilation?

Re: Development of the foundation of a programming language

2021-09-13 Thread max haughton via Digitalmars-d-learn
On Monday, 13 September 2021 at 04:08:53 UTC, rikki cattermole wrote: On 13/09/2021 3:21 PM, leikang wrote: Are there any recommended books or videos to learn about the principles of compilation? What else should I learn besides the principles of compilation? The classic book on compilers

Re: object.d: Error: module object is in file 'object.d' which cannot be read

2021-09-13 Thread max haughton via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 03:31:17 UTC, Kenneth Dallmann wrote: On Sunday, 27 March 2011 at 10:28:00 UTC, Ishan Thilina wrote: [...] I had the exact same problem, very frustrating. I believe I solved the issue, it was a simple error. When you are installing D, on Windows, it

Re: Development of the foundation of a programming language

2021-09-14 Thread max haughton via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 05:06:01 UTC, Elronnd wrote: On Tuesday, 14 September 2021 at 03:24:45 UTC, max haughton wrote: On Tuesday, 14 September 2021 at 03:19:46 UTC, Elronnd wrote: On Monday, 13 September 2021 at 11:40:10 UTC, max haughton wrote: The dragon book barely mentions SSA

Re: Development of the foundation of a programming language

2021-09-13 Thread max haughton via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 03:19:46 UTC, Elronnd wrote: On Monday, 13 September 2021 at 11:40:10 UTC, max haughton wrote: The dragon book barely mentions SSA for example In fairness, dmd doesn't use SSA either That's not a good thing.

Re: avoid codegen pass

2021-10-02 Thread max haughton via Digitalmars-d-learn
On Saturday, 2 October 2021 at 14:44:16 UTC, Padlev wrote: On Saturday, 2 October 2021 at 13:26:27 UTC, Adam D Ruppe wrote: On Saturday, 2 October 2021 at 13:24:19 UTC, Padlev wrote: -o- how to run only semantic and avoid codegen to have a quicker run? -o- does skip codegen already so

Re: How use ldc pragmas?

2021-10-01 Thread max haughton via Digitalmars-d-learn
On Friday, 1 October 2021 at 19:23:06 UTC, james.p.leblanc wrote: D-ers, After experimenting with ldc's autovectorization of avx code, it appears there may be counter-intuitiveness to the autovectorization (especially for complex numbers). (My comment may be wrong, so any corrections are

Re: avoid codegen pass

2021-10-02 Thread max haughton via Digitalmars-d-learn
On Saturday, 2 October 2021 at 18:05:06 UTC, Dennis wrote: On Saturday, 2 October 2021 at 16:57:48 UTC, max haughton wrote: Do you have optimizations turned on? i.e. are you compiling with -O by accident? Not needed, it's declared: ```D pragma(inline, true) @property _timezone() @safe const

Re: Better debugging?

2021-10-03 Thread max haughton via Digitalmars-d-learn
On Sunday, 3 October 2021 at 22:21:45 UTC, Tim wrote: Hi all, I am currently using GDB within VScode with the -gc DMD2 compiler switch and my debugging is not amazing. Whenever I inspect a struct/object it just shows me the pointer rather than the object information and strings come up as a

Re: First time using Parallel

2021-12-26 Thread max haughton via Digitalmars-d-learn
On Sunday, 26 December 2021 at 06:10:03 UTC, Era Scarecrow wrote: This is curious. I was up for trying to parallelize my code, specifically having a block of code calculate some polynomials (*Related to Reed Solomon stuff*). So I cracked open std.parallel and looked over how I would manage

Re: How to print unicode characters (no library)?

2021-12-26 Thread max haughton via Digitalmars-d-learn
On Sunday, 26 December 2021 at 21:22:42 UTC, Adam Ruppe wrote: On Sunday, 26 December 2021 at 20:50:39 UTC, rempas wrote: [...] write just transfers a sequence of bytes. It doesn't know nor care what they represent - that's for the receiving end to figure out. [...] You are mistaken.

Re: Is there a way to make a function parameter accept only values that can be checked at compile time?

2021-12-28 Thread max haughton via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 21:19:29 UTC, rempas wrote: I would like to know if that's possible. Actually I would like to do something like the following: ``` extern (C) void main() { void print_num(int num, comp_time_type int mul) { static if (is(mul == ten)) { printf("%d\n",

Re: Is there a way to make a function parameter accept only values that can be checked at compile time?

2021-12-29 Thread max haughton via Digitalmars-d-learn
On Wednesday, 29 December 2021 at 08:56:47 UTC, rempas wrote: On Tuesday, 28 December 2021 at 22:26:33 UTC, max haughton wrote: Why do you need this? What's wrong with a normal branch in this case. Runtime performance. I want the value to get checked at compile time and use "static if" with

Re: Is there a way to make a function parameter accept only values that can be checked at compile time?

2021-12-29 Thread max haughton via Digitalmars-d-learn
On Wednesday, 29 December 2021 at 16:51:47 UTC, rempas wrote: On Wednesday, 29 December 2021 at 16:27:22 UTC, max haughton wrote: Inlining + constant propagation. Fancier iterations on those exist too but 90% of the speedup will come from those since for it to matter they likely would've been

Re: Is there a way to make a function parameter accept only values that can be checked at compile time?

2021-12-29 Thread max haughton via Digitalmars-d-learn
On Wednesday, 29 December 2021 at 15:53:38 UTC, rempas wrote: On Wednesday, 29 December 2021 at 11:09:04 UTC, max haughton wrote: If the value is known at compile time the compiler can pretty easily do that for you unless you're really unlucky. How is this even possible? Inlining + constant

Re: Is DMD still not inlining "inline asm"?

2021-11-11 Thread max haughton via Digitalmars-d-learn
On Thursday, 11 November 2021 at 17:29:33 UTC, rempas wrote: On Thursday, 11 November 2021 at 13:22:15 UTC, Basile B. wrote: Yes, this is still the case. A particularity of DMD inliner is that it does its job in the front-end, so inlining asm is totally impossible. Then, even if inlining was

Re: Is DMD still not inlining "inline asm"?

2021-11-12 Thread max haughton via Digitalmars-d-learn
On Friday, 12 November 2021 at 11:32:16 UTC, rempas wrote: On Thursday, 11 November 2021 at 19:22:33 UTC, max haughton wrote: There's an attribute to tell it the function is safe to inline. And can't you do that with inline asm? Not always. The attribute is intended for naked asm since

Re: Source code for vibe.d listenTCP()

2022-02-26 Thread max haughton via Digitalmars-d-learn
On Saturday, 26 February 2022 at 22:25:46 UTC, Chris Piker wrote: Hi D I'm trying out the vibe.d framework for the first time and it looks like many of the functions mutate some hidden global state. Take for example `listenTCP`. To help me build a mental picuture of the framework I'd like

Re: How to get instance member value from getSymbolsByUDA

2022-02-26 Thread max haughton via Digitalmars-d-learn
On Saturday, 26 February 2022 at 10:39:18 UTC, Remi Thebault wrote: Hi all, I'm trying to establish a REST API by using the type system (used in both client and server code). [...] https://dlang.org/phobos/std_traits.html#getUDAs

Re: How to get instance member value from getSymbolsByUDA

2022-02-26 Thread max haughton via Digitalmars-d-learn
On Saturday, 26 February 2022 at 11:38:16 UTC, Remi Thebault wrote: On Saturday, 26 February 2022 at 11:26:54 UTC, max haughton wrote: On Saturday, 26 February 2022 at 10:39:18 UTC, Remi Thebault wrote: Hi all, I'm trying to establish a REST API by using the type system (used in both client

Re: How to get instance member value from getSymbolsByUDA

2022-02-26 Thread max haughton via Digitalmars-d-learn
On Saturday, 26 February 2022 at 17:06:06 UTC, Remi Thebault wrote: On Saturday, 26 February 2022 at 12:01:14 UTC, max haughton wrote: Getting the UDAs from inside a symbol must be done via a recursive procedure in the same manner one would identify the aforementioned symbol i.e. you have to

Re: gdc or ldc for faster programs?

2022-01-29 Thread max haughton via Digitalmars-d-learn
On Saturday, 29 January 2022 at 18:28:06 UTC, Ali Çehreli wrote: On 1/29/22 10:04, Salih Dincer wrote: > Could you also try the following code with the same configurations? The program you posted with 2 million random values: ldc 1.9 seconds gdc 2.3 seconds dmd 2.8 seconds I understand such

Re: stripping binaries from LDC2

2022-02-07 Thread max haughton via Digitalmars-d-learn
On Monday, 7 February 2022 at 12:16:53 UTC, Arjan wrote: In c++ our release builds are build `-O2 -g` and the resulting binaries are stripped with GNU/strip. Is this also possible with LDC2 generated binaries for D code? So build D code with `-O2 -g` and then strip the resulting binary? Why

Re: stripping binaries from LDC2

2022-02-07 Thread max haughton via Digitalmars-d-learn
On Monday, 7 February 2022 at 14:20:31 UTC, Arjan wrote: On Monday, 7 February 2022 at 13:14:19 UTC, max haughton wrote: On Monday, 7 February 2022 at 12:16:53 UTC, Arjan wrote: In c++ our release builds are build `-O2 -g` and the resulting binaries are stripped with GNU/strip. Is this also

Re: stack frame & dangling pointer weirdness

2022-04-21 Thread max haughton via Digitalmars-d-learn
On Thursday, 21 April 2022 at 05:49:12 UTC, Alain De Vos wrote: Following program: ``` import std.stdio; void main() @trusted { int *p=null; void myfun(){ int x=2; p= writeln(p); writeln(x); } myfun(); *p=16; writeln(p); writeln(*p); } ``` outputs :

Re: What are (were) the most difficult parts of D?

2022-05-15 Thread max haughton via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote: What are you stuck at? What was the most difficult features to understand? etc. To make it more meaningful, what is your experience with other languages? Ali Learning D is almost a complete blur in my memory but I distinctly

Re: What are (were) the most difficult parts of D?

2022-05-21 Thread max haughton via Digitalmars-d-learn
On Saturday, 21 May 2022 at 19:00:04 UTC, Johan wrote: On Tuesday, 17 May 2022 at 06:28:10 UTC, cc wrote: On Monday, 16 May 2022 at 15:08:15 UTC, H. S. Teoh wrote: [...] According to the dlang.org wiki entry for LDC: [...] So I'm not touching it for now. Lol, what? Don't misquote the

Re: What are (were) the most difficult parts of D?

2022-05-22 Thread max haughton via Digitalmars-d-learn
On Sunday, 22 May 2022 at 20:05:33 UTC, Chris Piker wrote: On Sunday, 22 May 2022 at 19:33:21 UTC, rikki cattermole wrote: I should probably jump back to another thread, but maybe one more reply isn't too much off topic discussion... [...]

Re: Best Practice to manage large projects with dub?

2022-05-13 Thread max haughton via Digitalmars-d-learn
On Friday, 13 May 2022 at 17:51:55 UTC, Ozan Süel wrote: Hi My situation: I'm working on and with many projects based on many libraries. I know how to handle these in Git, GitHub and Dub. But what would be the Best Practice in current dub? Let's say, we have many apps (1 app = 1 package),

Re: What are (were) the most difficult parts of D?

2022-05-13 Thread max haughton via Digitalmars-d-learn
On Friday, 13 May 2022 at 21:07:12 UTC, Christopher Katko wrote: Is there any way we can get numbered errors like C++ / Microsoft have? E2040 Declaration terminated incorrectly Because then we could easily have a wiki for common error cases with code snippets of it occurring, and a fix for

Re: Is there any implementation of a 128bit integer?

2022-07-10 Thread max haughton via Digitalmars-d-learn
On Monday, 11 July 2022 at 00:19:23 UTC, Era Scarecrow wrote: On Friday, 8 July 2022 at 15:32:44 UTC, Rob T wrote: [...] There was a discussion on this not long ago. Walter tried implementing it recently too, though I'm guessing he gave up. [...] Note that you're replying to a message

Re: vectorization of a simple loop -- not in DMD?

2022-07-11 Thread max haughton via Digitalmars-d-learn
On Monday, 11 July 2022 at 18:15:16 UTC, Ivan Kazmenko wrote: Hi. I'm looking at the compiler output of DMD (-O -release), LDC (-O -release), and GDC (-O3) for a simple array operation: ``` void add1 (int [] a) { foreach (i; 0..a.length) a[i] += 1; } ``` Here are the outputs:

Re: want to confirm: gc will not free a non-gc-allocated field of a gc-allocated object?

2022-06-06 Thread max haughton via Digitalmars-d-learn
On Tuesday, 7 June 2022 at 00:40:56 UTC, ag0aep6g wrote: On 07.06.22 00:22, max haughton wrote: float[] doesn't contain pointers, so the GC won't do anything to or with it. wat float[] is a pointer (plus a length). The GC will deal with it like any other pointer. I'm talking about the

Re: want to confirm: gc will not free a non-gc-allocated field of a gc-allocated object?

2022-06-06 Thread max haughton via Digitalmars-d-learn
On Monday, 6 June 2022 at 22:18:08 UTC, mw wrote: Hi, Suppose I have this code: ``` class GCAllocated { float[] data; this() { // non-gc-allocated field this.data = cast(float[])(core.stdc.stdlib.malloc(nBytes)[0 .. nBytes]); } } void foo() { auto obj = new GCAllocated();

Re: want to confirm: gc will not free a non-gc-allocated field of a gc-allocated object?

2022-06-07 Thread max haughton via Digitalmars-d-learn
On Tuesday, 7 June 2022 at 08:56:29 UTC, ag0aep6g wrote: On 07.06.22 03:02, max haughton wrote: I'm talking about the data in the array. void[] might contain pointers, float[] does not so it won't be scanned. That wasn't mw's question. I also answered this in my original one IIRC. There's

Re: want to confirm: gc will not free a non-gc-allocated field of a gc-allocated object?

2022-06-07 Thread max haughton via Digitalmars-d-learn
On Tuesday, 7 June 2022 at 09:12:25 UTC, ag0aep6g wrote: On 07.06.22 11:00, max haughton wrote: On Tuesday, 7 June 2022 at 08:56:29 UTC, ag0aep6g wrote: [...] That wasn't mw's question. I also answered this in my original one IIRC. You didn't. Ok I must have assumed it was obvious it

Re: Enforce not null at compile time?

2022-06-20 Thread max haughton via Digitalmars-d-learn
On Monday, 20 June 2022 at 17:48:48 UTC, Antonio wrote: Is there any way to specify that a variable, member or parameter can't be null? You can use an invariant if it's a member of an aggregate but be warned that these are only checked at the boundaries of public member functions.

Re: How to map machine instctions in memory and execute them? (Aka, how to create a loader)

2022-06-08 Thread max haughton via Digitalmars-d-learn
On Monday, 6 June 2022 at 15:13:45 UTC, rempas wrote: I tried to find anything that will show code but I wasn't able to find anything expect for an answer on stackoverflow. I would find a lot of theory but no practical code that works. What I want to do is allocate memory (with execution

Re: vectorization of a simple loop -- not in DMD?

2022-07-14 Thread max haughton via Digitalmars-d-learn
On Thursday, 14 July 2022 at 13:00:24 UTC, ryuukk_ wrote: On Thursday, 14 July 2022 at 05:30:58 UTC, Siarhei Siamashka wrote: On Tuesday, 12 July 2022 at 13:23:36 UTC, ryuukk_ wrote: I wonder if DMD/LDC/GDC have built in tools to profile and track performance Linux has a decent system wide

Re: What's a good way to disassemble Phobos?

2022-04-30 Thread max haughton via Digitalmars-d-learn
On Saturday, 30 April 2022 at 18:18:02 UTC, Dukc wrote: I have figured out that my development build of Phobos is for some reason including instances of `__cmp` and `dstrcmp` templates from DRuntime in the Phobos binary. Since `-betterC` client code does not link Phobos in, it fails if it

Re: Do I have to pass parameters with ref explicitly?

2022-04-16 Thread max haughton via Digitalmars-d-learn
On Sunday, 17 April 2022 at 03:00:28 UTC, Elfstone wrote: I'm reading some d-sources, and it looks like they pass big structs by value. Such as: Matrix4x4f opBinary(string op)(Matrix4x4f rhs) { ... } I came from a C++ background, and I would have written: Matrix4x4f opBinary(string

Re: how to benchmark pure functions?

2022-10-29 Thread max haughton via Digitalmars-d-learn
On Thursday, 27 October 2022 at 18:41:36 UTC, Dennis wrote: On Thursday, 27 October 2022 at 17:17:01 UTC, ab wrote: How can I prevent the compiler from removing the code I want to measure? With many C compilers, you can use volatile assembly blocks for that. With LDC -O3, a regular assembly

Re: Solving optimization problems with D

2023-01-01 Thread max haughton via Digitalmars-d-learn
On Sunday, 1 January 2023 at 21:11:06 UTC, Ogi wrote: I’ve read this [series if articles](https://www.gamedeveloper.com/design/decision-modeling-and-optimization-in-game-design-part-1-introduction) about using Excel Solver for all kinds of optimization problems. This is very neat, but of course,

Re: Can we ease WASM in D ?

2022-11-16 Thread max haughton via Digitalmars-d-learn
On Wednesday, 16 November 2022 at 23:00:40 UTC, Adam D Ruppe wrote: On Wednesday, 16 November 2022 at 22:51:31 UTC, bioinfornatics wrote: [...] It would be pretty cool if you could just mark `@wasm` on a function and have it magically convert... the dcompute thing i *think* does something

  1   2   >