Re: Cannot catch exception in debug mode

2021-08-11 Thread kinke via Digitalmars-d-learn
On Thursday, 12 August 2021 at 02:03:39 UTC, Adam D Ruppe wrote: On Thursday, 12 August 2021 at 01:53:12 UTC, frame wrote: Is this a known DMD bug or feature? Huh that is weird, it works correctly in gdc but i can reproduce in dmd and ldc. And removing the debug keyword makes it work.

Re: Cannot catch exception in debug mode

2021-08-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 12 August 2021 at 01:53:12 UTC, frame wrote: Is this a known DMD bug or feature? Huh that is weird, it works correctly in gdc but i can reproduce in dmd and ldc. And removing the debug keyword makes it work. Certainly smells like a regression bug to me.

Cannot catch exception in debug mode

2021-08-11 Thread frame via Digitalmars-d-learn
Is this a known DMD bug or feature? ```d void f(T)(int num) { writefln("recognized %d as %s", num, T.stringof); } void main() { try { throw new Exception(""); } catch (Exception) { f!Exception(1); } catch (Throwable) { f!Throwable(1);

Re: Can't compile with ldc in termux

2021-08-11 Thread _ZZ_ZZ_ZZ via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 19:17:40 UTC, jfondren wrote: On Wednesday, 11 August 2021 at 19:16:25 UTC, jfondren wrote: With two dashes: ``` default: { switches = [ "-defaultlib=phobos2-ldc,druntime-ldc", "-link-defaultlib-shared=false", "--linker=", // <-- add

Re: D has the same memory model as C++

2021-08-11 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 19:38:38 UTC, Tejas wrote: On Wednesday, 11 August 2021 at 19:27:34 UTC, Ali Çehreli wrote: On 8/11/21 12:19 PM, Tejas wrote: Atleast leave some pointers on where to start :( I DuckDuckGo'ed it for you. :)

Re: D has the same memory model as C++

2021-08-11 Thread Tejas via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 19:27:34 UTC, Ali Çehreli wrote: On 8/11/21 12:19 PM, Tejas wrote: Atleast leave some pointers on where to start :( I DuckDuckGo'ed it for you. :) https://en.cppreference.com/w/cpp/language/memory_model Then looked it up at Wikipedia too:

Re: D has the same memory model as C++

2021-08-11 Thread Ali Çehreli via Digitalmars-d-learn
On 8/11/21 12:19 PM, Tejas wrote: Atleast leave some pointers on where to start :( I DuckDuckGo'ed it for you. :) https://en.cppreference.com/w/cpp/language/memory_model Then looked it up at Wikipedia too: https://en.wikipedia.org/wiki/Memory_model_(programming) Ali

Re: D has the same memory model as C++

2021-08-11 Thread Tejas via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 19:04:50 UTC, Ali Çehreli wrote: This is an interesting thread but "memory model" does not cover or mean all of the points discussed here. I can't define it precisely, so I'm leaving it to interested parties to search for themselves. :) Ali A little bit of

Re: Can't compile with ldc in termux

2021-08-11 Thread jfondren via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 19:10:09 UTC, _ZZ_ZZ_ZZ wrote: On Wednesday, 11 August 2021 at 18:58:16 UTC, jfondren wrote: confirm the location of ldc2.conf with `ldc2 -v`, then edit that file. Mine was at ../usr/etc/ldc2.conf (relative to $HOME) Mine was at

Re: Can't compile with ldc in termux

2021-08-11 Thread jfondren via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 19:16:25 UTC, jfondren wrote: With two dashes: ``` default: { switches = [ "-defaultlib=phobos2-ldc,druntime-ldc", "-link-defaultlib-shared=false", "--linker=", // <-- add this ]; ```

Re: Can't compile with ldc in termux

2021-08-11 Thread _ZZ_ZZ_ZZ via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 18:58:16 UTC, jfondren wrote: confirm the location of ldc2.conf with `ldc2 -v`, then edit that file. Mine was at ../usr/etc/ldc2.conf (relative to $HOME) Mine was at `/data/data/com.termux/files/usr/etc/ldc2.conf` too. Now, the file contains: ``` $ cat ldc2.conf

Re: D has the same memory model as C++

2021-08-11 Thread Ali Çehreli via Digitalmars-d-learn
This is an interesting thread but "memory model" does not cover or mean all of the points discussed here. I can't define it precisely, so I'm leaving it to interested parties to search for themselves. :) Ali

Re: Can't compile with ldc in termux

2021-08-11 Thread jfondren via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 18:46:44 UTC, _ZZ_ZZ_ZZ wrote: On Wednesday, 11 August 2021 at 18:20:13 UTC, Paul Backus wrote: Maybe try compiling with `--linker=` (nothing after the `=` sign) and see if that helps? YOU ARE MY HERO!!! it works, and it's great! But in any case ... Can i

Re: Can't compile with ldc in termux

2021-08-11 Thread _ZZ_ZZ_ZZ via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 18:20:13 UTC, Paul Backus wrote: Maybe try compiling with `--linker=` (nothing after the `=` sign) and see if that helps? YOU ARE MY HERO!!! it works, and it's great! But in any case ... Can i configure the compiler to automatically execute the `--linker =`

Re: Can't compile with ldc in termux

2021-08-11 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 17:17:23 UTC, _ZZ_ZZ_ZZ wrote: After having downloaded `ldc` in Termux, i have tried to create an example script (obviously, D-program) and after having compiled it, it gives an error. ``` $ vim example_program.d $ ldc2 example_program.d clang-12: error: invalid

Can't compile with ldc in termux

2021-08-11 Thread _ZZ_ZZ_ZZ via Digitalmars-d-learn
After having downloaded `ldc` in Termux, i have tried to create an example script (obviously, D-program) and after having compiled it, it gives an error. ``` $ vim example_program.d $ ldc2 example_program.d clang-12: error: invalid linker name in argument '-fuse-ld=bfd' Error:

Re: equivalent of std.functional.partial for templates?

2021-08-11 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 14:08:59 UTC, Paul Backus wrote: [snip] Should have read further--this does not work with template functions due to [issue 1807.][1] My mistake. [1]: https://issues.dlang.org/show_bug.cgi?id=1807 Looks like that strengthens the case for moving forward with

Re: equivalent of std.functional.partial for templates?

2021-08-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 14:08:59 UTC, Paul Backus wrote: On Wednesday, 11 August 2021 at 14:03:50 UTC, Paul Backus wrote: On Wednesday, 11 August 2021 at 14:00:33 UTC, Steven Schveighoffer wrote: I have a template function like this: ```d auto foo(T, Args...)(Args args) {...} ``` If

Re: equivalent of std.functional.partial for templates?

2021-08-11 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 14:03:50 UTC, Paul Backus wrote: On Wednesday, 11 August 2021 at 14:00:33 UTC, Steven Schveighoffer wrote: I have a template function like this: ```d auto foo(T, Args...)(Args args) {...} ``` If I try to bind the T only, and produce a partial template function

Re: DUB "Error: only one `main` allowed."

2021-08-11 Thread tastyminerals via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 11:44:42 UTC, Steven Schveighoffer wrote: On 8/11/21 5:31 AM, tastyminerals wrote: [...] `dub -b unittest` should work (you don't need the extra build type stuff) dub test does something funky -- it removes the *whole module* where your main function is (if

Re: equivalent of std.functional.partial for templates?

2021-08-11 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 14:00:33 UTC, Steven Schveighoffer wrote: I have a template function like this: ```d auto foo(T, Args...)(Args args) {...} ``` If I try to bind the T only, and produce a partial template function which can accept any number of parameters, but has T already

equivalent of std.functional.partial for templates?

2021-08-11 Thread Steven Schveighoffer via Digitalmars-d-learn
I have a template function like this: ```d auto foo(T, Args...)(Args args) {...} ``` If I try to bind the T only, and produce a partial template function which can accept any number of parameters, but has T already specified, I get an error, because instantiating `foo!T` means Args is length

Re: DUB "Error: only one `main` allowed."

2021-08-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/11/21 5:31 AM, tastyminerals wrote: I would like to trigger tests in a simple dub project. ``` source/my_script.d dub.json ``` Here is a dub config: ```json {     "targetPath": "build", "targetType": "executable", "sourcePaths": ["source"], "name": "my_script",

Re: DUB "Error: only one `main` allowed."

2021-08-11 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 09:38:13 UTC, tastyminerals wrote: Hahaha, I fixed it by renaming the `my_script.d` to `app.d`. Oh boy. What you want is the `mainSourceFile` entry. From the dub documentation, [under "Build Settings"][1]: Determines the file that contains the main()

Re: D has the same memory model as C++

2021-08-11 Thread Bastiaan Veelo via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 05:33:06 UTC, Tejas wrote: On Tuesday, 10 August 2021 at 21:19:39 UTC, Bastiaan Veelo wrote: On Tuesday, 10 August 2021 at 16:00:37 UTC, Tejas wrote: Basically, what are the subtle gotcha's in the differences between C++ and D code that looks similar The only

Re: DUB "Error: only one `main` allowed."

2021-08-11 Thread tastyminerals via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 09:31:46 UTC, tastyminerals wrote: I would like to trigger tests in a simple dub project. ``` source/my_script.d dub.json ``` Here is a dub config: ```json { "targetPath": "build", "targetType": "executable", "sourcePaths": ["source"],

DUB "Error: only one `main` allowed."

2021-08-11 Thread tastyminerals via Digitalmars-d-learn
I would like to trigger tests in a simple dub project. ``` source/my_script.d dub.json ``` Here is a dub config: ```json { "targetPath": "build", "targetType": "executable", "sourcePaths": ["source"], "name": "my_script", "buildTypes": {

Re: DUB "Error: only one `main` allowed."

2021-08-11 Thread tastyminerals via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 09:31:46 UTC, tastyminerals wrote: I would like to trigger tests in a simple dub project. ``` source/my_script.d dub.json ``` Here is a dub config: ```json { "targetPath": "build", "targetType": "executable", "sourcePaths": ["source"],

Re: No compile time bounds checking for static arrays?

2021-08-11 Thread Tejas via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 06:46:34 UTC, Stefan Koch wrote: On Wednesday, 11 August 2021 at 06:29:40 UTC, Tejas wrote: ```d import std; void main() { int[40] staticA; auto c = staticA[0..50];//mistake }``` results in: ```d core.exception.RangeError@onlineapp.d(5): Range violation

Re: No compile time bounds checking for static arrays?

2021-08-11 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 06:29:40 UTC, Tejas wrote: ```d import std; void main() { int[40] staticA; auto c = staticA[0..50];//mistake }``` results in: ```d core.exception.RangeError@onlineapp.d(5): Range violation ??:? _d_arrayboundsp [0x55db29a0b645]

No compile time bounds checking for static arrays?

2021-08-11 Thread Tejas via Digitalmars-d-learn
```d import std; void main() { int[40] staticA; auto c = staticA[0..50];//mistake }``` results in: ```d core.exception.RangeError@onlineapp.d(5): Range violation ??:? _d_arrayboundsp [0x55db29a0b645] ./onlineapp.d:5 _Dmain [0x55db29a0ae8c] ``` Is there a way to make