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 vo
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
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 to
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 just
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: https://issues.dlang.org/show
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 be
On 4/18/14, monarch_dodra via Digitalmars-d-learn
wrote:
> Yeah... "static assert(void.sizeof == 1);" passes :/
Note that you can even have static void arrays. E.g.:
https://issues.dlang.org/show_bug.cgi?id=9691
I'm not sure whether this is an oversight (accepts-invalid) or
something else. But
On Friday, 18 April 2014 at 13:08:04 UTC, Steven Schveighoffer
wrote:
I admit, I didn't think C's void had a size ;) I'm pretty sure
it doesn't in D, but then again...
-Steve
Yeah... "static assert(void.sizeof == 1);" passes :/
So in any case, long story short:
"void[]": This is an un-typed
On Fri, 18 Apr 2014 02:04:16 -0400, monarch_dodra
wrote:
On Thursday, 17 April 2014 at 21:27:44 UTC, Steven Schveighoffer wrote:
On Thu, 17 Apr 2014 17:04:25 -0400, monarch_dodra
wrote:
void[] will only make sense once you've accepted that "void.sizeof ==
1".
It is already accepted tha
On Thursday, 17 April 2014 at 21:27:44 UTC, Steven Schveighoffer
wrote:
On Thu, 17 Apr 2014 17:04:25 -0400, monarch_dodra
wrote:
void[] will only make sense once you've accepted that
"void.sizeof == 1".
It is already accepted that when we talk about length in a
void[], it's the number of byt
On Thu, 17 Apr 2014 17:04:25 -0400, monarch_dodra
wrote:
On Thursday, 17 April 2014 at 12:59:20 UTC, Steven Schveighoffer wrote:
It was never possible. You must explicitly cast to void[].
void[] makes actually little sense as the result of whole-file read
that allocates. byte[] is at leas
On Thursday, 17 April 2014 at 12:59:20 UTC, Steven Schveighoffer
wrote:
It was never possible. You must explicitly cast to void[].
void[] makes actually little sense as the result of whole-file
read that allocates. byte[] is at least usable and more
accurate. In fact, it's a little dangerous t
Are you saying void[] *is* currently marked NOSCAN?
import std.stdio;
import core.memory;
writeln("int* []", GC.query(cast(void *) arr2).attr);
On Thursday, 17 April 2014 at 14:05:50 UTC, Regan Heath wrote:
On Thu, 17 Apr 2014 13:59:20 +0100, Steven Schveighoffer
wrote:
It was never possible. You must explicitly cast to void[].
to -> from?
void[] makes actually little sense as the result of whole-file
read that allocates. byte[] is
On Thu, 17 Apr 2014 10:05:49 -0400, Regan Heath
wrote:
On Thu, 17 Apr 2014 13:59:20 +0100, Steven Schveighoffer
wrote:
It was never possible. You must explicitly cast to void[].
to -> from?
Yes, sorry :)
void[] makes actually little sense as the result of whole-file read
that alloca
On Thu, 17 Apr 2014 13:59:20 +0100, Steven Schveighoffer
wrote:
It was never possible. You must explicitly cast to void[].
to -> from?
void[] makes actually little sense as the result of whole-file read that
allocates. byte[] is at least usable and more accurate. In fact, it's a
little d
On Thu, 17 Apr 2014 07:57:35 -0400, Regan Heath
wrote:
On Wed, 16 Apr 2014 14:36:20 +0100, Spacen Jasset
wrote:
Why does the read function return void[] and not byte[]
void[] read(in char[] name, size_t upTo = size_t.max);
One one hand the data is always /actually/ going to be a load
You can implicitly cast /to/ void[], but I don't think you could
ever implicitly cast from it.
Casting from it needs a bit more thought because you should
ensure that it actually is what you are saying it is and the
compiler can't help with that, so by prohibiting the automatic
cast it at lea
On Wed, 16 Apr 2014 14:36:20 +0100, Spacen Jasset
wrote:
Why does the read function return void[] and not byte[]
void[] read(in char[] name, size_t upTo = size_t.max);
One one hand the data is always /actually/ going to be a load of (u)bytes,
but /conceptually/ it might be structs or som
Why does the read function return void[] and not byte[]
void[] read(in char[] name, size_t upTo = size_t.max);
Dmitry Olshansky:
> Dang, DMD does not even type check the unitest code when the compiler
> option not passed.
This is a small known problem of D newsgroups. To partially cope with it at the
end of each module I add something like:
unittest { printf(__FILE__ ~ " unittest performed."); }
But am
On 02.08.2010 21:36, bearophile wrote:
Pelle:
Well, it magically converts to whatever array type you have. So this works:
ubyte[] data = read("trash.txt");
This code does not work for me on dmd 2.047.
AH, nor for me.
Bye,
bearophile
Hm... it doesn't ...
Ouch, I was very
Pelle:
> > Well, it magically converts to whatever array type you have. So this works:
> > ubyte[] data = read("trash.txt");
>
> This code does not work for me on dmd 2.047.
AH, nor for me.
Bye,
bearophile
On 08/02/2010 10:23 AM, Dmitry Olshansky wrote:
On 02.08.2010 5:23, bearophile wrote:
Can you tell me why std.file.read() returns a void[] instead of
something like a ubyte[]?
Well, it magically converts to whatever array type you have. So this works:
ubyte[] data = read("trash.txt"
Dmitry Olshansky:
> Well, it magically converts to whatever array type you have. So this works:
> ubyte[] data = read("trash.txt");
In more than tree years of nearly daily usage of D I have not even tried to
write that code :-)
Thank you,
bearophile
On 02.08.2010 5:23, bearophile wrote:
Can you tell me why std.file.read() returns a void[] instead of something like
a ubyte[]?
Well, it magically converts to whatever array type you have. So this
works:
ubyte[] data = read("trash.txt");
It's interesting fact de
Can you tell me why std.file.read() returns a void[] instead of something like
a ubyte[]?
(Performing a cast(ubyte[]) in SafeD can be a problem. I presume in SafeD I
have to use other safer functions to load binary data, like slurp() or
something similar.)
Bye,
bearophile
27 matches
Mail list logo