Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
On Friday, 16 August 2019 at 12:23:01 UTC, Newbie2019 wrote: I has this simple function has some memory bugs: --- struct TreeRange { @disable this() ; @disable this(this) ; } struct Tree { ref auto getRange() return scope { return TreeRange!T(_root);

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
On Friday, 16 August 2019 at 13:51:49 UTC, Jonathan M Davis wrote: It is not possible to prevent moving in D as things currently stand. DIP 1014 will need to be implemented to either hook into moves or to prevent them. However, once DIP 1014 has been implemented, I would expect the result to

Re: Blog Post #0062: Cairo Load & Display Images

2019-08-16 Thread bauss via Digitalmars-d-learn
On Friday, 16 August 2019 at 11:42:01 UTC, Ron Tarrant wrote: Continuing on with Cairo, this post covers loading and displaying three types of image (including a structured drawing) using two different load-n-display methods. As an extra bonus, you'll see a photo of my cat, Bob, and three of

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 16, 2019 6:29:19 AM MDT Newbie2019 via Digitalmars-d-learn wrote: > On Friday, 16 August 2019 at 12:23:01 UTC, Newbie2019 wrote: > > I has this simple function has some memory bugs: > > > > --- > > struct TreeRange { > > > > @disable this() ; > > @disable this(this)

Re: advise about safety of using move in an opAssign with __traits(isRef

2019-08-16 Thread Paul Backus via Digitalmars-d-learn
On Friday, 16 August 2019 at 08:07:28 UTC, aliak wrote: Hi, I'm trying to fix a use-case where you have a wrapper template type (it's an optional) and the wrapping type has @disable this(this). And having this scenario work: [...] 2) use isRef inside opAssign like this: void opAssign(auto

ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
I has this simple function has some memory bugs: --- struct TreeRange { @disable this() ; @disable this(this) ; } struct Tree { ref auto getRange() return scope { return TreeRange!T(_root); } } Tree tree; auto range = tree.getRange(); --

Blog Post #0062: Cairo Load & Display Images

2019-08-16 Thread Ron Tarrant via Digitalmars-d-learn
Continuing on with Cairo, this post covers loading and displaying three types of image (including a structured drawing) using two different load-n-display methods. As an extra bonus, you'll see a photo of my cat, Bob, and three of the seven guitars I've found in my building's recycle room

Re: Blog Post #0062: Cairo Load & Display Images

2019-08-16 Thread Andre Pany via Digitalmars-d-learn
On Friday, 16 August 2019 at 11:42:01 UTC, Ron Tarrant wrote: Continuing on with Cairo, this post covers loading and displaying three types of image (including a structured drawing) using two different load-n-display methods. As an extra bonus, you'll see a photo of my cat, Bob, and three of

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 16, 2019 8:14:52 AM MDT Newbie2019 via Digitalmars-d-learn wrote: > On Friday, 16 August 2019 at 13:51:49 UTC, Jonathan M Davis wrote: > > It is not possible to prevent moving in D as things currently > > stand. DIP 1014 will need to be implemented to either hook into > > moves

Re: Arrays in the disk

2019-08-16 Thread Giovanni Di Maria via Digitalmars-d-learn
On Friday, 16 August 2019 at 07:27:36 UTC, zabruk wrote: may be std.mmfile can be usefull https://dlang.org/phobos/std_mmfile.html Thank you Zabruk. I will study it. Giovanni

Re: ref auto getRange() return scope move struct ?

2019-08-16 Thread Newbie2019 via Digitalmars-d-learn
On Friday, 16 August 2019 at 16:22:27 UTC, Jonathan M Davis wrote: [...] Thanks very much again, very helpful explain. I use pass by ref scope instead "return TreeRange.__ctor();" to workround this issue.

Arrays in the disk

2019-08-16 Thread Giovanni Di Maria via Digitalmars-d-learn
Hi Do they exist arrays in the disk? I must manage very very large data. Thank you very much. Giovanni

Re: Arrays in the disk

2019-08-16 Thread zabruk via Digitalmars-d-learn
may be std.mmfile can be usefull https://dlang.org/phobos/std_mmfile.html

Is it a bug in std.getopt.config.stopOnFirstNonOption?

2019-08-16 Thread Andrey Zherikov via Digitalmars-d-learn
Here is the code I have which doesn't work: ``` string[] foo; string[] bar; auto args = ["app", "--bar", "bar", "--foo", "foo"]; // (1) import std.getopt; getopt(args, std.getopt.config.stopOnFirstNonOption, // (2) "foo", , "bar", ); ``` The error I see:

Re: error : outer function context of `D main` is needed to `new` nested class `main.main.X`

2019-08-16 Thread Bert via Digitalmars-d-learn
On Thursday, 15 August 2019 at 02:23:06 UTC, Adam D. Ruppe wrote: On Thursday, 15 August 2019 at 01:55:17 UTC, Bert wrote: void main() { class X { ... } I would just make it `static class X` and then it should work fine. Won't be able to access main's local variables then though, but

Re: Is it a bug in std.getopt.config.stopOnFirstNonOption?

2019-08-16 Thread Ali Çehreli via Digitalmars-d-learn
On 08/16/2019 02:07 PM, Andrey Zherikov wrote: But: - if I change line (1) to `auto args = ["app", "--foo", "foo", "--bar", "bar"];` then this code works. - if I remove line (2) then this code works. Yes, it's a bug. Another workaround--which I haven't tested to see whether produces the

Re: Cannot take the .keys of shared AA. Is this a regression in 2.087 or a feature?

2019-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 16, 2019 2:16:31 AM MDT Piotr Mitana via Digitalmars-d- learn wrote: > On Thursday, 15 August 2019 at 19:51:30 UTC, Jonathan M Davis > > wrote: > > Not being able to implicitly convert to const is a bit odd, but > > arguably, nothing should ever be called on a shared AA anyway. >

advise about safety of using move in an opAssign with __traits(isRef

2019-08-16 Thread aliak via Digitalmars-d-learn
Hi, I'm trying to fix a use-case where you have a wrapper template type (it's an optional) and the wrapping type has @disable this(this). And having this scenario work: struct S { @disable this(this); } Optional!S fun() {...} Optional!S a; a = fun.move; Now that won't work because of the

Re: Cannot take the .keys of shared AA. Is this a regression in 2.087 or a feature?

2019-08-16 Thread Piotr Mitana via Digitalmars-d-learn
On Thursday, 15 August 2019 at 19:51:30 UTC, Jonathan M Davis wrote: Not being able to implicitly convert to const is a bit odd, but arguably, nothing should ever be called on a shared AA anyway. If an operation isn't thread-safe, then it shouldn't work with shared. To use a shared object