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

Re: Consuming D libraries from other languages

2022-06-15 Thread Ali Çehreli via Digitalmars-d-learn
On 6/15/22 10:37, 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? Not Phobos but the D runtime. > What if I don't want to > use the D

Re: Whats the proper way to write a Range next function

2022-06-15 Thread Christian Köstlin via Digitalmars-d-learn
On 2022-06-15 19:36, JG wrote: On Wednesday, 15 June 2022 at 17:30:31 UTC, JG wrote: On Wednesday, 15 June 2022 at 13:52:24 UTC, Christian Köstlin wrote: the naive version would look like ```d auto next(Range)(Range r) {     r.popFront;     return r.front; } ``` But looking at a mature librar

Re: Comparing Exceptions and Errors

2022-06-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/15/22 3:51 PM, kdevel wrote: On Wednesday, 15 June 2022 at 03:09:56 UTC, Steven Schveighoffer wrote: I don't see what you see wrong with the code I wrote. It's straightforward, obvious, and does the job I need it to do, in a way that's not prone to future mistakes. Sometimes it is not ea

Re: Comparing Exceptions and Errors

2022-06-15 Thread kdevel via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 03:09:56 UTC, Steven Schveighoffer wrote: I don't see what you see wrong with the code I wrote. It's straightforward, obvious, and does the job I need it to do, in a way that's not prone to future mistakes. Sometimes it is not easy to explain why code "feels" wron

Re: Consuming D libraries from other languages

2022-06-15 Thread Guillaume Piolat via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 19:36:34 UTC, Guillaume Piolat wrote: BindBC bindings are multi-platform and can be both static and dynamic linking. My bad I understood the reverse, consuming C libraries from D. I think what you are seeking is described in the D blog.

Re: Consuming D libraries from other languages

2022-06-15 Thread Guillaume Piolat 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

Consuming D libraries from other languages

2022-06-15 Thread Templated Person via Digitalmars-d-learn
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? What happens with module level `this()` and `~this()`? Is there a compre

Re: Whats the proper way to write a Range next function

2022-06-15 Thread JG via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 17:30:31 UTC, JG wrote: On Wednesday, 15 June 2022 at 13:52:24 UTC, Christian Köstlin wrote: the naive version would look like ```d auto next(Range)(Range r) { r.popFront; return r.front; } ``` But looking at a mature library e.g. https://github.com/subma

Re: Whats the proper way to write a Range next function

2022-06-15 Thread JG via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 13:52:24 UTC, Christian Köstlin wrote: the naive version would look like ```d auto next(Range)(Range r) { r.popFront; return r.front; } ``` But looking at a mature library e.g. https://github.com/submada/btl/blob/9cc599fd8495215d346ccd62d6e9f1f7ac140937/so

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: Bug in dmd?

2022-06-15 Thread Andrey Zherikov via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 09:24:35 UTC, Dukc wrote: Now when I think of it, perhaps the fact that private `printHelp` has the same name as the public `printHelp` is somehow confusing dmd. If you try to rename the private `printHelp` and it's call in the public one to something else, you mi

Re: Whats the proper way to write a Range next function

2022-06-15 Thread Dennis via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 13:52:24 UTC, Christian Köstlin wrote: looks like there should be tons of annotations/attributes on it. Because you have a template function, most attributes will be inferred based on the Range type. `const` is not inferred, but `popFront` mutates so it doesn't a

Whats the proper way to write a Range next function

2022-06-15 Thread Christian Köstlin via Digitalmars-d-learn
the naive version would look like ```d auto next(Range)(Range r) { r.popFront; return r.front; } ``` But looking at a mature library e.g. https://github.com/submada/btl/blob/9cc599fd8495215d346ccd62d6e9f1f7ac140937/source/btl/vector/package.d#L229 is looks like there should be tons of

Re: Bug in dmd?

2022-06-15 Thread Andrey Zherikov via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 09:21:28 UTC, user1234 wrote: On Tuesday, 14 June 2022 at 13:39:12 UTC, Andrey Zherikov wrote: I have [pretty simple code in my library](https://github.com/andrey- [Line (2) produces](https://github.com/andrey-zherikov/argparse/runs/6880350900?check_suite_focus=tru

Re: Bug in dmd?

2022-06-15 Thread Andrey Zherikov via Digitalmars-d-learn
On Wednesday, 15 June 2022 at 07:38:36 UTC, JG wrote: I tried to reproduce it but wasn't able (I guess it is some interplay with the rest of your code): I tried this first but got the same result as you. I think my small library overheats DMD's template engine.

getSymbolsByUDA in constructor/member functions

2022-06-15 Thread cc via Digitalmars-d-learn
```d import std.traits; class XML {} class Def { @XML { int x; int y; } int z; this() { static foreach (sym; getSymbolsByUDA!(Def, XML)) { } } } void main() { auto def = new Def; } ``

Re: Bug in dmd?

2022-06-15 Thread Dukc via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 23:56:58 UTC, Andrey Zherikov wrote: On Tuesday, 14 June 2022 at 21:44:48 UTC, Dukc wrote: No idea. The functions seems indeed to be exactly the same, so I assume this is a DMD bug. It cannot be a bug in `std.sumtype`, since that would trigger in both of the templat

Re: Bug in dmd?

2022-06-15 Thread user1234 via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 13:39:12 UTC, Andrey Zherikov wrote: I have [pretty simple code in my library](https://github.com/andrey- [Line (2) produces](https://github.com/andrey-zherikov/argparse/runs/6880350900?check_suite_focus=true#step:5:12) `undefined reference to '_D3std7sumtype__T7SumTy

Re: Bug in dmd?

2022-06-15 Thread JG via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 23:56:58 UTC, Andrey Zherikov wrote: On Tuesday, 14 June 2022 at 21:44:48 UTC, Dukc wrote: No idea. The functions seems indeed to be exactly the same, so I assume this is a DMD bug. It cannot be a bug in `std.sumtype`, since that would trigger in both of the templat

Re: Bug?

2022-06-15 Thread JG via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 19:49:39 UTC, Steven Schveighoffer wrote: On 6/14/22 3:35 PM, JG wrote: Hi, Is this a bug? ```d import std; template test(alias f) {     auto test(I)(I i) { return f(i); } } void main() {     alias t = test!(x=>x+1);     1.t.writeln; //<--Doesn't compile     1