Re: Pass 'this' as reference

2018-09-19 Thread Jan via Digitalmars-d-learn
On Saturday, 15 September 2018 at 20:13:51 UTC, Jonathan M Davis wrote: On Saturday, September 15, 2018 11:44:05 AM MDT Jan via Digitalmars-d-learn wrote: [...] No. variables are _always_ lvalues. An lvalue is an object which is addressable and which can therefore be assigned a value

Pass 'this' as reference

2018-09-12 Thread Jan via Digitalmars-d-learn
I'm using D not for that long and lately I have encountered an issue. I have class 'Foo' with a constructor using this signature: `this (ref Bar original)` In the 'Bar' class itself I want to create an instance of 'Foo' using 'this' as parameter. Something in the way of: `Foo foo = new

Re: Pass 'this' as reference

2018-09-13 Thread Jan via Digitalmars-d-learn
Many thanks Adam and Steve! Works like a charm! :D I presumed classes are lvalues. I shouldn't make things more complicated than they are ;-)

Re: Pass 'this' as reference

2018-09-15 Thread Jan via Digitalmars-d-learn
On Thursday, 13 September 2018 at 11:08:30 UTC, Jonathan M Davis wrote: [...] Thanks for clarifying Jonathan :) But aren't the variables considered rvalues then?

Mimicking a shell

2019-12-29 Thread Jan via Digitalmars-d-learn
Hi, Is there a way to forward all input and output from a shell? This implies that e.g. pressing the left arrow on the keyboard is immediately being forwarded to the shell and that the output from a shell would be *exactly* the same as output from my D program (that would include the prompt

Re: Mimicking a shell

2020-01-04 Thread Jan via Digitalmars-d-learn
On Sunday, 29 December 2019 at 19:21:53 UTC, Adam D. Ruppe wrote: On Sunday, 29 December 2019 at 17:03:14 UTC, Jan wrote: Is there a way to forward all input and output from a shell? yes, but it is platform specific and can be a decent amount of code. what OS are you on? I am using Linux

Re: Mimicking a shell

2020-01-06 Thread Jan via Digitalmars-d-learn
I think the suggestion of angel would be most fitting for my case. As angel said, the using the C code for D would be a relatively small refactor. if you want to send like a synthetic arrow keystroke, well, things get ugly again, it will need to send the right series of bytes based on what

C++/D class interop example crashes

2021-03-27 Thread Jan via Digitalmars-d-learn
I just tried to get this example to work: https://dlang.org/spec/cpp_interface.html#using_d_classes_from_cpp It kept crashing for me with a 'privileged instruction' error when the function 'bar' was executed. Finally I removed the call to writefln and voilĂ  it finally works. So why does it

Re: C++/D class interop example crashes

2021-03-27 Thread Jan via Digitalmars-d-learn
On Saturday, 27 March 2021 at 18:39:53 UTC, Bastiaan Veelo wrote: The example links objects statically. You may be experiencing additional challenges with crossing DLL boundaries. I have not yet used DLLs, but did you initialise the D runtime? I haven't done anything extra (I'm pretty new to