Re: how do i fix this node_dlang error?

2021-06-07 Thread NotSpooky via Digitalmars-d-learn

On Tuesday, 8 June 2021 at 03:04:39 UTC, Mike Parker wrote:

On Tuesday, 8 June 2021 at 00:58:12 UTC, Jack wrote:

the dll which I was just build with dub command? how I have a 
version mismatch if they're the very same file?


Electron embeds node and does not use whatever you have on your 
system. So if there’s a mismatch between the embedded version 
and the one you linked against, you can see the error you’re 
seeing.


I don't use Windows often, my bad for incompatibilities there.

I updated Electron, node and DMD. After running

console.log (process.versions)

in Electron I get:

{
  node: '14.16.0',
  v8: '9.1.269.28-electron.0',
  uv: '1.40.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.16.1',
  modules: '89',
  nghttp2: '1.41.0',
  napi: '7',
  llhttp: '2.1.3',
  openssl: '1.1.1',
  icu: '68.1',
  unicode: '13.0',
  electron: '13.1.1',
  chrome: '91.0.4472.77'
}

So I changed node.lib in node_dlang with the version from 
https://nodejs.org/download/release/v14.16.0/win-x64/


However, I get an Error: A dynamic link library (DLL) 
initialization routine failed.


So I'll have to check what's happening now. It might be some API 
change in Node-API or something spookier.

These days I'm quite busy but will do my best to fix this.


Re: how do i fix this node_dlang error?

2021-06-06 Thread NotSpooky via Digitalmars-d-learn

On Sunday, 6 June 2021 at 04:25:39 UTC, Jack wrote:
I'm trying to use the node_dlang pakckage but the code example 
from [this 
repo](https://github.com/NotSpooky/node_dlang/tree/v0.4.11/examples) isn't working


the command ```dub build``` is fine but ```node example.js``` 
retuns an error saying the module.node is not a valid win32 
application. How do I fix this?


[1]: 
https://github.com/NotSpooky/node_dlang/tree/v0.4.11/examples


Hello, I'm the author of the library.
Indeed I only tested it on 64-bit systems. I can try to make it 
32-bit compatible if needed.


Aside from the auto-translated headers, in the case of Windows 
the repo also includes node.lib compiled for 64-bit, so unless 
the 32-bit version is added it will also give errors.


I'm pretty sure it does work with electron as I have used it 
myself.


Re: Read from terminal when enter is pressed, but do other stuff in the mean time...

2017-07-13 Thread NotSpooky via Digitalmars-d-learn

On Thursday, 13 July 2017 at 15:52:57 UTC, Dustmight wrote:
How do I read in input from the terminal without sitting there 
waiting for it? I've got code I want to run while there's no 
input, and then code I want to act on input when it comes in. 
How do I do both these things?


Might want to check Adam's Terminal.d
https://code.dlang.org/packages/arsd-official%3Aterminal
Docs at http://dpldocs.info/experimental-docs/arsd.terminal.html

You can use a RealTimeConsoleInput with getch. You can use kbhit 
to check whether getch would block. However I found inconsistent 
behavior between platforms with kbhit, so might wanna test.


Re: 'fopen64 cannot be interpreted at compile time' for __gshared File

2017-03-25 Thread NotSpooky via Digitalmars-d-learn

On Saturday, 25 March 2017 at 15:52:15 UTC, crimaniak wrote:

Simple File test:

void main()
{
import std.stdio;

File f = File("test.txt", "w");

f.writeln("hello");
}

All works as expected.

Now let's add __gshared:

void main()
{
import std.stdio;

__gshared File f = File("test.txt", "w");

f.writeln("hello");
}

Now we have:

/usr/include/dmd/phobos/std/stdio.d(3797): Error: fopen64 
cannot be interpreted at compile time, because it has no 
available source code
/usr/include/dmd/phobos/std/stdio.d(3804):called from 
here: fopenImpl(namez.ptr(), modez.ptr())
/usr/include/dmd/phobos/std/stdio.d(404):called from 
here: fopen(name, stdioOpenmode)
/usr/include/dmd/phobos/std/stdio.d(404):called from 
here: errnoEnforce(fopen(name, stdioOpenmode), delegate 
string() => text("Cannot open file `", name, "' in mode `", 
stdioOpenmode, "'"))
/usr/include/dmd/phobos/std/stdio.d(404):called from 
here: this.this(errnoEnforce(fopen(name, stdioOpenmode), 
delegate string() => text("Cannot open file `", name, "' in 
mode `", stdioOpenmode, "'")), name, 1u, false)
file.d(5):called from here: ((File __slFile648 = 
File(null, null);) , __slFile648).this("test.txt", "w")


Oooops! Who can explain this error message to me?

DMD64 D Compiler v2.073.0


__gshared implies static, that is, known at compile time (ct), 
that means the File constructor should be done at ct and thus 
open the file. Compile time function execution doesn't allow IO 
operations, however you can use 
https://dlang.org/spec/expression.html#ImportExpression if you 
want to read a file at compile time.


Re: std.digest toHexString

2017-03-18 Thread NotSpooky via Digitalmars-d-learn

On Thursday, 16 March 2017 at 22:06:24 UTC, H. S. Teoh wrote:
On Thu, Mar 16, 2017 at 02:36:15PM -0700, Jonathan M Davis via 
Digitalmars-d-learn wrote: [...]
Honestly, I think that it was a big mistake to have implicit 
slicing of static arrays in the language at all.


That makes at least 3 of us -- Adam, you, me. I'm sure there 
are more.


Make it 4.


Re: Assigning in constructor.

2017-01-18 Thread NotSpooky via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 23:08:07 UTC, Adam D. Ruppe 
wrote:

On Wednesday, 18 January 2017 at 22:57:22 UTC, NotSpooky wrote:
Is it undefined behavior to assign  to a pointer in the 
constructor of a struct?


Yes:

http://dlang.org/spec/struct.html
"A struct is defined to not have an identity; that is, the 
implementation is free to make bit copies of the struct as 
convenient."


That means it might copy and/or move it without giving you a 
chance to update the pointer. Updating in postblit can help 
sometimes but still the compiler and library are allowed to 
move structs without notice.


You already answered on the IRC so thanks X2.
So, it's problematic to have pointers to structs in all cases 
according to spec?


Assigning in constructor.

2017-01-18 Thread NotSpooky via Digitalmars-d-learn
Is it undefined behavior to assign  to a pointer in the 
constructor of a struct?