Re: Is this dub link flag (-L-lcudart_static) a bug?

2025-05-16 Thread mw via Digitalmars-d-learn
On Friday, 16 May 2025 at 17:44:01 UTC, Matheus Catarino wrote: The problem presented shows that this library possibly has other dependencies. That symbol is defined in that library .a file: ``` $ nm /usr/local/cuda/lib64/libcudart_static.a | grep -w cudaGetDeviceProperties_v2 000426

Is this dub link flag (-L-lcudart_static) a bug?

2025-05-12 Thread mw via Digitalmars-d-learn
Hi, With ``` $ dub --version DUB version 1.39.0, built on Mar 20 2025 $ ldc2 --version LDC - the LLVM D compiler (1.40.1): ``` dub.json: ``` "lflags": [ ... "-L/usr/local/cuda/lib64", "-lcudart_static", ... ], ``` I got a link error: `undefined reference to 'cudaGetDeviceProp

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: 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: 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: 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

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: 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

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: 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: 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 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-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

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: 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

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 "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.

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: 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

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: 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

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: 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: 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

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-04-25 Thread mw via Digitalmars-d-learn
BTW, maybe you can also try Mojo: https://github.com/modularml/mojo

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: 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: dub: Could not resolve configuration for package demo

2024-03-15 Thread mw via Digitalmars-d-learn
On Friday, 15 March 2024 at 18:04:25 UTC, Inkrementator wrote: You'll have to either fix the old vibe-d version, or fork msgpack-rpc to work with current vibe-d, whatever is more appropriate and easier. I'm trying to fix it with the latest vibe-d 0.10.0, now the new error: ``` ../../src/msg

Re: dub: Could not resolve configuration for package demo

2024-03-15 Thread mw via Digitalmars-d-learn
On Friday, 15 March 2024 at 18:04:25 UTC, Inkrementator wrote: On Friday, 15 March 2024 at 17:48:26 UTC, mw wrote: ``` $ dub build Could not resolve configuration for package demo ``` Trying to build your dependency msgpack-rpc, it spits out ``` Warning The sub configuration directive "vi

Re: dub: Could not resolve configuration for package demo

2024-03-15 Thread mw via Digitalmars-d-learn
OK, looks something wrong with dub / or vibe-d 0.10.0 https://github.com/msgpack-rpc/msgpack-rpc-d/blob/master/examples/with_http_server/dub.sdl#L5 with ``` dependency "vibe-d" version="~>0.7.25" ``` `dub build` can at least starts. But ``` dependency "vibe-d" version="~>0.10.0" ``` ``` $ d

dub: Could not resolve configuration for package demo

2024-03-15 Thread mw via Digitalmars-d-learn
Very simple thing from https://dub.pm/getting-started/first-steps/ After I add dependencies, it cannot build: ``` $ cat dub.json { "authors": [ "mw" ], "copyright": "Copyright © 2024, mw", "description": "msgpack-rpc-d demo.", "license": "M

Re: length's type.

2024-02-07 Thread mw via Digitalmars-d-learn
On Thursday, 8 February 2024 at 05:56:57 UTC, Kevin Bailey wrote: I don't think it's productive to compare the behavior to C. C is now 50 years old. One would hope that D has learned a few things in that time. How many times does the following loop print? I ran into this twice doing the AoC e

Re: length's type.

2024-01-28 Thread mw via Digitalmars-d-learn
On Sunday, 28 January 2024 at 16:16:34 UTC, Olivier Pisano wrote: If .length were to be an int, D could not handle array of more than 2G bytes. The whole language would be useless on 64 bit systems. The array.length better to be *signed* `long` (signed size_t) instead of unsigned. Can yo

under gdb: received signal SIG34, Real-time event 34.; received signal SIG35, Real-time event 35

2023-11-14 Thread mw via Digitalmars-d-learn
Hi, I have this in ~/.gdbinit already: ``` handle SIGUSR1 SIGUSR2 nostop handle SIGUSR1 noprint handle SIGUSR2 noprint ``` Today I encountered: received signal SIG34, Real-time event 34. then I added to ~/.gdbinit ``` handle SIG34 nostop noprint pass noignore ``` Next, I got: received sign

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 01:54:12 UTC, Richard (Rikki) Andrew Cattermole wrote: On 17/10/2023 2:15 PM, mw wrote: On Tuesday, 17 October 2023 at 01:11:13 UTC, Richard (Rikki) Andrew Cattermole wrote: They are for structs as well. Ah?! I use quite a few struts, but I never have provided s

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 01:14:04 UTC, Richard (Rikki) Andrew Cattermole wrote: On 17/10/2023 1:58 PM, mw wrote: Oh the <_My_struct> part is my simplification, it is mangled as something like : _D6..<_My_struct>..__xtoHashFNbNeKxSQBlQBoQBiZm When dealing with linker errors, please do no

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 01:11:13 UTC, Richard (Rikki) Andrew Cattermole wrote: They are for structs as well. Ah?! I use quite a few struts, but I never have provided such two methods.

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 00:44:17 UTC, Richard (Rikki) Andrew Cattermole wrote: xtoHash and xopEquals are generated by the compiler automatically. These two are for `class`, but shouldn't be generated for `struct`, right?

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Tuesday, 17 October 2023 at 00:44:17 UTC, Richard (Rikki) Andrew Cattermole wrote: xtoHash and xopEquals are generated by the compiler automatically. Curiously those two symbol names are not demangling. Given this, I suspect the best thing to do is file a bug report with ldc with the code

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
On Monday, 16 October 2023 at 21:20:39 UTC, mw wrote: It's very hard to isolate the problem. I have comment out that piece part of code for now (non-essential part of my program): comment out where the struct is used, not the struct definition. Anyway, I will try some time later. BTW, the st

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
It's very hard to isolate the problem. I have comment out that piece part of code for now (non-essential part of my program): comment out where the struct is used, not the struct definition. Anyway, I will try some time later.

strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread mw via Digitalmars-d-learn
Hi, I just encountered a strange link error: I have a `struct` type `My_struct`, the program compiles fine, but at link time, it errors out: undefined reference to _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm undefined reference to _My_struct__xopEqualsMxFKxSQBlQBoQBiZb looks like it treats My_str

Re: is the array literal in a loop stack or heap allocated?

2023-10-10 Thread mw via Digitalmars-d-learn
On Wednesday, 11 October 2023 at 03:15:30 UTC, H. S. Teoh wrote: On Wed, Oct 11, 2023 at 02:54:53AM +, mw via Digitalmars-d-learn wrote: Hi, I want to confirm: in the following loop, is the array literal `a` vs. `b` stack or heap allocated? and how many times? void main() { int[2] a

is the array literal in a loop stack or heap allocated?

2023-10-10 Thread mw via Digitalmars-d-learn
Hi, I want to confirm: in the following loop, is the array literal `a` vs. `b` stack or heap allocated? and how many times? void main() { int[2] a; int[] b; int i; While(++i <=100) { a = [i, i+1]; // array literal b = [i, i+1]; } } Thanks.

Re: How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?

2023-10-09 Thread mw via Digitalmars-d-learn
On Monday, 9 October 2023 at 16:51:31 UTC, rempas wrote: On Monday, 9 October 2023 at 16:42:38 UTC, mw wrote: use: import std.conv; [...] Damn, sorry, forgot to mention. I cannot use Phobos. but you `import std.stdio;`? Or copy the std/conv.d over to your build, or copy / write a toStrin

Re: How to use ".stringof" to get the value of a variable and not the name of the variable (identifier) itself?

2023-10-09 Thread mw via Digitalmars-d-learn
use: import std.conv; ... i.to!string ... ``` import std.stdio; import std.conv; static foreach(i; 0 .. 10) { mixin(create_fn!(i.to!string)); } enum create_fn(string num) = ` void function_`~ num ~`() { writeln("Hello from function `~ num ~`!"); } `; void main() { function_9(); }

Re: allocated object address as high as 46th bit (i.e in the 131072 GB range)

2023-10-08 Thread mw via Digitalmars-d-learn
On Monday, 9 October 2023 at 05:57:47 UTC, Richard (Rikki) Andrew Cattermole wrote: As far as I'm aware, no cpu that you can get ahold of support more than 48bit of address space at the hardware level. There is simply no reason at this time to support more, due to the fact that nobody has impl

allocated object address as high as 46th bit (i.e in the 131072 GB range)

2023-10-08 Thread mw via Digitalmars-d-learn
https://dlang.org/library/core/bitop/bsr.html I'm trying to find out allocated object's address' space: ``` import std.stdio; import core.bitop; void main() { const size_t ONE_G = 1 << 30; char[][128] ptrs; foreach (i, ref ptr; ptrs) { ptr = new char[ONE_G]; if (ptr is null) {

Re: how to assign multiple variables at once by unpacking array?

2023-10-08 Thread mw via Digitalmars-d-learn
On Sunday, 8 October 2023 at 07:45:56 UTC, Andrea Fontana wrote: On Sunday, 8 October 2023 at 07:44:04 UTC, Andrea Fontana wrote: ``` int a,b,c; "1,2,3" .splitter(',') .zip(only(&a, &b, &c)) .each!(x => *x[1] = x[0].to!int); writeln(a, b, c); ``` or: ```

Re: is there a way to use sumtype in `switch/case` (with multiple statements)? or how can I get the `tag` and `storage`?

2023-10-07 Thread mw via Digitalmars-d-learn
On Saturday, 7 October 2023 at 19:30:23 UTC, mw wrote: On Saturday, 7 October 2023 at 19:25:51 UTC, mw wrote: Or how can I get the `tag` and `storage` myself? https://github.com/dlang/phobos/blob/a3f22129dd2a134338ca02b79ff0de242d7f016e/std/sumtype.d#L310 If I add this line to the above func

Re: is there a way to use sumtype in `switch/case` (with multiple statements)? or how can I get the `tag` and `storage`?

2023-10-07 Thread mw via Digitalmars-d-learn
On Saturday, 7 October 2023 at 19:25:51 UTC, mw wrote: Or how can I get the `tag` and `storage` myself? https://github.com/dlang/phobos/blob/a3f22129dd2a134338ca02b79ff0de242d7f016e/std/sumtype.d#L310 If I add this line to the above func `isF`: ``` writeln(t.tag); ``` it won't compile: s

is there a way to use sumtype in `switch/case` (with multiple statements)? or how can I get the `tag` and `storage`?

2023-10-07 Thread mw via Digitalmars-d-learn
https://dlang.org/library/std/sumtype.html seems right now the `match!(...)` template only generate a delegate, e.g. suppose the following (silly) code: ``` bool isF(Temperature t) { while (true) { t.match!( (Fahrenheit f) {return true;}, (_) {return false;} // I want to ret

Re: how to assign multiple variables at once by unpacking array?

2023-10-07 Thread mw via Digitalmars-d-learn
Interesting: in terms of easy of coding, clarity and future maintenance, which one is superior? The one liner in Python, or your "solution" with dozen lines of code? BTW, is that a solution at all? Did it achieved what the original goal asked in the OP question? So, who should learn from who

Re: How to get all modules in a package at CT?

2023-10-05 Thread mw via Digitalmars-d-learn
On Thursday, 5 October 2023 at 21:25:54 UTC, cc wrote: So how about at runtime? I just want the compiler to help to list them, instead of doing manually. At runtime, simply: ```d foreach (m; ModuleInfo) { writeln(m.name); } ``` However, Walter has hinted that he wants to remove Modul

Re: Getting all struct members and values with introspection avoiding string mixins

2023-10-05 Thread mw via Digitalmars-d-learn
On Thursday, 5 October 2023 at 21:41:38 UTC, cc wrote: If you have `T info`, T.tupleof[n] will always match up with info.tupleof[n]. You can think of `info.tupleof[n]` as being rewritten by the compiler in-place as info.whateverFieldThatIs. You might try this version (note the double {{ }}

Re: How to get all modules in a package at CT?

2023-10-05 Thread mw via Digitalmars-d-learn
On Thursday, 5 October 2023 at 20:07:38 UTC, user1234 wrote: No. Sorry. Generally compile time code cannot interact with the system. To be evaluable at compile time code has to be strongly pure, that is not the case of the function you would need. Otherwise you'd need a new traits for that..

Re: How to get all modules in a package at CT?

2023-10-05 Thread mw via Digitalmars-d-learn
On Saturday, 24 November 2018 at 15:21:57 UTC, Anonymouse wrote: On Saturday, 24 November 2018 at 08:44:19 UTC, Domain wrote: I have a package named command, and many modules inside it, such as command.build, command.pack, command.help... I want to get all these modules at compile time so that I

Re: Getting all struct members and values with introspection avoiding string mixins

2023-09-28 Thread mw via Digitalmars-d-learn
On Sunday, 1 May 2016 at 10:13:47 UTC, H. S. Teoh wrote: Using typeof(T.tupleof) seems a bit circuitous. Here's how I'd do it: void printStructInfo( T )( T info ) { import std.stdio : writefln; foreach (memb; __traits(allMembers, T)) {

Re: array index out of bound may not throw exception?

2023-07-21 Thread mw via Digitalmars-d-learn
On Friday, 21 July 2023 at 23:32:41 UTC, Adam D Ruppe wrote: On Friday, 21 July 2023 at 21:27:45 UTC, mw wrote: However, I just debugged a case, where out of bound array index didn't throw exception, and just hang the thread Uncaught exceptions in a thread terminate that thread and are report

array index out of bound may not throw exception?

2023-07-21 Thread mw via Digitalmars-d-learn
Hi, I have thought array index out of bound always throw exceptions. However, I just debugged a case, where out of bound array index didn't throw exception, and just hang the thread, which is much harder to debug (than exception which tells the exact error and source line location). So my q

Re: looking for recommendation: which thread safe logger library?

2023-07-12 Thread mw via Digitalmars-d-learn
On Wednesday, 12 July 2023 at 09:47:26 UTC, Danilo wrote: On Wednesday, 12 July 2023 at 05:27:27 UTC, mw wrote: But what's wrong with my code? the strange compiler error? Might be a bug/issue in the logger module. `sharedLog` uses the `shared` attribute, but the base class for everything ("ab

Re: looking for recommendation: which thread safe logger library?

2023-07-11 Thread mw via Digitalmars-d-learn
On Wednesday, 12 July 2023 at 04:48:23 UTC, Danilo wrote: On Wednesday, 12 July 2023 at 01:55:00 UTC, mw wrote: ``` import std.experimental.logger; void main() { std.experimental.logger.sharedLog.trace("msg"); } ``` See examples at https://dlang.org/phobos/std_logger.html and https://dlan

Re: looking for recommendation: which thread safe logger library?

2023-07-11 Thread mw via Digitalmars-d-learn
On Wednesday, 12 July 2023 at 01:26:25 UTC, mw wrote: On Wednesday, 12 July 2023 at 01:24:41 UTC, mw wrote: Hi, Just wondering which logger library is thread safe? https://code.dlang.org/ Need to find a mature one to be used in a multi-threaded env. Oh, forget to mention: need output to lo

Re: looking for recommendation: which thread safe logger library?

2023-07-11 Thread mw via Digitalmars-d-learn
On Wednesday, 12 July 2023 at 01:24:41 UTC, mw wrote: Hi, Just wondering which logger library is thread safe? https://code.dlang.org/ Need to find a mature one to be used in a multi-threaded env. Oh, forget to mention: need output to logger file.

looking for recommendation: which thread safe logger library?

2023-07-11 Thread mw via Digitalmars-d-learn
Hi, Just wondering which logger library is thread safe? https://code.dlang.org/ Need to find a mature one to be used in a multi-threaded env. Thanks.

Re: gdc 12.1: undefined references when linking separately compiled files

2023-07-06 Thread mw via Digitalmars-d-learn
On Thursday, 6 July 2023 at 22:44:27 UTC, Alexibu wrote: I just encountered this problem in recently released debian bookworm (gdc 12.2.0), I was able to fix these undefined lambdas inside std library with -fall-instantiations, and a bunch of other undefined lambdas in my own code by changin

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread mw via Digitalmars-d-learn
https://forum.dlang.org/thread/duetqujuoceancqtj...@forum.dlang.org Try HashMap see if it is still a problem. If no, then it's another example of the built in AA problem.

is ref inout redundant in: ref inout(T) opIndex(size_t index)

2023-06-19 Thread mw via Digitalmars-d-learn
Hi, I just saw this line: https://github.com/dlang/dmd/blob/master/druntime/src/core/stdcpp/vector.d#LL66C5-L66C39 ``` 66:ref inout(T) opIndex(size_t index) inout pure nothrow @safe @nogc { return as_array[index]; } ``` I'm wondering if the `ref` and `inout` redundant here? They both

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

2023-06-18 Thread mw via Digitalmars-d-learn
If I use array: ``` extern(C++) { void getInts(core.stdcpp.array.array!(int, 10) vec) { foreach (int i; 0 .. 10) { vec.at(i) = i; } } } ``` ``` #include using namespace std; void getInts(array* vector); ``` Both DMD and LDC has link error: base.cpp:42: undefined reference to `getIn

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:56:54 UTC, Richard (Rikki) Andrew Cattermole wrote: On 19/06/2023 5:54 PM, mw wrote: Ha, I saw vector.d there, So I can use this vector.d as the D side of C++'s std::vector? Probably, I just don't know how well tested it is. But worth a go! ``` import core.stdc

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:46:13 UTC, Richard (Rikki) Andrew Cattermole wrote: On 19/06/2023 5:39 PM, mw wrote: Then it will be very tedious, esp. for such library class std::list. Yes, you would also need to verify it with every compiler you need (MSVC, vs linux gcc). There could be a

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

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

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: 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

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: 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

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

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 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

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

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

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

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,

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: 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

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: 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

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: 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

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: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 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: 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 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 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: 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

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: 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 `

  1   2   3   >