Re: Dynamic Arrays Capacity

2022-06-02 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 2 June 2022 at 08:14:40 UTC, Mike Parker wrote: You've initialized `str` with a string literal. No memory is allocated for these from the GC. They're stored in the binary, meaning they're loaded into memory from disk by the OS. So `str.ptr` points to a static memory location

Re: Graphing a D function : possible?

2022-06-02 Thread harakim via Digitalmars-d-learn
On Thursday, 2 June 2022 at 03:37:13 UTC, z wrote: Is there a quick way of obtaining the graph of D functions like these? ```d T f(T) if (isScalarType!T){} ``` or ```D T[2] f(T, T)if (isScalarType!T){} ``` I know that there are graphing calculators already, but these don't support low level

Re: Dynamic Arrays Capacity

2022-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/2/22 1:04 AM, Salih Dincer wrote: Hi, Do I misunderstand? A dynamic array is allocated memory according to the `nextpow2()` algorithm(-1 lapse); strings, on the other hand, don't behave like this... ```d   string str = "0123456789ABCDEF";   char[] chr = str.dup;   assert(str.length

Re: Graphing a D function : possible?

2022-06-02 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 2 June 2022 at 03:37:13 UTC, z wrote: Is there a quick way of obtaining the graph of D functions like these? ```d T f(T) if (isScalarType!T){} ``` or ```D T[2] f(T, T)if (isScalarType!T){} ``` I know that there are graphing calculators already, but these don't support low level

Re: int | missing | absent

2022-06-02 Thread bauss via Digitalmars-d-learn
On Thursday, 2 June 2022 at 08:27:32 UTC, Antonio wrote: JSON properties can be - a value - null - absent What's the standard way to define a serialziable/deserializable structs supporting properties of any of this 4 kinds?: * int * int | null * int | absent * int | null | absent Whats the

Re: Dynamic Arrays Capacity

2022-06-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 2 June 2022 at 08:24:51 UTC, Mike Parker wrote: And so, `[0]` is the same as `&(*ts.ptr + 0)`, or simply `ts.ptr`. That should be the same as `&(*(ts.ptr + 0))`!

int | missing | absent

2022-06-02 Thread Antonio via Digitalmars-d-learn
JSON properties can be - a value - null - absent What's the standard way to define a serialziable/deserializable structs supporting properties of any of this 4 kinds?: * int * int | null * int | absent * int | null | absent Whats the best library to manage this JSON requirements? (all the

Re: Dynamic Arrays Capacity

2022-06-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 2 June 2022 at 08:14:40 UTC, Mike Parker wrote: More specifically, it points to the starting address of the allocated block of memory. I posted too soon. Given an instance `ts` of type `T[]`, array accesses essentially are this: ```d ts[0] == *(ts.ptr + 0); ts[1] == *(ts.ptr +

Re: Dynamic Arrays Capacity

2022-06-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 2 June 2022 at 05:04:03 UTC, Salih Dincer wrote: Hi, Do I misunderstand? A dynamic array is allocated memory according to the `nextpow2()` algorithm(-1 lapse); strings, on the other hand, don't behave like this... ```d string str = "0123456789ABCDEF"; char[] chr = str.dup;