Re: Postblit constructor

2018-02-28 Thread Jiyan via Digitalmars-d-learn
On Wednesday, 28 February 2018 at 18:23:04 UTC, Jiyan wrote: Hey, i thought i had understood postblit, but in my Code the following is happening (simplified): struct C { this(this){/*Do sth*/} list!C; void opAssign(const C c) { "Postlbit from C called".writeln; // Do sth } } Sry of

Postblit constructor

2018-02-28 Thread Jiyan via Digitalmars-d-learn
Hey, i thought i had understood postblit, but in my Code the following is happening (simplified): struct C { this(this){/*Do sth*/} list!C; void opAssign(const C c) { "Postlbit from C called".writeln; // Do sth } } struct list(T) { node* head; node* last; size_t size; struct node { T val;

Re: Forward references

2018-02-25 Thread Jiyan via Digitalmars-d-learn
On Sunday, 25 February 2018 at 22:20:13 UTC, Steven Schveighoffer wrote: On 2/25/18 4:25 PM, Jiyan wrote: [...] Looks like this was fixed in 2.064. What version of the compiler are you using? -Steve 2.077.0 It is really strange, it works now but there still seems to be some strangeness

Forward references

2018-02-25 Thread Jiyan via Digitalmars-d-learn
Hi, is there any document or text describing forward references? It is kinda strange, i implemented a list structure which is kinda like this: struct list(T) { private: struct node { T val; node* next; node* prev; } node* head; node* last; size_t size; . } The thing is when i

Re: Destructing Struct

2018-02-21 Thread Jiyan via Digitalmars-d-learn
On Wednesday, 21 February 2018 at 11:12:01 UTC, Jiyan wrote: Hi :), What i thought was that when i create a struct dynamically i can just deconstruct it with __dtor lets say: struct U {...} struct S {... private U _member;} S* p; p = cast(S*)malloc(S.sizeof); // just run that if it

Destructing Struct

2018-02-21 Thread Jiyan via Digitalmars-d-learn
Hi :), What i thought was that when i create a struct dynamically i can just deconstruct it with __dtor lets say: struct U {...} struct S {... private U _member;} S* p; p = cast(S*)malloc(S.sizeof); // just run that if it compiles, for simplicity // we dont use __traits(compiles, ...)

Re: Interactive Interpreter

2018-02-06 Thread Jiyan via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 01:23:57 UTC, Stefan Koch wrote: On Monday, 5 February 2018 at 19:54:09 UTC, Jiyan wrote: Is there any work for an interactive interpreter for D -maybe just for ctfe-able expressions? It shouldnt be too hard to implement it regarding the fact, that ctfe is kinda

Interactive Interpreter

2018-02-05 Thread Jiyan via Digitalmars-d-learn
Is there any work for an interactive interpreter for D -maybe just for ctfe-able expressions? It shouldnt be too hard to implement it regarding the fact, that ctfe is kinda doing what an interpreter should do i guess.

Implicit conversion

2018-01-17 Thread Jiyan via Digitalmars-d-learn
Hello, I want to convert from ints implicit to a struct type, so for example: struct use { int x; int toInt() { return x; } use fromInt(int v) { return use(v); } alias toInt this; // implicit

Trait compiles

2018-01-15 Thread Jiyan via Digitalmars-d-learn
Hello, is there anyway to do something like this: mixin template foo( exp) { static if(__traits(compiles, exp))exp; } Thanks :)

Rvalue references

2018-01-08 Thread Jiyan via Digitalmars-d-learn
Sry i know i asked it already in IRC: Are rvalue references already solved with auto ref? https://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-ref-and-then-not-using-it Says rvalues are moved! The other solution seems not so practical. Is any solution to them intended, or

Re: Template Question

2017-11-19 Thread Jiyan via Digitalmars-d-learn
On Sunday, 19 November 2017 at 19:42:02 UTC, Jonathan M Davis wrote: On Sunday, November 19, 2017 19:25:40 Jiyan via Digitalmars-d-learn wrote: [...] Okay. For starters, [...] Ah ok thanks very much, this helped me a lot :)

Re: Template Question

2017-11-19 Thread Jiyan via Digitalmars-d-learn
On Sunday, 19 November 2017 at 19:28:37 UTC, Jonathan M Davis wrote: On Sunday, November 19, 2017 19:22:51 Jiyan via Digitalmars-d-learn wrote: Hello, i wanted to ask why this isnt working: struct Text(T : char) { size_t _len; T* _ptr; } Thanks :) What about it isn't working? I think

Re: Template Question

2017-11-19 Thread Jiyan via Digitalmars-d-learn
With working i mean that Text X; Doesnt compile!

Template Question

2017-11-19 Thread Jiyan via Digitalmars-d-learn
Hello, i wanted to ask why this isnt working: struct Text(T : char) { size_t _len; T* _ptr; } Thanks :)

Re: Imports

2017-10-05 Thread Jiyan via Digitalmars-d-learn
On Thursday, 5 October 2017 at 12:35:26 UTC, Mike Parker wrote: On Thursday, 5 October 2017 at 12:25:27 UTC, Mike Parker wrote: [...] Right. I had to go back and look at what I wrote in Learning D, which is the last (and only) time I played around with the default module behavior. I always

Re: Imports

2017-10-05 Thread Jiyan via Digitalmars-d-learn
On Thursday, 5 October 2017 at 00:28:32 UTC, Mike Parker wrote: On Wednesday, 4 October 2017 at 16:31:35 UTC, Jiyan wrote: [...] If you have this directory tree: - mylib -- pack1 --- a.d --- b.d pack2 - c.d [...] Thank you, i think i kinda got that :) But as i see it with

Imports

2017-10-04 Thread Jiyan via Digitalmars-d-learn
Hey, as i see it the -Ipath command for dmd just imports the files within a directory but it doesnt work for sub directories, so i can write something like: import subdirectoryFromPath.file; Also with dub this doesnt seem possible (sourcePaths seems to work as the -I command). Is there a

Re: Anonymous nogc class

2017-09-08 Thread Jiyan via Digitalmars-d-learn
On Friday, 8 September 2017 at 16:10:55 UTC, Biotronic wrote: On Friday, 8 September 2017 at 12:32:35 UTC, Jiyan wrote: [...] It's scoped!T's destructor. If you decide to use that workaround, you should probably copy scoped!T from std.typecons and have your own version. It's not safe in all

Re: Anonymous nogc class

2017-09-08 Thread Jiyan via Digitalmars-d-learn
On Friday, 8 September 2017 at 06:37:54 UTC, Biotronic wrote: On Thursday, 7 September 2017 at 23:40:11 UTC, Jiyan wrote: [...] Sadly, even std.typecons.scoped isn't currently @nogc: https://issues.dlang.org/show_bug.cgi?id=13972 https://issues.dlang.org/show_bug.cgi?id=17592 [...] First

Anonymous nogc class

2017-09-07 Thread Jiyan via Digitalmars-d-learn
Hey, wanted to know whether it is possible to make anonymous nogc classes: interface I { public void ap(); } void exec(I i) { i.ap; } // now execute, but with something like `scope` exec( new class I { int tr = 43; override void ap(){tr.writeln;} }); Thanks

Re: DlangUI Error

2017-08-11 Thread Jiyan via Digitalmars-d-learn
On Friday, 11 August 2017 at 02:25:51 UTC, Mike Parker wrote: On Thursday, 10 August 2017 at 23:38:42 UTC, Jiyan wrote: [...] Sounds like you used the script from the download page that installs the compiler per user. It's designed to allow you to have multiple versions installed in your

Re: DlangUI Error

2017-08-10 Thread Jiyan via Digitalmars-d-learn
On Thursday, 10 August 2017 at 22:27:44 UTC, HyperParrow wrote: On Thursday, 10 August 2017 at 20:48:23 UTC, Jiyan wrote: Hey, i get the following errors when i try to use dlangui, by just importing the package i get a lot of errors which look like: function std.xml.Item.opEquals does not

DlangUI Error

2017-08-10 Thread Jiyan via Digitalmars-d-learn
Hey, i get the following errors when i try to use dlangui, by just importing the package i get a lot of errors which look like: function std.xml.Item.opEquals does not override any function, did you mean to override 'object.Object.opEquals'? What is happening there?

Vectorflow noob

2017-08-10 Thread Jiyan via Digitalmars-d-learn
Hey, wanted to the following simple thing with vectorflow: I want to develop a simple MLP, which has 2 input neurons and one output neuron. The network should simply add the input values together, so [1,2] predicts [3] i guess. I started in a newbish way to build the following code: import

Re: Struct Postblit Void Initialization

2017-07-30 Thread Jiyan via Digitalmars-d-learn
On Sunday, 30 July 2017 at 19:32:48 UTC, Eugene Wissner wrote: On Sunday, 30 July 2017 at 19:22:07 UTC, Jiyan wrote: Hey, just wanted to know whether something like this would be possible sowmehow: struct S { int m; int n; this(this) { m = void; n = n; } } So not the whole struct is moved

Struct Postblit Void Initialization

2017-07-30 Thread Jiyan via Digitalmars-d-learn
Hey, just wanted to know whether something like this would be possible sowmehow: struct S { int m; int n; this(this) { m = void; n = n; } } So not the whole struct is moved everytime f.e. a function is called, but only n has to be "filled"

Re: Struct Constructor Lazy

2017-07-12 Thread Jiyan via Digitalmars-d-learn
Thank you, one last question: If i declare the parameter as ref i, then there shouldnt be any overhead wouldnt it? Thanks :)

Re: Struct Constructor Lazy

2017-07-12 Thread Jiyan via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 11:18:08 UTC, Biotronic wrote: On Wednesday, 12 July 2017 at 11:00:54 UTC, Jiyan wrote: [...] The traditional solution is static opCall: struct A { int field; static A opCall() { A result; result.field = getDataFromFile("file.txt");

Struct Constructor Lazy

2017-07-12 Thread Jiyan via Digitalmars-d-learn
Hey there:) i want to know whether the following is somehow possible: structs dont have default constructors, i know so: struct A { int field; this(int i){field = getDataFromFile("file.txt");} } A instance = A(0); Here comes my issue: when A(0) is called I would want here optimal performance,