Re: @safe std.file.read

2020-01-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 6, 2020 8:52:01 AM MST Steven Schveighoffer via Digitalmars-d-learn wrote: > On 1/6/20 5:07 AM, WebFreak001 wrote: > > I was wondering, how are you supposed to use std.file : read in @safe > > code when it returns a void[] but you want to get all bytes in the file? > > > > Is

Re: Algebraic and implicit conversions

2020-01-06 Thread drug via Digitalmars-d-learn
06.01.2020 22:48, Steven Schveighoffer пишет: I think his question is, why shouldn't this work? e.g., this works: Ah, indeed. Sorry for noise.

Re: Algebraic and implicit conversions

2020-01-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/6/20 2:33 PM, drug wrote: 06.01.2020 20:08, Per Nordlöw пишет: alias A = Algebraic!(long, string); A x; x = 42; That's because you try to assign int, not long. This works: alias A = Algebraic!(long, string); A x; x = 42L; I think his question is, why shouldn't this work?

Re: Algebraic and implicit conversions

2020-01-06 Thread drug via Digitalmars-d-learn
06.01.2020 20:08, Per Nordlöw пишет: alias A = Algebraic!(long, string);     A x;     x = 42; That's because you try to assign int, not long. This works: alias A = Algebraic!(long, string); A x; x = 42L;

Algebraic and implicit conversions

2020-01-06 Thread Per Nordlöw via Digitalmars-d-learn
Is there a reason why alias A = Algebraic!(long, string); A x; x = 42; doesn't implicitly convert `42` to `long` and stores it in `x`?

Re: @safe std.file.read

2020-01-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/6/20 5:07 AM, WebFreak001 wrote: Or should void[] actually be castable to ubyte[] in @safe code? No, because you can implicitly cast anything to void[], including pointer arrays. Possibly const(ubyte[]). -Steve

Re: @safe std.file.read

2020-01-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/6/20 5:07 AM, WebFreak001 wrote: I was wondering, how are you supposed to use std.file : read in @safe code when it returns a void[] but you want to get all bytes in the file? Is void[] really the correct type it should be returning instead of ubyte[] when it just reads a (binary) file

Re: Unfold string array

2020-01-06 Thread Teo via Digitalmars-d-learn
On Monday, 6 January 2020 at 00:03:06 UTC, Temtaime wrote: https://ideone.com/tvpreP That's cool! Thank you very much!

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

Re: How load icon from resource using LoadImage?

2020-01-06 Thread ShadoLight via Digitalmars-d-learn
On Sunday, 5 January 2020 at 13:52:27 UTC, JN wrote: On Sunday, 5 January 2020 at 13:33:35 UTC, Marcone wrote: [snip] By the way, have you managed to add the res file into the binary? My understanding is that the res file should be added into the exe file by the rc command before it can be

Re: What type does byGrapheme() return?

2020-01-06 Thread Alex via Digitalmars-d-learn
On Monday, 6 January 2020 at 08:39:19 UTC, Robert M. Münch wrote: On 2020-01-05 04:18:34 +, H. S. Teoh said: At a minimum, I think we should file a bug report to investigate whether Grapheme.opSlice can be implemented differently, such that we avoid this obscure referential behaviour that

Re: @safe std.file.read

2020-01-06 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Monday, 6 January 2020 at 10:07:37 UTC, WebFreak001 wrote: I was wondering, how are you supposed to use std.file : read in @safe code when it returns a void[] but you want to get all bytes in the file? Is void[] really the correct type it should be returning instead of ubyte[] when it

Re: @safe std.file.read

2020-01-06 Thread Dennis via Digitalmars-d-learn
I would say it should return a ubyte[]. On Monday, 6 January 2020 at 10:07:37 UTC, WebFreak001 wrote: Or should void[] actually be castable to ubyte[] in @safe code? Definitely not with the current semantics, since a void[] can alias pointers in @safe code. See:

linkererrors when reducion phobos with dustmite

2020-01-06 Thread berni44 via Digitalmars-d-learn
As mentioned on the dustmite website [1] I copied the folder std from Phobos in a separate folder and renamed it to mystd. The I changed all occurences of std by mystd in all files. That works most of the time, but sometimes I get hundreds of linker errors I do not understand: $> dmd -main

@safe std.file.read

2020-01-06 Thread WebFreak001 via Digitalmars-d-learn
I was wondering, how are you supposed to use std.file : read in @safe code when it returns a void[] but you want to get all bytes in the file? Is void[] really the correct type it should be returning instead of ubyte[] when it just reads a (binary) file to memory? Or should void[] actually

Re: What type does byGrapheme() return?

2020-01-06 Thread Robert M. Münch via Digitalmars-d-learn
On 2020-01-05 04:18:34 +, H. S. Teoh said: At a minimum, I think we should file a bug report to investigate whether Grapheme.opSlice can be implemented differently, such that we avoid this obscure referential behaviour that makes it hard to work with in complex code. I'm not sure if this is