Re: F*cked by memory corruption after assiging value to associative array

2021-01-28 Thread tsbockman via Digitalmars-d-learn
On Thursday, 28 January 2021 at 07:50:43 UTC, frame wrote: Under Linux everything is shared. Under Windows each DLL seems to run in its own thread, has its own rt_options and do not see any __gshared variable value. Its completely isolated and so I assume that also GC is. This stuff works

emplace doesn't forward aeguments

2021-01-28 Thread vitamin via Digitalmars-d-learn
Is there reason why std.conv.emplace doesn't forward arguments to __ctor? this doesn't work: import std.conv : emplace; import std.functional : forward; struct Bar{ @disable this(const ref typeof(this) rhs)pure nothrow @safe @nogc; } class Foo{ Bar bar; this(Bar bar){

Re: Why filling AA in shared library freezes execution?

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 12:42:09 UTC, Siemargl wrote: Update. Something is broken in DLL support in druntime for Win7. I take previous working in Win10 binary and try run it in virtual Windows 7 SP1 x64. Got this You can't expect that a Win10 build also runs on Win7.

Re: Why filling AA in shared library freezes execution?

2021-01-28 Thread Siemargl via Digitalmars-d-learn
On Thursday, 28 January 2021 at 16:46:40 UTC, frame wrote: On Thursday, 28 January 2021 at 12:42:09 UTC, Siemargl wrote: Update. Something is broken in DLL support in druntime for Win7. I take previous working in Win10 binary and try run it in virtual Windows 7 SP1 x64. Got this You can't

What are these functions called and how to implement they?

2021-01-28 Thread dog2002 via Digitalmars-d-learn
I saw these functions in some projects. For example: in Dagon (https://gecko0307.github.io/dagon/) there are functions like onKeyDown. This function doesn't need to call - it checks pressed keys every time. Or Update in Unity (game engine). It doesn't need to call, but it executes itself every

Re: What are these functions called and how to implement they?

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 17:10:57 UTC, dog2002 wrote: I saw these functions in some projects. For example: in Dagon (https://gecko0307.github.io/dagon/) there are functions like onKeyDown. This function doesn't need to call - it checks pressed keys every time. Or Update in Unity (game

Re: Why does calling readln() more than once not work

2021-01-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 28 January 2021 at 19:25:52 UTC, Ruby The Roobster wrote: readf(" %d",); This leaves the \n at the end. A next readf thanks to the leading space would ignore that \n and keep going, but a readln stops at the first \n it sees, even if it is a leftover item in the buffer

unittests and imported modules

2021-01-28 Thread kdevel via Digitalmars-d-learn
Today I moved some functions to a new module within the same package and ran dmd -g -i -unittest -checkaction=context -main -run . dmd reported 5 unittests passed I would have expected that only the one unittest in would have been compiled. After inserting print statements into the

Re: unittests and imported modules

2021-01-28 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 28, 2021 at 07:44:59PM +, kdevel via Digitalmars-d-learn wrote: > Today I moved some functions to a new module within the same package > and ran > >dmd -g -i -unittest -checkaction=context -main -run . > > dmd reported > >5 unittests passed Which version of dmd is this?

Re: emplace doesn't forward aeguments

2021-01-28 Thread kinke via Digitalmars-d-learn
On Thursday, 28 January 2021 at 21:15:49 UTC, vitamin wrote: Is there reason why std.conv.emplace doesn't forward arguments to __ctor? Yeah, a bug in the emplace() version for classes, some missing `forward!args` in there (it works when emplacing a struct with identical ctor). E.g.

Re: Why does calling readln() more than once not work

2021-01-28 Thread Ruby The Roobster via Digitalmars-d-learn
On Thursday, 28 January 2021 at 19:31:35 UTC, Adam D. Ruppe wrote: On Thursday, 28 January 2021 at 19:25:52 UTC, Ruby The Roobster wrote: readf(" %d",); This leaves the \n at the end. A next readf thanks to the leading space would ignore that \n and keep going, but a readln stops at

Re: F*cked by memory corruption after assiging value to associative array

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 19:22:16 UTC, tsbockman wrote: It is possible to get things sort of working with on Windows, anyway. I'm ok with it as long as the memory is not re-used by the GC. It seems that it can be prevented with addRoot() successfully. The other problem with shared

Re: Compile time check for GC?

2021-01-28 Thread Kagamin via Digitalmars-d-learn
You can make it opt in, it's insurance.

Re: unittests and imported modules

2021-01-28 Thread kdevel via Digitalmars-d-learn
On Thursday, 28 January 2021 at 20:03:34 UTC, H. S. Teoh wrote: [...] 5 unittests passed Which version of dmd is this? $ dmd --version DMD64 D Compiler v2.093.1 Copyright (C) 1999-2020 by The D Language Foundation, All Rights Reserved written by Walter Bright In the latest releases,

Re: F*cked by memory corruption after assiging value to associative array

2021-01-28 Thread tsbockman via Digitalmars-d-learn
On Thursday, 28 January 2021 at 20:17:09 UTC, frame wrote: On Thursday, 28 January 2021 at 19:22:16 UTC, tsbockman wrote: It is possible to get things sort of working with on Windows, anyway. I'm ok with it as long as the memory is not re-used by the GC. It seems that it can be prevented

Re: Why filling AA in shared library freezes execution?

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 07:51:06 UTC, SealabJaster wrote: On Wednesday, 27 January 2021 at 16:38:07 UTC, Adam D. Ruppe wrote: ... Yikes! Ok, I thought DLLs were just "sort of" unusable due to the RTTI issue, but now I'm convinced that they're almost completely useless in their

How do I compose pipes?

2021-01-28 Thread Anthony via Digitalmars-d-learn
This post https://dlang.org/library/std/process/pipe.html mentions: Pipes can, for example, be used for interprocess communication by spawning a new process and passing one end of the pipe to the child, while the parent uses the other end. (See also pipeProcess and pipeShell for an easier

Re: Why filling AA in shared library freezes execution?

2021-01-28 Thread Siemargl via Digitalmars-d-learn
On Friday, 29 January 2021 at 00:45:12 UTC, Siemargl wrote: Then i modify program, just removing DLL, copying TestFun() in main module and it runs. Same compiler -m64 target. Ups. Sorry, I just forget copy test_dll.dll inside VM :-) So, program runs in Win7, but hangs after printing i:64511

Re: How do I compose pipes?

2021-01-28 Thread Ali Çehreli via Digitalmars-d-learn
On 1/28/21 3:45 PM, Anthony wrote: > void end(AccumulatorPipe acc) { > auto pids = acc.pids ~ P.spawnShell("cat", acc.stdout); > > foreach (pid; pids) { > P.wait(pid); > } > } > ``` > > > So now I can do something like: > ``` > run("find source -name '*.d'") >

Re: How do I compose pipes?

2021-01-28 Thread Anthony via Digitalmars-d-learn
On Friday, 29 January 2021 at 03:49:38 UTC, Ali Çehreli wrote: On 1/28/21 3:45 PM, Anthony wrote: > void end(AccumulatorPipe acc) { > auto pids = acc.pids ~ P.spawnShell("cat", acc.stdout); > > foreach (pid; pids) { > P.wait(pid); > } > } > ``` > > > So now I can do

Re: How do I compose pipes?

2021-01-28 Thread Anthony via Digitalmars-d-learn
On Thursday, 28 January 2021 at 17:18:46 UTC, Ali Çehreli wrote: On 1/28/21 2:16 AM, Anthony wrote: > auto p = pipeProcess("ls"); > auto q = pipeProcess("cat", stdin = p.stdout); //it would be good to do That would work if `cat` received the *contents* of the files (and with a "-" command

Re: Why filling AA in shared library freezes execution?

2021-01-28 Thread Siemargl via Digitalmars-d-learn
On Thursday, 28 January 2021 at 12:42:09 UTC, Siemargl wrote: Update. Something is broken in DLL support in druntime for Win7. I take previous working in Win10 binary and try run it in virtual Windows 7 SP1 x64. Got this C:\Proj\dtest>test_dll_exe.exe object.Exception@test_dll_exe.d(7):

Re: unittests and imported modules

2021-01-28 Thread H. S. Teoh via Digitalmars-d-learn
To answer your other question: On Thu, Jan 28, 2021 at 07:44:59PM +, kdevel via Digitalmars-d-learn wrote: [...] > After inserting print statements into the other modules I found that > the additional four unittests originate from the imported files. Is > there a trick to get only the

Why does calling readln() more than once not work

2021-01-28 Thread Ruby The Roobster via Digitalmars-d-learn
I call readln() on a variable in a loop. On the next iteration, it's as if the readln() is ignored, as it moves on to the next line apparently. Here is the code: for(int i = 1;i<1000;i++) { int tempx; int tempy; int high = 0; double highs = 0;

Re: Why does calling readln() more than once not work

2021-01-28 Thread Ruby The Roobster via Digitalmars-d-learn
On Thursday, 28 January 2021 at 19:25:52 UTC, Ruby The Roobster wrote: I call readln() on a variable in a loop. On the next iteration, it's as if the readln() is ignored, as it moves on to the next line apparently. Here is the code: for(int i = 1;i<1000;i++) { int tempx;

Re: How do I compose pipes?

2021-01-28 Thread Ali Çehreli via Digitalmars-d-learn
On 1/28/21 2:16 AM, Anthony wrote: > auto p = pipeProcess("ls"); > auto q = pipeProcess("cat", stdin = p.stdout); //it would be good to do That would work if `cat` received the *contents* of the files (and with a "-" command line switch). Since `ls` produces file names, you would have to make

Re: Why am I getting a dividing by zero error message

2021-01-28 Thread tsbockman via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:37:37 UTC, Ruby The Roobster wrote: Here is the output/input of the program: Type in data for an egg: Width: 3 Hight: 2 object.Error@(0): Integer Divide by Zero ... Here is the source code: import std.stdio; import std.string; void main(){ egg[1000]

Re: What are these functions called and how to implement they?

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:27:09 UTC, frame wrote: Not 100% sure what you mean but I guess you ask how to implement a handler? If an event occurs, a routine decides to call your onKeyPressed function and pass the keyCode which was pressed. The routine must be registered on a event

Re: Why am I getting a dividing by zero error message

2021-01-28 Thread Ruby The Roobster via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:56:45 UTC, Ruby The Roobster wrote: On Thursday, 28 January 2021 at 18:53:51 UTC, Dennis wrote: On Thursday, 28 January 2021 at 18:37:37 UTC, Ruby The Roobster wrote: object.Error@(0): Integer Divide by Zero Why is this happening? Does anybody know?

Re: Why am I getting a dividing by zero error message

2021-01-28 Thread Ruby The Roobster via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:53:51 UTC, Dennis wrote: On Thursday, 28 January 2021 at 18:37:37 UTC, Ruby The Roobster wrote: object.Error@(0): Integer Divide by Zero Why is this happening? Does anybody know? data[0] = (new egg(0,0,"a")); Here you set data[0].y to 0 tempb =

Why am I getting a dividing by zero error message

2021-01-28 Thread Ruby The Roobster via Digitalmars-d-learn
Here is the output/input of the program: Type in data for an egg: Width: 3 Hight: 2 object.Error@(0): Integer Divide by Zero 0x004023FE 0x0040CF9F 0x0040CF19 0x0040CDB4 0x00409033 0x00402638 0x75F86359 in BaseThreadInitThunk 0x77018944 in RtlGetAppContainerNamedObjectPath

Re: Why am I getting a dividing by zero error message

2021-01-28 Thread Dennis via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:37:37 UTC, Ruby The Roobster wrote: object.Error@(0): Integer Divide by Zero Why is this happening? Does anybody know? data[0] = (new egg(0,0,"a")); Here you set data[0].y to 0 tempb = data[x].y; In the first iteration, this equals data[0].y which

Re: Why am I getting a dividing by zero error message

2021-01-28 Thread evilrat via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:37:37 UTC, Ruby The Roobster wrote: Here is the output/input of the program: Type in data for an egg: Width: 3 Hight: 2 object.Error@(0): Integer Divide by Zero 0x004023FE 0x0040CF9F 0x0040CF19 0x0040CDB4 0x00409033 0x00402638 0x75F86359 in

Re: Why am I getting a dividing by zero error message

2021-01-28 Thread jmh530 via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:37:37 UTC, Ruby The Roobster wrote: Here is the output/input of the program: Type in data for an egg: Width: 3 Hight: 2 [...] It might help to separate break this out into smaller functions. May make it easier to follow what is happening.

Re: Why filling AA in shared library freezes execution?

2021-01-28 Thread frame via Digitalmars-d-learn
On Thursday, 28 January 2021 at 17:00:35 UTC, Siemargl wrote: On Thursday, 28 January 2021 at 16:46:40 UTC, frame wrote: On Thursday, 28 January 2021 at 12:42:09 UTC, Siemargl wrote: Update. Something is broken in DLL support in druntime for Win7. I take previous working in Win10 binary and

Re: What are these functions called and how to implement they?

2021-01-28 Thread dog2002 via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:56:15 UTC, frame wrote: On Thursday, 28 January 2021 at 18:27:09 UTC, frame wrote: [...] A very simple example: bool myEventA = true; bool myEventB = false; // event source that generates the event (must be called to run) void source() {

Weird interaction with public and non-public imports

2021-01-28 Thread SealabJaster via Digitalmars-d-learn
Please see: https://run.dlang.io/is/2mwcPH I'd expect that the `isInstanceOf` would be true instead of false here. Commenting out the public import changes the output of `fullyQualifiedName`. I can kind of see why this happens, but it's kind of annoying when things like `isInstanceOf`

Re: Weird interaction with public and non-public imports

2021-01-28 Thread SealabJaster via Digitalmars-d-learn
On Thursday, 28 January 2021 at 13:13:46 UTC, Paul Backus wrote: ... https://issues.dlang.org/show_bug.cgi?id=21589 These issues are always so subtle and specific yet so annoying, e.g.: https://issues.dlang.org/show_bug.cgi?id=21496 and https://issues.dlang.org/show_bug.cgi?id=21377

Re: How to dinamically create Tuples?

2021-01-28 Thread Leonardo via Digitalmars-d-learn
On Wednesday, 27 January 2021 at 17:28:00 UTC, H. S. Teoh wrote: On Wed, Jan 27, 2021 at 05:17:18PM +, Paul Backus via Digitalmars-d-learn wrote: On Wednesday, 27 January 2021 at 17:11:52 UTC, Leonardo wrote: > Hi, I want to know if are some way to dinamically create > Tuples, with

Re: Why filling AA in shared library freezes execution?

2021-01-28 Thread Siemargl via Digitalmars-d-learn
Update. Something is broken in DLL support in druntime for Win7. I take previous working in Win10 binary and try run it in virtual Windows 7 SP1 x64. Got this C:\Proj\dtest>test_dll_exe.exe object.Exception@test_dll_exe.d(7): Enforcement failed 0x0001400013A3

Re: Weird interaction with public and non-public imports

2021-01-28 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 28 January 2021 at 13:07:13 UTC, SealabJaster wrote: Please see: https://run.dlang.io/is/2mwcPH I'd expect that the `isInstanceOf` would be true instead of false here. Commenting out the public import changes the output of `fullyQualifiedName`. I can kind of see why this