Re: pointer escaping return scope bug?

2022-11-25 Thread Tejas via Digitalmars-d-learn
On Friday, 25 November 2022 at 17:45:57 UTC, Paul Backus wrote: On Friday, 25 November 2022 at 14:07:28 UTC, ShadoLight wrote: On Saturday, 19 November 2022 at 15:00:16 UTC, Paul Backus wrote: Since, in your example, `lf` has global lifetime, the compiler deduces that `lf.fp` also has global li

Re: "Little Scheme" and PL Design (Code Critique?)

2022-11-25 Thread jwatson-CO-edu via Digitalmars-d-learn
On Tuesday, 22 November 2022 at 08:19:44 UTC, JG wrote: On Thursday, 17 November 2022 at 22:05:45 UTC, jwatson-CO-edu wrote: I just pushed a D implementation of "[Little Scheme](https://mitpress.mit.edu/9780262560993/the-little-schemer/)", which is a limited educational version of [Scheme](https

Re: "Little Scheme" and PL Design (Code Critique?)

2022-11-25 Thread jwatson-CO-edu via Digitalmars-d-learn
On Monday, 21 November 2022 at 14:36:43 UTC, Paul Backus wrote: On Thursday, 17 November 2022 at 22:05:45 UTC, jwatson-CO-edu wrote: * Compatibility with both Windows and Linux. What do I need to consider? - Can I create threads/processes under Windows? [core.thread][1] and [std.process][2]

Re: pointer escaping return scope bug?

2022-11-25 Thread Paul Backus via Digitalmars-d-learn
On Friday, 25 November 2022 at 14:07:28 UTC, ShadoLight wrote: On Saturday, 19 November 2022 at 15:00:16 UTC, Paul Backus wrote: Since, in your example, `lf` has global lifetime, the compiler deduces that `lf.fp` also has global lifetime, and therefore there is nothing wrong with assigning it t

Re: pointer escaping return scope bug?

2022-11-25 Thread ShadoLight via Digitalmars-d-learn
On Friday, 25 November 2022 at 14:07:28 UTC, ShadoLight wrote: On Saturday, 19 November 2022 at 14:07:59 UTC, Nick Treleaven ```d @safe: struct LockedFile { private int* fps; auto fp() return scope => fps; } void main() { int* p; { auto lf = LockedFile(new int);

Re: pointer escaping return scope bug?

2022-11-25 Thread ShadoLight via Digitalmars-d-learn
On Saturday, 19 November 2022 at 15:00:16 UTC, Paul Backus wrote: On Saturday, 19 November 2022 at 14:07:59 UTC, Nick Treleaven wrote: Hi, The following seems like a bug to me (reduced code, FILE* changed to int*): ```d @safe: struct LockedFile { private int* fps; auto fp() return sc

Re: Assigning parameter on entry to a function and assigning back on exit

2022-11-25 Thread Ali Çehreli via Digitalmars-d-learn
On 11/25/22 05:06, Victor Porton wrote: >> A function argument that is both input and output, may be passed to >> the function either as reference or do two assignments: on entry of >> the function it is assigned to the parameter, on exit it is assigned >> back. The way I understand it with C, C

Re: Assigning parameter on entry to a function and assigning back on exit

2022-11-25 Thread Victor Porton via Digitalmars-d-learn
On Friday, 25 November 2022 at 11:01:09 UTC, Victor Porton wrote: Somewhere in my brain memory, it was written: A function argument that is both input and output, may be passed to the function either as reference or do two assignments: on entry of the function it is assigned to the parameter,

Assigning parameter on entry to a function and assigning back on exit

2022-11-25 Thread Victor Porton via Digitalmars-d-learn
Somewhere in my brain memory, it was written: A function argument that is both input and output, may be passed to the function either as reference or do two assignments: on entry of the function it is assigned to the parameter, on exit it is assigned back. Whether it is a reference or two assi