Re: Print debug data

2024-04-24 Thread mw via Digitalmars-d-learn
On Monday, 17 July 2023 at 03:43:04 UTC, Alain De Vos wrote: Is it possible to print runtime memory usage of: -The stack -The heap -The garbage collector ? And how to print the memory stats of each class / struct type? 

Re: Recommendations on porting Python to D

2024-04-25 Thread mw via Digitalmars-d-learn
On Wednesday, 24 April 2024 at 22:07:41 UTC, Chris Piker wrote: Python-AST to D source converter may already exist? https://github.com/joortcom/eiffel_rename/tree/main/yi A rudimentary converter from (extended) Python to D. Maybe you can use it as a starting point. It uses: PEG parser gene

Re: Recommendations on porting Python to D

2024-04-25 Thread mw via Digitalmars-d-learn
BTW, maybe you can also try Mojo: https://github.com/modularml/mojo

Recommendations for good concurrent hashset (esp. for strings)?

2024-05-01 Thread mw via Digitalmars-d-learn
Hi, I'm looking for recommendations for good concurrent hashset (esp. for strings)? Any libraries? Thanks.

Re: Recommendations on porting Python to D

2024-05-03 Thread mw via Digitalmars-d-learn
On Friday, 3 May 2024 at 17:38:10 UTC, Chris Piker wrote: On Thursday, 25 April 2024 at 16:57:53 UTC, mw wrote: On Wednesday, 24 April 2024 at 22:07:41 UTC, Chris Piker wrote: Python-AST to D source converter may already exist? https://github.com/joortcom/eiffel_rename/tree/main/yi A rudime

Re: Recommendations on porting Python to D

2024-05-23 Thread mw via Digitalmars-d-learn
On Friday, 3 May 2024 at 17:53:41 UTC, mw wrote: On Friday, 3 May 2024 at 17:38:10 UTC, Chris Piker wrote: On Thursday, 25 April 2024 at 16:57:53 UTC, mw wrote: [...] Thanks for the suggestions. I put the question aside for a bit, but yesterday ran across a python transpiler here: https

Re: Parallel safe associative array?

2024-05-24 Thread mw via Digitalmars-d-learn
https://code.dlang.org/packages/rust_interop_d wrapped: DashMap: is an implementation of a concurrent associative array/hashmap in Rust.

Re: Problem with clear on shared associative array?

2024-05-26 Thread mw via Digitalmars-d-learn
On Monday, 27 May 2024 at 00:43:47 UTC, Serg Gini wrote: On Sunday, 26 May 2024 at 20:15:54 UTC, Andy Valencia wrote: For others wrestling with this issue, I found out how to cast to unshared at this article: You can check also this solution https://github.com/DmitryOlshansky/sharded-map

What's the latest GDC stable release version?

2024-06-16 Thread mw via Digitalmars-d-learn
Hi, What's the latest GDC stable release version? The GDC link on: https://dlang.org/download.html is very out dated. I think it at least should show the latest version number, and link to the announcement. Thanks.

Re: What's the latest GDC stable release version?

2024-06-17 Thread mw via Digitalmars-d-learn
On Monday, 17 June 2024 at 15:33:46 UTC, Dejan Lekic wrote: On Sunday, 16 June 2024 at 16:26:08 UTC, mw wrote: Hi, What's the latest GDC stable release version? Stable release version is the same as stable GCC release version. Find it here: https://gcc.gnu.org/ (GDC is part of the GCC proj

Re: What's the latest GDC stable release version?

2024-06-17 Thread mw via Digitalmars-d-learn
and GDC 14: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=09992f8b881aa2dfbee1e9d6954c3ca90cd3fe41 So GDC 14.1 includes the D language at v2.108.0. This is wonderful: Synchronizing with the upstream release of v2.108.0. BTW, if the following two pages are updated with version information,

Re: ImportC "no include path set"

2024-06-21 Thread mw via Digitalmars-d-learn
On Monday, 6 February 2023 at 14:35:53 UTC, bachmeier wrote: On Monday, 6 February 2023 at 06:55:02 UTC, Elfstone wrote: So how am I supposed to set the include path? https://dlang.org/spec/importc.html#preprocessor The -Ppreprocessorflag switch passes preprocessorflag to the preprocessor.

importC Error: undefined identifier `__atomic_thread_fence`

2024-06-21 Thread mw via Digitalmars-d-learn
Looks like `__atomic_thread_fence` is a GCC built-in function, so how to make importC recognize it? Thanks.

Re: ImportC in a Dub project

2024-06-21 Thread mw via Digitalmars-d-learn
On Friday, 28 October 2022 at 19:08:47 UTC, Steven Schveighoffer wrote: On 10/28/22 2:43 PM, Carsten Schlote wrote: On Friday, 28 October 2022 at 18:31:25 UTC, Steven Schveighoffer wrote: Are you passing the c file to the compiler? Also, you must be ... By default dub does not build C files

Why `foo.x.saa.aa` and `foo.y.saa.aa` is the same? `shared_AA.saa` should still be instance variable, not class variable, right?

2024-06-24 Thread mw via Digitalmars-d-learn
Sorry about the silly code, but I just tried this: ``` $ cat shared_aa.d import std; synchronized class shared_AA_class { private: int[int] aa; alias aa this; public: void print() { writeln(&aa, aa); } } struct shared_AA { shared_AA_class saa = new shared_AA_class(); //

Re: Why `foo.x.saa.aa` and `foo.y.saa.aa` is the same? `shared_AA.saa` should still be instance variable, not class variable, right?

2024-06-24 Thread mw via Digitalmars-d-learn
On Tuesday, 25 June 2024 at 02:25:14 UTC, Richard (Rikki) Andrew Cattermole wrote: On 25/06/2024 2:16 PM, mw wrote: struct shared_AA {   shared_AA_class saa = new shared_AA_class();  // by this syntax `saa` is still instance variable?   alias saa this; } When you specify an initializer lik

Re: Why `foo.x.saa.aa` and `foo.y.saa.aa` is the same? `shared_AA.saa` should still be instance variable, not class variable, right?

2024-06-25 Thread mw via Digitalmars-d-learn
On Tuesday, 25 June 2024 at 21:13:44 UTC, Nick Treleaven wrote: On Tuesday, 25 June 2024 at 02:16:25 UTC, mw wrote: Why `foo.x.saa.aa` and `foo.y.saa.aa` is the same? (and of course print out the same contents). `shared_AA.saa` should still be instance variable, not class variable, right? `

Re: Why `foo.x.saa.aa` and `foo.y.saa.aa` is the same? `shared_AA.saa` should still be instance variable, not class variable, right?

2024-06-25 Thread mw via Digitalmars-d-learn
On Tuesday, 25 June 2024 at 21:13:44 UTC, Nick Treleaven wrote: I think in the next edition of D we can forbid tail mutable initializers. It is still (or maybe only) useful for fields of a singleton class.

Re: Why `foo.x.saa.aa` and `foo.y.saa.aa` is the same? `shared_AA.saa` should still be instance variable, not class variable, right?

2024-06-25 Thread mw via Digitalmars-d-learn
On Wednesday, 26 June 2024 at 01:17:01 UTC, mw wrote: On Tuesday, 25 June 2024 at 21:13:44 UTC, Nick Treleaven wrote: I think in the next edition of D we can forbid tail mutable initializers. It is still (or maybe only) useful for fields of a singleton class. But a compiler warning messa

Re: Recommendations on porting Python to D

2024-07-12 Thread mw via Digitalmars-d-learn
On Friday, 3 May 2024 at 17:38:10 UTC, Chris Piker wrote: On Thursday, 25 April 2024 at 16:57:53 UTC, mw wrote: On Wednesday, 24 April 2024 at 22:07:41 UTC, Chris Piker wrote: Python-AST to D source converter may already exist? https://github.com/joortcom/eiffel_rename/tree/main/yi A rudime

Re: Recommendations on porting Python to D

2024-07-12 Thread mw via Digitalmars-d-learn
On Friday, 12 July 2024 at 18:07:50 UTC, mw wrote: On Friday, 3 May 2024 at 17:38:10 UTC, Chris Piker wrote: ... Hi, I have made basic py2many.pyd work at language/syntax level in my dlang fork: https://github.com/mw66/py2many/tree/dlang The following examples works now: https://github.c

std.container.rbtree has no search method?! e.g. `contains`, `canFind`

2024-07-13 Thread mw via Digitalmars-d-learn
Hi, on doc: https://dlang.org/phobos/std_container_rbtree.html#.RedBlackTree I cannot find any search method?! e.g. `contains`, `canFind`. Is this a over look? Or there are such functions else where?

Re: std.container.rbtree has no search method?! e.g. `contains`, `canFind`

2024-07-14 Thread mw via Digitalmars-d-learn
On Sunday, 14 July 2024 at 02:01:44 UTC, Steven Schveighoffer wrote: On Saturday, 13 July 2024 at 17:41:42 UTC, mw wrote: Hi, on doc: https://dlang.org/phobos/std_container_rbtree.html#.RedBlackTree I cannot find any search method?! e.g. `contains`, `canFind`. Is this a over look? Or there a

Re: Recommendations on porting Python to D

2024-07-15 Thread mw via Digitalmars-d-learn
On Friday, 12 July 2024 at 18:07:50 UTC, mw wrote: On Friday, 3 May 2024 at 17:38:10 UTC, Chris Piker wrote: On Thursday, 25 April 2024 at 16:57:53 UTC, mw wrote: On Wednesday, 24 April 2024 at 22:07:41 UTC, Chris Piker wrote: Python-AST to D source converter may already exist? https://git

Re: Recommendations on porting Python to D

2024-08-08 Thread mw via Digitalmars-d-learn
FYI, the code has been merged into the main branch already: https://github.com/py2many/py2many/tree/main/pyd On Thursday, 8 August 2024 at 20:20:11 UTC, Chris Piker wrote: On Friday, 12 July 2024 at 18:07:50 UTC, mw wrote: I have made basic py2many.pyd work at language/syntax level in my dlan

Re: Do you have a better way to remove element from a array?

2024-08-10 Thread mw via Digitalmars-d-learn
On Thursday, 5 February 2015 at 14:09:10 UTC, bearophile wrote: Tobias Pankrath: Works as designed: http://dlang.org/phobos/std_algorithm.html#.remove Unfortunately it's one of the worst designed functions of Phobos: https://issues.dlang.org/show_bug.cgi?id=10959 Bye, bearophile Hit this

Re: How pretty-print a struct?

2022-03-31 Thread mw via Digitalmars-d-learn
On Thursday, 31 March 2022 at 06:35:15 UTC, ZZ wrote: Hi, Is there an easy way to pretty-print a struct which also includes arrays? pretty_array does a very good job for arrays. If you want the field variable names in the output, you can use: https://code.dlang.org/packages/jdiutil htt

one liner to split a string into every n chars?

2022-04-12 Thread mw via Digitalmars-d-learn
Hi, What's the D's idiom to split a string into an array of every n chars? (prefer one liner) Thanks.

Re: Does D programming language have work steal queue?

2022-05-22 Thread mw via Digitalmars-d-learn
On Sunday, 22 May 2022 at 21:07:19 UTC, zoujiaqing wrote: Does D language have task steal queue? The requirements are high-performance, lock-free, and thread-safe. I have a C's liblfds D wrapper: https://github.com/mw66/liblfdsd right now only bmm and bss queue are wrapped. It's not in dub

Re: Does D programming language have work steal queue?

2022-05-22 Thread mw via Digitalmars-d-learn
On Sunday, 22 May 2022 at 22:37:43 UTC, Stefan Koch wrote: On Sunday, 22 May 2022 at 21:07:19 UTC, zoujiaqing wrote: Does D language have task steal queue? The requirements are high-performance, lock-free, and thread-safe. I have one called fluffy: https://github.com/UplinkCoder/fluffy Th

Re: Does D programming language have work steal queue?

2022-05-23 Thread mw via Digitalmars-d-learn
On Monday, 23 May 2022 at 23:07:00 UTC, zoujiaqing wrote: On Sunday, 22 May 2022 at 23:34:19 UTC, mw wrote: On Sunday, 22 May 2022 at 21:07:19 UTC, zoujiaqing wrote: Does D language have task steal queue? The requirements are high-performance, lock-free, and thread-safe. I have a C's liblfds

Re: Does D programming language have work steal queue?

2022-06-05 Thread mw via Digitalmars-d-learn
I will try it. It's in dub now: https://code.dlang.org/packages/liblfdsd Also added queue_umm: unbounded,manyproducer,many_consumer, lock-free queue

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

2022-06-06 Thread mw via Digitalmars-d-learn
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(); // gc-allocated owning object ... } ``` So when

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

2022-06-06 Thread mw via Digitalmars-d-learn
On Monday, 6 June 2022 at 22:22:05 UTC, max haughton wrote: float[] doesn't contain pointers, so the GC won't do anything to or with it. does every array have a .ptr attr? https://dlang.org/spec/arrays.html Dynamic Array Properties .ptrReturns a pointer to the first element of the array.

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

2022-06-07 Thread mw via Digitalmars-d-learn
On Tuesday, 7 June 2022 at 13:56:23 UTC, Steven Schveighoffer wrote: So you are safe, it will see the pointer inside the array reference, and see that it doesn't point at GC memory, so nothing further will be done. Thanks for the detailed explanation, and everyone who has replied.

Re: 'each' can take static arrays

2022-06-10 Thread mw via Digitalmars-d-learn
On Friday, 10 June 2022 at 17:27:13 UTC, Adam D Ruppe wrote: On Friday, 10 June 2022 at 16:59:04 UTC, Ali Çehreli wrote: Why the inconsistency? Phobos has dozens of random special cases throughout. I'd prefer if these were all removed, but right now there's just some functions that special c

Re: Bug in dmd?

2022-06-15 Thread mw via Digitalmars-d-learn
Create a simple test case, file bug at: https://issues.dlang.org/

Re: Consuming D libraries from other languages

2022-06-15 Thread mw via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 17:37:32 UTC, Templated Person wrote: It there any resources on how to build D static (`.lib` / `.a`) and dynamic libraries (`.dll` / `.so`), and then use them from C? Do I need to link and initialize phobos somehow? What if I don't want to use the D runtime? Wha

Python <==> d call both ways example (with PyD and autowrap)?

2022-06-22 Thread mw via Digitalmars-d-learn
Hi, I know with PyD, D can call Python, and with autowrap, Python can call a D .dll, I'm just wondering if someone can show an example that Python <==> d can call both ways? esp. show passing D objects to Python and then call its member function there, and vice versa. Thanks.

Re: Python <==> d call both ways example (with PyD and autowrap)?

2022-06-22 Thread mw via Digitalmars-d-learn
On Thursday, 23 June 2022 at 02:35:25 UTC, Tejas wrote: IIRC the best you can do is embed a Python interpreter inside a D program https://pyd.readthedocs.io/en/latest/embed.html Thanks. I tried something like this: https://github.com/symmetryinvestments/autowrap/issues/314 Although the

Re: How to call a function from a dll created with d ?

2022-07-01 Thread mw via Digitalmars-d-learn
On Friday, 1 July 2022 at 19:11:16 UTC, Vinod KC wrote: Hi all, I have created a dll file with this code. ```d module dimedll; export void testFunc() { writeln("This is from dll"); } ``` void main() { log("Lets build our own ime"); testFunc(); } ``` ``` di

Re: How to call a function from a dll created with d ?

2022-07-01 Thread mw via Digitalmars-d-learn
On Friday, 1 July 2022 at 21:15:50 UTC, Vinod K Chandran wrote: On Friday, 1 July 2022 at 21:02:20 UTC, mw wrote: I think the problem is the linker looking for dime.testFunc, while your lib function is dimedll.testFunc Thanks for the reply. What about this `mixin SimpleDllMain;` I suspect

Re: How to call a function from a dll created with d ?

2022-07-02 Thread mw via Digitalmars-d-learn
On Saturday, 2 July 2022 at 20:43:41 UTC, Vinod KC wrote: On Saturday, 2 July 2022 at 14:32:11 UTC, apz28 wrote: dmd -of=dimedll.dll dimedll.d dimedll.def dmd dime.d dimedll.di Thanks for the reply. Well, I am sorry to say that your suggestions resulted in failure. First of all, when I used

Re: How long will DUB update a package from github release?

2022-08-15 Thread mw via Digitalmars-d-learn
On Tuesday, 16 August 2022 at 02:12:32 UTC, Domain wrote: The project [Lumars](https://code.dlang.org/packages/lumars) has released a new version 10 days ago in [github](https://github.com/BradleyChatha/lumars). But still unavailable in DUB. It has problems recently, you can log a bug here:

what's this error: allocatestack.c:384: advise_stack_range: Assertion `freesize < size' failed.

2022-08-23 Thread mw via Digitalmars-d-learn
Hi, I got an error message when my program exits (the main functionality is done, I guess the error happened during D runtime's cleanup) : allocatestack.c:384: advise_stack_range: Assertion `freesize < size' failed. I suspect it somehow related to I pass some (object) pointers to foreign

is it possible synchronized(null) ? i.e NO-OP

2022-08-26 Thread mw via Digitalmars-d-learn
Hi, I haven't tried, but can I do: ``` void foo(lots of params) { Object lock = (a particular condition) ? realLock : null; synchronized(lock) { // lots of complex code block here } } ``` i.e depending on a a particular condition, the complex code block either need to be sync-prote

how to use dub to run all / chosen dependency lib's unittests

2022-09-19 Thread mw via Digitalmars-d-learn
Hi, I'm using dub.json to specify the dependencies libs for my project. I'm just wondering how I can use dub to run all the tests of those dependencies libs (of the transitive closure of *all* the libs) to make sure my project is built on a very solid foundation? I know this could be very

Re: how to use dub to run all / chosen dependency lib's unittests

2022-09-19 Thread mw via Digitalmars-d-learn
On Monday, 19 September 2022 at 23:57:31 UTC, Steven Schveighoffer wrote: I don't see any specific command to do it in dub itself. I've recently discovered that `dub describe` gives you the directories of all your dependencies in a JSON format. I used this to write an install script for de

Best way to read CSV data file into Mir (2d array) ndslice?

2022-09-20 Thread mw via Digitalmars-d-learn
Hi, I'm just wondering what is the best way to read CSV data file into Mir (2d array) ndslice? Esp. if it can parse date into int/float. I searched a bit, but can't find any example. Thanks.

Re: Best way to read CSV data file into Mir (2d array) ndslice?

2022-09-21 Thread mw via Digitalmars-d-learn
On Wednesday, 21 September 2022 at 19:14:30 UTC, jmh530 wrote: I just tried doing it with `std.csv`, but my version was a bit awkward since it doesn't seem quite so straightforward to just take the result of csvReader and put it in a array. I had to read it in there. I also wanted to allocate

Re: Interfacing with Rust

2022-09-29 Thread mw via Digitalmars-d-learn
On Thursday, 29 September 2022 at 16:02:43 UTC, Ruby The Roobster wrote: Is there any way one can interface with Rust, such as with a struct, or a function? I know that rust has an extern keyword, but I can't get it to work. https://code.dlang.org/packages/rust_interop_d Read the notes on

Re: How to do alligned allocation?

2022-09-30 Thread mw via Digitalmars-d-learn
On Friday, 30 September 2022 at 15:57:22 UTC, Quirin Schroll wrote: When I do `new void[](n)`, is that buffer allocated with an alignment of 1 or what are the guarantees? How can I set an alignment? Also, is the alignment of any type guaranteed to be a power of 2? https://dlang.org/library/co

Re: How to do alligned allocation?

2022-09-30 Thread mw via Digitalmars-d-learn
On Friday, 30 September 2022 at 16:23:00 UTC, mw wrote: On Friday, 30 September 2022 at 15:57:22 UTC, Quirin Schroll wrote: When I do `new void[](n)`, is that buffer allocated with an alignment of 1 or what are the guarantees? How can I set an alignment? Also, is the alignment of any type guara

Re: Interfacing with Rust

2022-09-30 Thread mw via Digitalmars-d-learn
extern(C++)? Why do you think Rust export C++ linkage? And why do you think Rust export some kind of OO object model linkage? Do it in plain C style, you may make it work. As said, check how it's done in: https://code.dlang.org/packages/rust_interop_d

csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-02 Thread mw via Digitalmars-d-learn
Hi, I'm following the example on https://dlang.org/phobos/std_csv.html ``` class Layout { int value; double other; string name; int extra_field; // un-comment to see the error } void main() { import std.csv; import std.stdio: write, writeln,

Re: csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-02 Thread mw via Digitalmars-d-learn
``` text.csvReader!Layout(["b","c","a"]); // Read only these column ``` The intention is very clear: only read the selected columns from the csv, and for any other fields of class Layout, just ignore (with the default D .init value).

Re: csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-02 Thread mw via Digitalmars-d-learn
On Sunday, 2 October 2022 at 21:03:40 UTC, rassoc wrote: But say, I'm curious, what's the purpose of adding an optional/useless contents field? What's the use-case here? We have a class/struct for a data record, some of its data fields need to be saved/loaded from CSV files; while there are

Re: csvReader: how to read only selected columns while the class Layout has extra field?

2022-10-03 Thread mw via Digitalmars-d-learn
On Monday, 3 October 2022 at 18:02:51 UTC, Salih Dincer wrote: On Sunday, 2 October 2022 at 19:48:52 UTC, mw wrote: ``` text.csvReader!Layout(["b","c","a"]); // Read only these column ``` The intention is very clear: only read the selected columns from the csv, and for any other fie

cannot gdb LDC build binary: Segmentation fault

2022-10-06 Thread mw via Digitalmars-d-learn
Hi, I have a LDC (1.30.0) built binary on Ubuntu 18.04.5 LTS x86_64, the program core dumps somewhere, so I want to debug it. However under gdb, the program fails as soon as I start it: ``` (gdb) r [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-lin

best memory profiler (to debug accumulated allocation of each line) for D?

2022-10-14 Thread mw via Digitalmars-d-learn
Hi, With CPU profiler, we can see the accumulated run time of each function & line, I'm wondering if there is such a profiler for memory allocation? The reason I'm asking is because I suspect there are some small but repetitive memory allocation going on in the libraries (in C and D) I'm us

Re: best memory profiler (to debug accumulated allocation of each line) for D?

2022-10-14 Thread mw via Digitalmars-d-learn
On Friday, 14 October 2022 at 19:06:12 UTC, rassoc wrote: On 10/14/22 20:45, mw via Digitalmars-d-learn wrote: Any suggestions? There's `dmd -profile=gc` or `dub build --build=profile-gc`. Thanks. I eventually use valgrind --tool=massif, and found the problem was in a underlying C li

Re: library to solve the system of linear equations

2022-10-17 Thread mw via Digitalmars-d-learn
On Monday, 17 October 2022 at 19:54:12 UTC, Yura wrote: it is possible to install the most recent ldc and gdc compilers on Ubuntu 18.04? Yes, I used LDC on the same system.

Re: library to solve the system of linear equations

2022-10-17 Thread mw via Digitalmars-d-learn
On Monday, 17 October 2022 at 20:22:47 UTC, jmh530 wrote: If you have a problem with support for mir, submit a bug report. I don't think gdc is supported, but ldc should be. The latest version of Mir can only be compiled with latest Ldc 1.30, 1.29 doesn't work. Maybe Mir should add static

Re: library to solve the system of linear equations

2022-10-17 Thread mw via Digitalmars-d-learn
On Monday, 17 October 2022 at 20:39:10 UTC, rikki cattermole wrote: On 18/10/2022 9:37 AM, mw wrote: Maybe Mir should add static check for supported complier versions, rather than let user try and error. Dub has dependency checks for compiler/dub in it. It doesn't need to be in code. Not ev

Re: library to solve the system of linear equations

2022-10-18 Thread mw via Digitalmars-d-learn
On Tuesday, 18 October 2022 at 09:56:09 UTC, Siarhei Siamashka wrote: On Monday, 17 October 2022 at 20:05:24 UTC, mw wrote: On Monday, 17 October 2022 at 19:54:12 UTC, Yura wrote: it is possible to install the most recent ldc and gdc compilers on Ubuntu 18.04? Yes, I used LDC on the same sys

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread mw via Digitalmars-d-learn
On Wednesday, 19 October 2022 at 01:30:23 UTC, H. S. Teoh wrote: On Wed, Oct 19, 2022 at 01:15:37AM +, Adam D Ruppe via it only applies to types, not to functions. Wat... so what's the use of it then? So it's not possible to mark the return value of an int function @mustUse without mak

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread mw via Digitalmars-d-learn
On Wednesday, 19 October 2022 at 01:38:27 UTC, Adam D Ruppe wrote: On Wednesday, 19 October 2022 at 01:34:54 UTC, mw wrote: Is there any (design) doc about this? scroll up, click the link from this very thread. https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1038.md#design-goals-an

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-18 Thread mw via Digitalmars-d-learn
@mustuse as a function attribute was in the original version of the DIP. It was vetoed by Walter. Thus, only the type attribute remains in the accepted version. Let's continue the discussion here: https://forum.dlang.org/thread/nmornkxaxddfziqmq...@forum.dlang.org in general, it's about: comm

druntime thread (from foreach parallel?) cleanup bug

2022-11-01 Thread mw via Digitalmars-d-learn
My program received signal SIGSEGV, Segmentation fault. Its simplified structure looks like this: ``` void foo() { ... writeln("done"); // saw this got printed! } int main() { foo(); return 0; } ``` So, just before the program exit, it failed. I suspect druntime has a thread (maybe

Re: druntime thread (from foreach parallel?) cleanup bug

2022-11-01 Thread mw via Digitalmars-d-learn
Can you show a code snippet that includes the parallel foreach? (It's just a very straight forward foreach on an array; as I said it may not be relevant.) And I just noticed, one of the thread trace points to here: https://github.com/huntlabs/hunt/blob/master/source/hunt/util/DateTime.d#L43

Re: druntime thread (from foreach parallel?) cleanup bug

2022-11-01 Thread mw via Digitalmars-d-learn
On Tuesday, 1 November 2022 at 18:18:45 UTC, Steven Schveighoffer wrote: And I just noticed, one of the thread trace points to here: https://github.com/huntlabs/hunt/blob/master/source/hunt/util/DateTime.d#L430 ``` class DateTime {   shared static this() {     ...     dateThread.isDaemon

difference between x.atomicOp!"+="(1) and atomicFetchAdd(x, 1)?

2022-11-10 Thread mw via Digitalmars-d-learn
Hi, Anyone can help explain what is the difference between x.atomicOp!"+="(1) and atomicFetchAdd(x, 1)? From the doc, their return values are different atomicOp Performs the binary operation 'op' on val using 'mod' as the modifier. Returns: The result of the operation. atomicFetchAdd Atom

Re: difference between x.atomicOp!"+="(1) and atomicFetchAdd(x, 1)?

2022-11-10 Thread mw via Digitalmars-d-learn
On Thursday, 10 November 2022 at 18:30:16 UTC, Paul Backus wrote: On Thursday, 10 November 2022 at 17:04:31 UTC, mw wrote: Hi, Anyone can help explain what is the difference between x.atomicOp!"+="(1) and atomicFetchAdd(x, 1)? Looking at the source in druntime, `atomicOp!"+="` forwards to `

does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn
Hi, I'm mem-profiling a multi-threaded program, and want it to exit early, so I added a call ``` core.stdc.stdlib.exit(-1); ``` in a loop in one of the thread. However when the program reached this point, it seems hang: it's not exiting, and CPU usage dropped to 0%. I'm wondering does dmd

Re: does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 18:48:42 UTC, mw wrote: BTW, can --build=profile-gc can intercept "Ctrl+C" and generate *partial* report file? And what's the suggested proper way to do early exit, and still let --build=profile-gc generate reports? I tried presss "Ctrl+C", and that cannot stop

Re: does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 18:51:17 UTC, mw wrote: On Sunday, 13 November 2022 at 18:48:42 UTC, mw wrote: BTW, can --build=profile-gc can intercept "Ctrl+C" and generate *partial* report file? And what's the suggested proper way to do early exit, and still let --build=profile-gc generate

Re: Proper way to exit with specific exit code?

2022-11-13 Thread mw via Digitalmars-d-learn
On Saturday, 19 September 2020 at 06:11:15 UTC, Jacob Carlborg wrote: On 2020-09-17 16:58, drathier wrote: What's the proper way to exit with a specific exit code? I found a bunch of old threads discussing this, making sure destructors run and the runtime terminates properly, all of which see

Re: does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 19:02:29 UTC, mw wrote: BTW, can --build=profile-gc can intercept "Ctrl+C" and generate *partial* report file? And what's the suggested proper way to do Is there a profile-gc plugin function I can call in the middle of my program to generate *partial* report fi

Re: Proper way to exit with specific exit code?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 21:16:32 UTC, mw wrote: I even tried core.stdc.stdlib.exit(-1), it does not work. Tried ``` import core.runtime; Runtime.terminate(); core.stdc.stdlib.exit(-1); ``` Still does not work.

Re: Proper way to exit with specific exit code?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 22:06:09 UTC, Imperatorn wrote: On Sunday, 13 November 2022 at 21:37:47 UTC, mw wrote: On Sunday, 13 November 2022 at 21:16:32 UTC, mw wrote: I even tried core.stdc.stdlib.exit(-1), it does not work. Tried ``` import core.runtime; Runtime.terminate(); cor

Re: Proper way to exit with specific exit code?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 22:17:32 UTC, mw wrote: On Sunday, 13 November 2022 at 22:06:09 UTC, Imperatorn wrote: On Sunday, 13 November 2022 at 21:37:47 UTC, mw wrote: On Sunday, 13 November 2022 at 21:16:32 UTC, mw wrote: I even tried core.stdc.stdlib.exit(-1), it does not work. Tried

Re: Proper way to exit with specific exit code?

2022-11-13 Thread mw via Digitalmars-d-learn
On Sunday, 13 November 2022 at 22:42:45 UTC, mw wrote: On Sunday, 13 November 2022 at 22:17:32 UTC, mw wrote: On Sunday, 13 November 2022 at 22:06:09 UTC, Imperatorn wrote: On Sunday, 13 November 2022 at 21:37:47 UTC, mw wrote: On Sunday, 13 November 2022 at 21:16:32 UTC, mw wrote: I even tr

in dub single file build how to pass "-J" options?

2022-12-21 Thread mw via Digitalmars-d-learn
I have example.d: ``` #!/usr/bin/env dub /+dub.sdl: dependency "tkd" version="~>1.1.14" +/ ... ``` $ dub build --single example.d ... Error: need `-J` switch to import text file `folder_page.png` I'm wondering how to pass "-J" options? BTW, for such single file build, do I have to use dub

Re: in dub single file build how to pass "-J" options?

2022-12-21 Thread mw via Digitalmars-d-learn
On Thursday, 22 December 2022 at 02:19:23 UTC, mw wrote: I have example.d: ``` #!/usr/bin/env dub /+dub.sdl: dependency "tkd" version="~>1.1.14" +/ ... ``` $ dub build --single example.d ... Error: need `-J` switch to import text file `folder_page.png` I'm wondering how to pass "-J" option

How to debug/set breakpoint a dynamic library.so ?

2023-02-09 Thread mw via Digitalmars-d-learn
The dynamic library.so is built from D (with pyd), and invoked from Python. I'm just wondering How to debug/set breakpoint a dynamic library.so ? Can someone give an example? Thanks.

Re: How to debug/set breakpoint a dynamic library.so ?

2023-02-09 Thread mw via Digitalmars-d-learn
On Thursday, 9 February 2023 at 19:26:59 UTC, Ali Çehreli wrote: On 2/9/23 06:00, mw wrote: The dynamic library.so is built from D (with pyd), and invoked from Python. I'm just wondering How to debug/set breakpoint a dynamic library.so ? Can someone give an example? Thanks. I may be tota

help: Unresolvable dependencies to package openssl

2023-03-08 Thread mw via Digitalmars-d-learn
Hi, In my dub.json, I have: ``` "dependencies": { "apache-thrift": "==0.16.0", ... } "subConfigurations": { "apache-thrift": "use_openssl_1_1", "pyd": "python39" }, `

Re: help: Unresolvable dependencies to package openssl

2023-03-09 Thread mw via Digitalmars-d-learn
On Thursday, 9 March 2023 at 01:22:08 UTC, Steven Schveighoffer wrote: This is a known limitation -- dub builds the selections file based on *all* configurations in the file. If you have conflicting ones, it will not know what to pick. However, if you manually construct the selections file,

As of 2023, we still cannot declaring a constant string[char] AA?

2023-05-16 Thread mw via Digitalmars-d-learn
Hi, I just run into this problem again: https://stackoverflow.com/questions/26861708/what-is-the-syntax-for-declaring-a-constant-stringchar-aa So, the solution still is to use: ``` static this () { ... } ``` What happened to this comments: """ It should be noted that this restriction will ev

how to skip empty field in csvReader?

2023-06-05 Thread mw via Digitalmars-d-learn
Hi, https://run.dlang.io/is/9afmT1 ``` void main() { import std.csv; import std.stdio: write, writeln, writef, writefln; import std.algorithm.comparison : equal; string text = "Hello;65;;\nWorld;123;7.5"; struct Layout { string name; int value; dou

Re: how to skip empty field in csvReader?

2023-06-06 Thread mw via Digitalmars-d-learn
On Tuesday, 6 June 2023 at 14:18:25 UTC, Steven Schveighoffer wrote: On 6/6/23 1:09 AM, mw wrote: Is there a way to tell csvReader to skip such empty fields? What I have done is specify that it's a string, and then handle the conversion myself. The std library need to be enhanced to skip

Re: looking for work-around: _d_assocarrayliteralTX segfault assigning a shared associative array an AA literal

2023-06-13 Thread mw via Digitalmars-d-learn
On Tuesday, 13 June 2023 at 17:12:41 UTC, Anonymouse wrote: On Tuesday, 13 June 2023 at 17:06:55 UTC, mw wrote: Does anyone know how to fix it? or any work-around? Thanks. I don't know if it's *correct* or not, but I think I did this at the time to work around it. ``` shared string[string

looking for hint to debug a strange multi-thread bug (grpc-d-core)

2023-06-13 Thread mw via Digitalmars-d-learn
Hi, I recently found and started playing with the grpc-d-core[1] package, and my program structure looks like this: https://github.com/mw66/grpc-demo/blob/master/source/main.d If I run L64 alone (without L66 ~ 79 grpc-d part): ``` 64: auto t = new Thread({fun();}).start(); ``` it works fine.

Re: looking for work-around: _d_assocarrayliteralTX segfault assigning a shared associative array an AA literal

2023-06-13 Thread mw via Digitalmars-d-learn
On Tuesday, 13 June 2023 at 22:21:10 UTC, Steven Schveighoffer wrote: As far as I can tell, this problem has been occurring for a long time. BTW, you don't need to define it in global space, just: ```d void main() { shared aa = ["abc": "123"]; } ``` I have to ask the old-timers on this fo

Re: looking for hint to debug a strange multi-thread bug (grpc-d-core)

2023-06-13 Thread mw via Digitalmars-d-learn
UPDATE: life is too short to debug dlang built-in AA to right, let's just use HashMap from emsi_containers https://github.com/mw66/grpc-d/blob/master/source/grpc/server/package.d#L25 ``` HashMap!(string, ServiceHandlerInterface) services; ``` After this change, the problem goes away. I think t

ldc link error on new machine: undefined reference to `_D6object9Throwable7messageMxFNbNfZAxa'

2023-06-14 Thread mw via Digitalmars-d-learn
Hi, I switched to a different machine to build my project, suddenly I got lots of link errors. (It builds fine on the old machine, and my software version are the same on both machines LDC - the LLVM D compiler (1.32.2)) e.g.: ``` ... /usr/bin/ld: /home//.dub/cache/cachetools/0.3.1/build/li

Re: ldc link error on new machine: undefined reference to `_D6object9Throwable7messageMxFNbNfZAxa'

2023-06-14 Thread mw via Digitalmars-d-learn
On Thursday, 15 June 2023 at 01:20:50 UTC, H. S. Teoh wrote: On Thu, Jun 15, 2023 at 12:49:30AM +, mw via Digitalmars-d-learn wrote: Hi, Recently encountered a similar problem, ultimately the cause was that my library paths turned out to be wrongly set, so it was picking up the wrong

Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread mw via Digitalmars-d-learn
Hi, I'm following this example: https://dlang.org/spec/cpp_interface.html#using_cpp_classes_from_d and try to wrap a std::list base.cpp ```cpp #include #include using namespace std; class Base { public: virtual void print3i(int a, int b, int c) = 0; }; class Derived : public B

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread mw via Digitalmars-d-learn
On Monday, 19 June 2023 at 05:32:23 UTC, Richard (Rikki) Andrew Cattermole wrote: This is just a guess, but I think the problem is the vtable is incomplete. Because of this the offsets are wrong. So you wouldn't be calling push_back. So, you mean on the D side, it need to list all the fields

Re: Using C++ Classes From D: dmd cannot link, while ldc segfault

2023-06-18 Thread mw via Digitalmars-d-learn
On Monday, 19 June 2023 at 05:39:51 UTC, mw wrote: Then it will be very tedious, esp. for such library class std::list. Is there a tool that can automate this? A related question: basically I want to pass an array of objects from D side to the Cpp side, is there any example showing how to

  1   2   3   >