Re: Read file/stream

2011-03-11 Thread Jonathan M Davis
On Friday, March 11, 2011 14:39:43 Stewart Gordon wrote: > On 11/03/2011 21:51, Steven Schveighoffer wrote: > > > >> Presumably there's a reason that it's been provided for uint but not > >> ushort or ulong > > > > I think things in std.intrinsic are functions that tie directly to CPU > > fe

Re: I seem to be able to crash writefln

2011-03-11 Thread Spacen Jasset
On 10/03/2011 12:18, Steven Schveighoffer wrote: On Wed, 09 Mar 2011 18:19:55 -0500, Joel Christensen wrote: This is on Windows 7. Using a def file to stop the terminal window coming up. win.def EXETYPE NT SUBSYSTEM WINDOWS bug.d import std.stdio; import std.string; void main() { auto f = F

Re: Fibonacci with ranges

2011-03-11 Thread Jesse Phillips
Without testing: foreach (f; take(recurrence!("a[n-1] + a[n-2]")(0UL, 1UL), 50)) teo Wrote: > Just curious: How can I get ulong here? > > foreach (f; take(recurrence!("a[n-1] + a[n-2]")(0, 1), 50)) > { > writeln(f); > }

Fibonacci with ranges

2011-03-11 Thread teo
Just curious: How can I get ulong here? foreach (f; take(recurrence!("a[n-1] + a[n-2]")(0, 1), 50)) { writeln(f); } Results: 0 1 1 2 3 5 8 .. 1134903170 1836311903 -1323752223 512559680 -811192543

Re: Read file/stream

2011-03-11 Thread Stewart Gordon
On 11/03/2011 21:51, Steven Schveighoffer wrote: Presumably there's a reason that it's been provided for uint but not ushort or ulong I think things in std.intrinsic are functions that tie directly to CPU features, True, but... so presumably, the CPU only provides the possibility for

Re: Read file/stream

2011-03-11 Thread Steven Schveighoffer
On Fri, 11 Mar 2011 16:42:59 -0500, Stewart Gordon wrote: On 11/03/2011 19:50, Ali Çehreli wrote: There is also std.intrinsic.bswap Well spotted. I don't tend to look at std.intrinsic much. Presumably there's a reason that it's been provided for uint but not ushort or ulong I th

Re: Read file/stream

2011-03-11 Thread Stewart Gordon
On 11/03/2011 19:50, Ali Çehreli wrote: There is also std.intrinsic.bswap Well spotted. I don't tend to look at std.intrinsic much. Presumably there's a reason that it's been provided for uint but not ushort or ulong Stewart.

Re: Read file/stream

2011-03-11 Thread Ali Çehreli
On 03/11/2011 11:18 AM, Stewart Gordon wrote: On 11/03/2011 18:46, Steven Schveighoffer wrote: I am not sure what facilities Phobos provides for reading/writing integers in network order (i.e. Big Endian), but I'm sure there's something. http://www.digitalmars.com/d/1.0/phobos/std_stream.html

Re: Read file/stream

2011-03-11 Thread Stewart Gordon
On 11/03/2011 18:46, Steven Schveighoffer wrote: I am not sure what facilities Phobos provides for reading/writing integers in network order (i.e. Big Endian), but I'm sure there's something. http://www.digitalmars.com/d/1.0/phobos/std_stream.html EndianStream I haven't experimented with it.

Re: Mixins: to!string cannot be interpreted at compile time

2011-03-11 Thread Caligo
On Fri, Mar 11, 2011 at 11:48 AM, Caligo wrote: > > > On Tue, Mar 1, 2011 at 1:15 PM, Peter Lundgren > wrote: > >> That worked, thanks. This is interesting because the example used in "The >> D >> Programming Language" on page 83 gets away with it just fine. I had no >> problem >> running this:

Re: Read file/stream

2011-03-11 Thread Simen kjaeraas
nrgyzer wrote: I'm trying to read a png file and I'm having some trouble with the chunk-size. Each chunk of a png file begins with a 4 byte (unsigned) integer. When I read this 4 byte integer (uint) I get an absolutely incorrect length. My code currently looks like: void main(string args) {

Re: Read file/stream

2011-03-11 Thread Steven Schveighoffer
On Fri, 11 Mar 2011 13:43:19 -0500, nrgyzer wrote: I'm trying to read a png file and I'm having some trouble with the chunk-size. Each chunk of a png file begins with a 4 byte (unsigned) integer. When I read this 4 byte integer (uint) I get an absolutely incorrect length. My code currently look

Read file/stream

2011-03-11 Thread nrgyzer
I'm trying to read a png file and I'm having some trouble with the chunk-size. Each chunk of a png file begins with a 4 byte (unsigned) integer. When I read this 4 byte integer (uint) I get an absolutely incorrect length. My code currently looks like: void main(string args) { File f = new File

Re: Mixins: to!string cannot be interpreted at compile time

2011-03-11 Thread Caligo
On Tue, Mar 1, 2011 at 1:15 PM, Peter Lundgren wrote: > That worked, thanks. This is interesting because the example used in "The D > Programming Language" on page 83 gets away with it just fine. I had no > problem > running this: > > result ~= to!string(bitsSet(b)) ~ ", "; > How did you get tha

Re: Why is the struct instance being copied here?

2011-03-11 Thread Steven Schveighoffer
On Fri, 11 Mar 2011 04:50:38 -0500, d coder wrote: Greetings Please look at the code down here. When compiled and run, I get the message "Call to postblit" printed. I think it is because of the foreach block, because the variable "i" is not declared as ref there. Is there a way to make it a

Why is the struct instance being copied here?

2011-03-11 Thread d coder
Greetings Please look at the code down here. When compiled and run, I get the message "Call to postblit" printed. I think it is because of the foreach block, because the variable "i" is not declared as ref there. Is there a way to make it a ref? Regards - Puneet import std.stdio; struct Foo {

Re: enum with classes/structs

2011-03-11 Thread useo
== Auszug aus Jonathan M Davis (jmdavisp...@gmx.com)'s Artikel > On Thursday, March 10, 2011 11:28:04 bearophile wrote: > > useo: > > > is it possible to declare a enum where all entries are instances of a > > > > > class (or struct), like the following: > > I don't think so. Enums are compile-time