Jonathan M Davis Wrote:
> Okay, it seems that the way to read in a binary file is to use
> std.file.read()
> which reads in the file as a void[]. This immediately raises the question as
> to
> how to convert the void[] into something useful.
You may like the BinaryReader interface
http://msdn
On Tuesday, September 21, 2010 17:34:26 bearophile wrote:
> > Take a look at the rawWrite/rawRead methods of std.stdio.File.
>
> I have just tried those a little. Python file object doesn't have a eof()
> method. This D2 program shows that eof() is false even when the whole file
> has being read,
On Tuesday, September 21, 2010 16:41:57 bearophile wrote:
> Jonathan M Davis:
> > UTF-8 strings are easy because they're the same size as ubytes.
> > Casting to char[] for the portion of the data that you want as a string
> > seems to work just fine.
>
> D2 string are immutable(char)[] and not cha
> Take a look at the rawWrite/rawRead methods of std.stdio.File.
I have just tried those a little. Python file object doesn't have a eof()
method. This D2 program shows that eof() is false even when the whole file has
being read, is this correct?
import std.stdio: File;
void main() {
doubl
%u wrote:
== Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article
%u wrote:
> enum X { A=3, B=1, C }
>
> void main() {
> foreach(e;X)
> writefln(e.stringof," = ",e);
> }
> //X.A = 3
> //X.B = 1
> //X.C = 2
> or
> //X.B = 1
> //X.C = 2
> //X.A = 3
enum X { A=3, B=1, C }
voi
Jonathan M Davis:
> UTF-8 strings are easy because they're the same size as ubytes.
> Casting to char[] for the portion of the data that you want as a string
> seems to work just fine.
D2 string are immutable(char)[] and not char[].
Strings are UTF-8, while the raw bytes you read from a file may
== Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article
> %u wrote:
> > enum X { A=3, B=1, C }
> >
> > void main() {
> > foreach(e;X)
> > writefln(e.stringof," = ",e);
> > }
> > //X.A = 3
> > //X.B = 1
> > //X.C = 2
> > or
> > //X.B = 1
> > //X.C = 2
> > //X.A = 3
> enum X { A=
%u wrote:
enum X { A=3, B=1, C }
void main() {
foreach(e;X)
writefln(e.stringof," = ",e);
}
//X.A = 3
//X.B = 1
//X.C = 2
or
//X.B = 1
//X.C = 2
//X.A = 3
enum X { A=3, B=1, C }
void main( ) {
foreach( e; __traits(allMembers, X) ) {
writeln( "X.", e, " = ", mixin(
Okay, it seems that the way to read in a binary file is to use std.file.read()
which reads in the file as a void[]. This immediately raises the question as to
how to convert the void[] into something useful. It seems to me that casting
void[] to a ubyte[] is then the appropriate thing to do bec
enum X { A=3, B=1, C }
void main() {
foreach(e;X)
writefln(e.stringof," = ",e);
}
//X.A = 3
//X.B = 1
//X.C = 2
or
//X.B = 1
//X.C = 2
//X.A = 3
On Tue, 21 Sep 2010 16:22:22 -0400, bearophile
wrote:
You may add an enhancement request for Phobos in Bugzilla, asking
for named captured groups, but there are many things to implement and
only few people that implement things, so probably you will have to
wait a lot of time :-)
I guessed t
Juanjo Alvarez:
> In Python and C# you can define a regex like:
> "Blabla_(? \d{4}) _BLA
> And then if you match that against a string like:
> Blabla_1970_BLA
D2 Phobos is in beta stage still, and I think its regex don't support named
groups yet. So you need to use numbers to select the group y
Steven Schveighoffer wrote:
> On Tue, 21 Sep 2010 05:17:10 -0400, Lutger
> wrote:
>
>> I'm still a bit fuzzy on how to create immutable data and when said data
>> is safe
>> to share across threads.
>>
>> To begin with, there is .idup, string literals and constructors of
>> immutable
>> objects.
Simen kjaeraas wrote:
> Lutger wrote:
>
>> Aha, thanks. I have made a conceptual diagram to help understand this,
>> would you
>> care to take a look and confirm whether this is correct or not?
>>
>>
http://picasaweb.google.com/Lutger.blijdestijn/Illustration#5519337139518828386
>>
>> I hope it
Lutger wrote:
Aha, thanks. I have made a conceptual diagram to help understand this,
would you
care to take a look and confirm whether this is correct or not?
http://picasaweb.google.com/Lutger.blijdestijn/Illustration#5519337139518828386
I hope it explains itself, the edges reflect the typ
On Tue, 21 Sep 2010 05:17:10 -0400, Lutger
wrote:
I'm still a bit fuzzy on how to create immutable data and when said data
is safe
to share across threads.
To begin with, there is .idup, string literals and constructors of
immutable
objects. Those can be safely shared, no problem, right
On Mon, 20 Sep 2010 16:26:44 -0400, Don wrote:
Steven Schveighoffer wrote:
I think it's ok for a function to be pure if all the arguments are
unshared, regardless of immutability. However, in order to cache the
return value, the reference itself must not be used as the key, but the
enti
In Python and C# you can define a regex like:
"Blabla_(? \d{4}) _BLA
And then if you match that against a string like:
Blabla_1970_BLA
you can get a hash with "year" as key and 1970 as value. Can this be
done with D regex module? Trying it throws a RegExpException with the
message "*+? not
21.09.2010 11:29, Bob Cowdery wrote:
if I say something like:
float[] xfer = new float[512];
xfer = buffer[0 .. $/2];
tid.send(xfer);
Try this
auto xfer = buffer[0..$/2].idup;
tid.send(xfer);
Simen kjaeraas wrote:
> Lutger wrote:
>
>> char[] s = ...;
>> immutable(char)[] p = cast(immutable)s.dup; // ok, unique reference
>>
>> I do not understand how that works with sharing. Since immutable data is
>> implicitly shared but the data that p refers to is allocated on the TLS,
>> how can
Lutger wrote:
char[] s = ...;
immutable(char)[] p = cast(immutable)s.dup; // ok, unique reference
I do not understand how that works with sharing. Since immutable data is
implicitly shared but the data that p refers to is allocated on the TLS,
how can
you share this? I always thought that th
I'm still a bit fuzzy on how to create immutable data and when said data is
safe
to share across threads.
To begin with, there is .idup, string literals and constructors of immutable
objects. Those can be safely shared, no problem, right?
But then, the spec mentions casting to immutable is ok
Bob Cowdery wrote:
Ok, so assumeUnique when I read it a bit more will still share data but
idup will copy data. Where are the docs for that. Something else not in
the book - but then I guess there is a lot of detail not in the book.
Thank goodness for forums.
The thing is, slices (as you did
Ok, so assumeUnique when I read it a bit more will still share data but
idup will copy data. Where are the docs for that. Something else not in
the book - but then I guess there is a lot of detail not in the book.
Thank goodness for forums.
bob
On 21/09/2010 09:10, Pelle wrote:
> On 09/21/2010 0
On 09/21/2010 09:29 AM, Bob Cowdery wrote:
Hi
I'm stuggling with immutable.
I have a fixed size buffer which is used as a circular buffer of floats
and is effectively double buffering data I wish to transfer to another
thread. At an appropriate point I take the top half or bottom half of
the
Bob Cowdery wrote:
Thanks, that at least builds now. I didn't see that trick in the book
but I've found it on the on-line library ref under std.exception. I
can't say I understand why its under std.exception.
I know. It used to be std.contracts, which makes a bit more sense. Then,
someone de
Thanks, that at least builds now. I didn't see that trick in the book
but I've found it on the on-line library ref under std.exception. I
can't say I understand why its under std.exception.
bob
On 21/09/2010 08:48, Simen kjaeraas wrote:
> Bob Cowdery wrote:
>
>> if I say something like:
>> flo
Bob Cowdery wrote:
if I say something like:
float[] xfer = new float[512];
xfer = buffer[0 .. $/2];
tid.send(xfer);
it rightly tells me 'thread local data not allowed'. If I make it:
immutable (float)[] xfer;
xfer = buffer[0 .. $/2];
tid.send(xfer);
it tells me 'can't implicitly convert floa
Hi
I'm stuggling with immutable.
I have a fixed size buffer which is used as a circular buffer of floats
and is effectively double buffering data I wish to transfer to another
thread. At an appropriate point I take the top half or bottom half of
the buffer and send it to another thread.
To do t
29 matches
Mail list logo