Re: Why is GC.collect `pure`

2023-08-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, August 2, 2023 12:02:35 PM MDT Nick Treleaven via Digitalmars-d- learn wrote: > On Wednesday, 2 August 2023 at 17:55:12 UTC, Nick Treleaven wrote: > > On Wednesday, 2 August 2023 at 17:52:00 UTC, Nick Treleaven > > > > wrote: > >> Now I'm wondering why those functions are marked

Re: Why is GC.collect `pure`

2023-08-02 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 2 August 2023 at 17:55:12 UTC, Nick Treleaven wrote: On Wednesday, 2 August 2023 at 17:52:00 UTC, Nick Treleaven wrote: Now I'm wondering why those functions are marked `pure` - they must affect the GC's bookkeeping state. I guess it was because the GC's internal state is not

Re: Why is GC.collect `pure`

2023-08-02 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 2 August 2023 at 17:52:00 UTC, Nick Treleaven wrote: Now I'm wondering why those functions are marked `pure` - they must affect the GC's bookkeeping state. Here's the pull that added it: https://github.com/dlang/druntime/pull/3561

Why is this pure function taking a string literal not CTFE-executable?

2019-06-01 Thread Simon via Digitalmars-d-learn
Hi Guys! In my programm, I have a custom String-type that I want to initialize some variables of at compile time by casting a string literal to said custom String type. I thought I could achieve this straight forwardly, but after trying a bit, I could not find a (simple) working solution. I

Re: Why is my @pure function @system when placed in a struct?

2019-02-27 Thread ag0aep6g via Digitalmars-d-learn
On 27.02.19 19:10, Dukc wrote: I tested a bit, and it appears that attribute inference is not done at all for templates inside structs -the attribute need not be a delegate: struct S     {     static int fImpl(Ret)() { return Ret.init; }     pragma(msg,

Re: Why is my @pure function @system when placed in a struct?

2019-02-27 Thread Dukc via Digitalmars-d-learn
On Wednesday, 27 February 2019 at 17:23:21 UTC, Q. Schroll wrote: For whatever reason, when I put the code in a struct, the @safe testing line tells me, it's @system now. I tested a bit, and it appears that attribute inference is not done at all for templates inside structs -the attribute

Re: Why is my @pure function @system when placed in a struct?

2019-02-27 Thread Dukc via Digitalmars-d-learn
On Wednesday, 27 February 2019 at 18:06:49 UTC, Stefan Koch wrote: the struct gets drawn into your delegate-context. and I guess that taints the function. Even if it did, it should not make the delegate @system. And it does not, since this manifest with static functions and function

Re: Why is my @pure function @system when placed in a struct?

2019-02-27 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 27 February 2019 at 17:23:21 UTC, Q. Schroll wrote: I have a template function `fImpl` I whish to instantiate manually using the new name `f`. Reason is simple: `f` should not be a template, but overloading it makes it easier that way. Nothing's more simple in D: [...] the

Why is my @pure function @system when placed in a struct?

2019-02-27 Thread Q. Schroll via Digitalmars-d-learn
I have a template function `fImpl` I whish to instantiate manually using the new name `f`. Reason is simple: `f` should not be a template, but overloading it makes it easier that way. Nothing's more simple in D: int fImpl(T)(T value) { return cast(int) value; } alias f = fImpl!int;

Why is this pure?

2014-08-25 Thread Shachar via Digitalmars-d-learn
The following program compiles, and does what you'd expect: struct A { int a; } pure int func( ref A a ) { return a.a += 3; } As far as I can tell, however, it shouldn't. I don't see how or why func can possibly be considered pure, as it changes a state external to the function.

Re: Why is this pure?

2014-08-25 Thread Alex Rønne Petersen via Digitalmars-d-learn
On Monday, 25 August 2014 at 06:27:00 UTC, Shachar wrote: The following program compiles, and does what you'd expect: struct A { int a; } pure int func( ref A a ) { return a.a += 3; } As far as I can tell, however, it shouldn't. I don't see how or why func can possibly be considered