Re: Extract base type of any array?

2021-09-18 Thread jfondren via Digitalmars-d-learn
On Sunday, 19 September 2021 at 03:58:41 UTC, Kirill wrote: How can I get the base type of any (multidimensional/static/dynamic/associative) array? Example: ``` void main() { int[][] intArr; double[4][] doubleArr; string[string][] strArr; intArr.example; // T = int

Extract base type of any array?

2021-09-18 Thread Kirill via Digitalmars-d-learn
How can I get the base type of any (multidimensional/static/dynamic/associative) array? Example: ``` void main() { int[][] intArr; double[4][] doubleArr; string[string][] strArr; intArr.example; // T = int doubleArr.example; // T = double strArr.example; // T = string }

Re: GC seems to crash my C-code function

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 5:16 PM, frame wrote: On Saturday, 18 September 2021 at 18:48:07 UTC, Steven Schveighoffer wrote: Did you mean "long to char" cast? In that case, yes, you have to cast it. Note, `out` is a keyword, it can't be used as a variable, but you probably already figured that out. But if

Re: GC seems to crash my C-code function

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 5:20 PM, frame wrote: On Saturday, 18 September 2021 at 21:16:13 UTC, frame wrote: On Saturday, 18 September 2021 at 18:48:07 UTC, Steven Schveighoffer wrote: Are you defining the prototype for strchr yourself instead of importing it from core.stdc.string? Not really :D but

Re: How to do "C++ classes"?

2021-09-18 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 18 September 2021 at 15:38:38 UTC, rempas wrote: I'm seeing in the page about "BeterC" and in the part about the [retained features](https://dlang.org/spec/betterc.html#retained), the #11 says about "COM classes and C++ classes". What are the "C++ classes"? I tried to create a

Re: GC seems to crash my C-code function

2021-09-18 Thread frame via Digitalmars-d-learn
On Saturday, 18 September 2021 at 21:16:13 UTC, frame wrote: On Saturday, 18 September 2021 at 18:48:07 UTC, Steven Schveighoffer wrote: Are you defining the prototype for strchr yourself instead of importing it from core.stdc.string? Not really :D but without cast it complains: ``` Error:

Re: MobI? Really?

2021-09-18 Thread Jordi Sayol via Digitalmars-d-learn
El 18/9/21 a les 22:40, Chris_D via Digitalmars-d-learn ha escrit: The "D Programming Language Specification" seems to be the most important documentation for D.  Is it really only available as Mobi?  That is the most bizarre choice of format I've ever seen.   Chris

Re: GC seems to crash my C-code function

2021-09-18 Thread frame via Digitalmars-d-learn
On Saturday, 18 September 2021 at 18:48:07 UTC, Steven Schveighoffer wrote: Are you defining the prototype for strchr yourself instead of importing it from core.stdc.string? Not really :D but without cast it complains: ``` Error: cannot implicitly convert expression strchr(e, cast(int)c) of

Re: MobI? Really?

2021-09-18 Thread jfondren via Digitalmars-d-learn
On Saturday, 18 September 2021 at 20:40:56 UTC, Chris_D wrote: The "D Programming Language Specification" seems to be the most important documentation for D. Is it really only available as Mobi? That is the most bizarre choice of format I've ever seen. Chris No, it's not *only*

MobI? Really?

2021-09-18 Thread Chris_D via Digitalmars-d-learn
The "D Programming Language Specification" seems to be the most important documentation for D. Is it really only available as Mobi? That is the most bizarre choice of format I've ever seen. Chris

Re: GC seems to crash my C-code function

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 12:52 PM, frame wrote: There were also parts where the pointer is used in calculations - which is accepted by the compiler - it just complains about implicitly `long` to `char*` cast: ``` // const char *e // char *w out[p++] = ((w - e) + 3) % 40; ``` Did you mean "long to char"

Re: GC seems to crash my C-code function

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 12:52 PM, frame wrote: On Saturday, 18 September 2021 at 11:47:52 UTC, Steven Schveighoffer wrote: Have you tried: ```d const(char)* s2 = "..."; ``` This will work because string literals are zero terminated and implicitly castable to `immutable(char)*`, which will also

Re: GC seems to crash my C-code function

2021-09-18 Thread frame via Digitalmars-d-learn
On Saturday, 18 September 2021 at 11:47:52 UTC, Steven Schveighoffer wrote: Have you tried: ```d const(char)* s2 = "..."; ``` This will work because string literals are zero terminated and implicitly castable to `immutable(char)*`, which will also implicitly cast to `const(char)*`. That

How to do "C++ classes"?

2021-09-18 Thread rempas via Digitalmars-d-learn
I'm seeing in the page about "BeterC" and in the part about the [retained features](https://dlang.org/spec/betterc.html#retained), the #11 says about "COM classes and C++ classes". What are the "C++ classes"? I tried to create a class using "extern(C++)" but this didn't worked. Can someone

Re: yet another segfault - array out of bound is not caught by try catch

2021-09-18 Thread russhy via Digitalmars-d-learn
Double check in your dub.json file and see if you haven't changed your buildoptions DEBUG: it's caught: https://run.dlang.io/is/F8HkD8 RELEASE: segfault as expected: https://run.dlang.io/is/oLU2M3 And make sure to use latest version of ldc

Re: What is the meaning of @future ?

2021-09-18 Thread Ali Çehreli via Digitalmars-d-learn
On 9/18/21 1:27 AM, evilrat wrote: > IIRC they went out of business for inability to compete Yes, but not Sociomantic but Dunhumby[1], who had acquired Sociomantic, shut down that business because of changes in the ad market. Ali

Re: What is the meaning of @future ?

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 7:49 AM, Steven Schveighoffer wrote: add buys "ad buys" of course :P -Steve

Re: GC seems to crash my C-code function

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 5:40 AM, frame wrote: On Friday, 17 September 2021 at 14:29:23 UTC, Steven Schveighoffer wrote: Looking at that signature, it does not appear that it uses zero-termination at all, as it takes a length. So using `dup` and therefore the gc is totally unnecessary. I'm assuming that

Re: What is the meaning of @future ?

2021-09-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/18/21 4:02 AM, Dylan Graham wrote: On Friday, 17 September 2021 at 14:37:29 UTC, Meta wrote: On Friday, 17 September 2021 at 10:31:34 UTC, bauss wrote: On Thursday, 16 September 2021 at 20:53:34 UTC, Elmar wrote: [...] It's just another "useless" attribute that the language has added

Re: Program crash: GC destroys an object unexpectedly

2021-09-18 Thread jfondren via Digitalmars-d-learn
On Saturday, 18 September 2021 at 09:39:24 UTC, eugene wrote: The definition of this struct was taken from /usr/include/dmd/druntime/import/core/sys/linux/epoll.d ... If the reason for crash was in EpollEvent alignment, programs would segfaults always very soon after start, just right after

Re: GC seems to crash my C-code function

2021-09-18 Thread frame via Digitalmars-d-learn
On Friday, 17 September 2021 at 14:29:23 UTC, Steven Schveighoffer wrote: Looking at that signature, it does not appear that it uses zero-termination at all, as it takes a length. So using `dup` and therefore the gc is totally unnecessary. I'm assuming that string is the barcode argument?

Re: Program crash: GC destroys an object unexpectedly

2021-09-18 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 20:59:14 UTC, Ali Çehreli wrote: On 9/14/21 9:56 AM, eugene wrote: > On Tuesday, 14 September 2021 at 16:43:50 UTC, jfondren wrote: >> The misaligned pointer and the >> reference-containing struct that vanishes on the return of your >> corresponding function

Re: What is the meaning of @future ?

2021-09-18 Thread evilrat via Digitalmars-d-learn
On Saturday, 18 September 2021 at 08:02:13 UTC, Dylan Graham wrote: On Friday, 17 September 2021 at 14:37:29 UTC, Meta wrote: On Friday, 17 September 2021 at 10:31:34 UTC, bauss wrote: On Thursday, 16 September 2021 at 20:53:34 UTC, Elmar wrote: [...] It's just another "useless" attribute

Re: What is the meaning of @future ?

2021-09-18 Thread Dylan Graham via Digitalmars-d-learn
On Friday, 17 September 2021 at 14:37:29 UTC, Meta wrote: On Friday, 17 September 2021 at 10:31:34 UTC, bauss wrote: On Thursday, 16 September 2021 at 20:53:34 UTC, Elmar wrote: [...] It's just another "useless" attribute that the language has added before fixing any of the real problems :)