Re: toStringz lifetime

2020-11-08 Thread Ali Çehreli via Digitalmars-d-learn
On 11/8/20 6:58 PM, rikki cattermole wrote: > On 09/11/2020 2:58 PM, Ali Çehreli wrote: >> Does the D GC know the complete function call stack of the C program >> all the way up from 'main'? Is there the concept of "bottom of the >> stack" >

Re: toStringz lifetime

2020-11-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/11/2020 2:58 PM, Ali Çehreli wrote: Does the D GC know the complete function call stack of the C program all the way up from 'main'? Is there the concept of "bottom of the stack" or does the D GC can only know the value of the stack pointer at the time rt_init() was called. If the

Re: toStringz lifetime

2020-11-08 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/20 3:19 AM, rikki cattermole wrote: On 25/10/2020 11:03 PM, Ali Çehreli wrote: Does the GC see that local variable 'name' that is on the C side? What I don't know is whether the GC is aware only of the stack frames of D functions or the entire thread, which would include the C

Re: asdf get first value from a json string.

2020-11-08 Thread frame via Digitalmars-d-learn
On Sunday, 8 November 2020 at 19:29:39 UTC, frame wrote: On Sunday, 8 November 2020 at 16:30:40 UTC, Vino wrote: Request your help on how to get the first value of "type" from the below json, the expected output required is as below, You need a data structure to work with, eg: static

Re: asdf get first value from a json string.

2020-11-08 Thread frame via Digitalmars-d-learn
On Sunday, 8 November 2020 at 16:30:40 UTC, Vino wrote: Request your help on how to get the first value of "type" from the below json, the expected output required is as below, You need a data structure to work with, eg: static struct S { string characteristicValue; } foreach (ref j;

asdf get first value from a json string.

2020-11-08 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on how to get the first value of "type" from the below json, the expected output required is as below, {"characteristicValue":"TT,t...@dev.com,DEV"} output1: TT output2: t...@dev.com Code: /+dub.sdl: dependency "asdf" version="~>0.6.6" +/ import std; import

Re: How add class or struct member after construction?

2020-11-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-11-05 23:48, Marcone wrote: How add class or struct member after construction? Is it possible in D? How? It depends on what needs you have. You can declare a free function that takes the class/struct as the first parameter and call it like a method [1]: class Foo { int a; }

Re: DMD: invalid UTF character `\U0000d800`

2020-11-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-11-08 13:39, Kagamin wrote: Surrogate pairs are used in rules because java strings are utf-16 encoded, it doesn't make much sense for other encodings. D supports the UTF-16 encoding as well. The compiler doesn't accept the surrogate pairs even for UTF-16 strings. -- /Jacob Carlborg

Re: How exactly does Tuple work?

2020-11-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 8 November 2020 at 13:57:08 UTC, Jan Hönig wrote: So it's like inheritance resolved at compile time. It's inheritance with virtual member functions without overhead. I am guessing only one alias works. And we use this, because struct can't do inheritance and interface is abstract.

Re: How exactly does Tuple work?

2020-11-08 Thread Jan Hönig via Digitalmars-d-learn
On Sunday, 8 November 2020 at 13:10:33 UTC, Adam D. Ruppe wrote: On Sunday, 8 November 2020 at 10:03:46 UTC, Jan Hönig wrote: Is there some recourse, which explains the `alias this`? If your object is used in a way that doesn't compile, the compiler will change `obj` to

Re: DMD: invalid UTF character `\U0000d800`

2020-11-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/8/20 5:47 AM, Per Nordlöw wrote: On Saturday, 7 November 2020 at 17:49:54 UTC, Jacob Carlborg wrote: [1] https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF Thanks! I'm only using these UTF characters to create ranges that source code characters as checked against during parsing.

Re: How exactly does Tuple work?

2020-11-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 8 November 2020 at 10:03:46 UTC, Jan Hönig wrote: Is there some recourse, which explains the `alias this`? If your object is used in a way that doesn't compile, the compiler will change `obj` to `obj.whatever_alias_this_is` and try again. So say you have struct S { int a;

Re: DMD: invalid UTF character `\U0000d800`

2020-11-08 Thread Kagamin via Digitalmars-d-learn
On Sunday, 8 November 2020 at 10:47:34 UTC, Per Nordlöw wrote: dchar Surrogate pairs are used in rules because java strings are utf-16 encoded, it doesn't make much sense for other encodings.

Re: DMD: invalid UTF character `\U0000d800`

2020-11-08 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 8 November 2020 at 10:47:34 UTC, Per Nordlöw wrote: cast(dchar)0xd8000 To clarify, enum dch1 = cast(dchar)0xa0a0; enum dch2 = '\ua0a0'; assert(dch1 == dch2); works. Can I use the first-variant if I want to postpone these encoding questions for now?

Re: DMD: invalid UTF character `\U0000d800`

2020-11-08 Thread Per Nordlöw via Digitalmars-d-learn
On Saturday, 7 November 2020 at 17:49:54 UTC, Jacob Carlborg wrote: [1] https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF Thanks! I'm only using these UTF characters to create ranges that source code characters as checked against during parsing. Therefore I would like to just convert

Re: How exactly does Tuple work?

2020-11-08 Thread Jan Hönig via Digitalmars-d-learn
On Saturday, 7 November 2020 at 18:31:18 UTC, Paul Backus wrote: Indexing and slicing are implemented with `alias expand this`, which causes `t[i]` to be lowered to `t.expand[i]`. Is there some recourse, which explains the `alias this`? I still don't understand what it does. I can't imagine