Re: int | missing | absent

2022-06-23 Thread bauss via Digitalmars-d-learn
On Thursday, 23 June 2022 at 15:20:02 UTC, Jesse Phillips wrote: On Wednesday, 22 June 2022 at 01:09:22 UTC, Steven Schveighoffer wrote: There are 3 situations: 1. field in json and struct. Obvious result. 2. field in json but not in struct. 3. field in struct but not in json. I do a lot of

Re: DIP1000

2022-06-23 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Friday, 24 June 2022 at 03:03:52 UTC, Paul Backus wrote: On Thursday, 23 June 2022 at 21:34:27 UTC, Ola Fosheim Grøstad wrote: On Thursday, 23 June 2022 at 21:05:57 UTC, ag0aep6g wrote: It's a weird rule for sure. Another slightly annoying thing is that it cares about destruction order wh

Re: DIP1000

2022-06-23 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 23 June 2022 at 21:34:27 UTC, Ola Fosheim Grøstad wrote: On Thursday, 23 June 2022 at 21:05:57 UTC, ag0aep6g wrote: It's a weird rule for sure. Another slightly annoying thing is that it cares about destruction order when there are no destructors. If there are no destructors th

Re: nested function overloading

2022-06-23 Thread Chris Katko via Digitalmars-d-learn
On Wednesday, 22 June 2022 at 12:42:48 UTC, Steven Schveighoffer wrote: On 6/22/22 2:05 AM, monkyyy wrote: On Monday, 20 June 2022 at 13:20:51 UTC, Steven Schveighoffer wrote: And you can also use an inner struct to define overloaded functions. I believe templates make a better bandaid ```d v

Re: How to use templates in a separate library?

2022-06-23 Thread monkyyy via Digitalmars-d-learn
On Thursday, 23 June 2022 at 08:12:32 UTC, CrazyMan wrote: linking make sure you use the -i flag when compiling

Re: DIP1000

2022-06-23 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Thursday, 23 June 2022 at 21:05:57 UTC, ag0aep6g wrote: It's a weird rule for sure. Another slightly annoying thing is that it cares about destruction order when there are no destructors. If there are no destructors the lifetime ought to be considered the same for variables in the same s

Re: DIP1000

2022-06-23 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Thursday, 23 June 2022 at 21:05:57 UTC, ag0aep6g wrote: It means "may be returned or copied to the first parameter" (https://dlang.org/spec/function.html#param-storage). You cannot escape via other parameters. It's a weird rule for sure. Too complicated for what it does… Maybe @trusted isn'

Re: DIP1000

2022-06-23 Thread ag0aep6g via Digitalmars-d-learn
On Thursday, 23 June 2022 at 20:27:44 UTC, Ola Fosheim Grøstad wrote: On Thursday, 23 June 2022 at 19:38:12 UTC, ag0aep6g wrote: ```d void connect(ref scope node a, return scope node* b) ``` Thanks, so the `return scope` means «allow escape», not necessarily return? It means "may be returne

Re: Reading parquet files from D

2022-06-23 Thread Sergey via Digitalmars-d-learn
On Thursday, 23 June 2022 at 12:48:20 UTC, test123 wrote: https://forum.dlang.org/post/mkgelbxeqvhbdsukg...@forum.dlang.org On Monday, 14 October 2019 at 20:13:43 UTC, jmh530 wrote: On Monday, 14 October 2019 at 19:27:04 UTC, Andre Pany wrote: [snip] I found this tool https://github.com/gtkd-

Re: DIP1000

2022-06-23 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Thursday, 23 June 2022 at 19:38:12 UTC, ag0aep6g wrote: ```d void connect(ref scope node a, return scope node* b) ``` Thanks, so the `return scope` means «allow escape», not necessarily return? But that only works for this very special case. It falls apart when you try to add a third nod

Re: DIP1000

2022-06-23 Thread ag0aep6g via Digitalmars-d-learn
On Thursday, 23 June 2022 at 16:08:01 UTC, Ola Fosheim Grøstad wrote: How am I supposed to write this: ```d import std; @safe: struct node { node* next; } auto connect(scope node* a, scope node* b) { a.next = b; } void main() { node x; node y; connect(&x,&y); } ``` Erro

Re: Null terminated character

2022-06-23 Thread frame via Digitalmars-d-learn
On Thursday, 23 June 2022 at 17:27:51 UTC, frame wrote: On Thursday, 23 June 2022 at 16:16:26 UTC, vc wrote: I've try this '\0'*10 and didn't work, i want the results be \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 One way: ```d import std.range; repeat("\0", 10).join(""); ``` If you just need

Re: Null terminated character

2022-06-23 Thread frame via Digitalmars-d-learn
On Thursday, 23 June 2022 at 16:16:26 UTC, vc wrote: I've try this '\0'*10 and didn't work, i want the results be \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 One way: ```d import std.range; repeat("\0", 10).join(""); ```

Re: How to use templates in a separate library?

2022-06-23 Thread frame via Digitalmars-d-learn
On Thursday, 23 June 2022 at 08:12:32 UTC, CrazyMan wrote: I have a separate library and some template interface in it ```d interface IFoo(T) { void setValue(const(T) value); } ``` But when using it in the main program, it throws a linking error. I found that you can make a sourceLibrary

Null terminated character

2022-06-23 Thread vc via Digitalmars-d-learn
I've try this '\0'*10 and didn't work, i want the results be \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00

DIP1000

2022-06-23 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
How am I supposed to write this: ```d import std; @safe: struct node { node* next; } auto connect(scope node* a, scope node* b) { a.next = b; } void main() { node x; node y; connect(&x,&y); } ``` Error: scope variable `b` assigned to non-scope `(*a).next`

Re: int | missing | absent

2022-06-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/23/22 11:20 AM, Jesse Phillips wrote: On Wednesday, 22 June 2022 at 01:09:22 UTC, Steven Schveighoffer wrote: There are 3 situations: 1. field in json and struct. Obvious result. 2. field in json but not in struct. 3. field in struct but not in json. I do a lot of reading JSON data in C

Re: int | missing | absent

2022-06-23 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 22 June 2022 at 01:09:22 UTC, Steven Schveighoffer wrote: There are 3 situations: 1. field in json and struct. Obvious result. 2. field in json but not in struct. 3. field in struct but not in json. I do a lot of reading JSON data in C#, and I heavily lean on optional over req

Reading parquet files from D

2022-06-23 Thread test123 via Digitalmars-d-learn
https://forum.dlang.org/post/mkgelbxeqvhbdsukg...@forum.dlang.org On Monday, 14 October 2019 at 20:13:43 UTC, jmh530 wrote: On Monday, 14 October 2019 at 19:27:04 UTC, Andre Pany wrote: [snip] I found this tool https://github.com/gtkd-developers/gir-to-d from Mike Wey which translates GObject

How to use templates in a separate library?

2022-06-23 Thread CrazyMan via Digitalmars-d-learn
I have a separate library and some template interface in it ```d interface IFoo(T) { void setValue(const(T) value); } ``` But when using it in the main program, it throws a linking error. I found that you can make a sourceLibrary that copies the code instead of creating a binary. But with