Re: Best way in D2 to rotate a ubyte[4] array

2011-03-10 Thread spir
On 03/10/2011 11:01 PM, bearophile wrote: While creating the rotation code I have found two things I don't understand. Maybe some of you is able to help me understand. This version of the code: union Four { uint u; ubyte[4] a; } void main() { Four f; asm { rol f.u

Re: Best way in D2 to rotate a ubyte[4] array

2011-03-10 Thread bearophile
While creating the rotation code I have found two things I don't understand. Maybe some of you is able to help me understand. This version of the code: union Four { uint u; ubyte[4] a; } void main() { Four f; asm { rol f.u, 8; } } DMD 2.052 gives this error, do you

Re: enum with classes/structs

2011-03-10 Thread Jonathan M Davis
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 constants. > This code doesn't compile: > > class A { >this(uint i)

Re: enum with classes/structs

2011-03-10 Thread Andrej Mitrovic
*I mean construction via field-by-field assignment. (I made the same typo in the bug report, lol).

Re: enum with classes/structs

2011-03-10 Thread Andrej Mitrovic
There's also this bug where the constructor for a struct isn't called: http://d.puremagic.com/issues/show_bug.cgi?id=5460 , and field assignment is not disabled even with the presence of a constructor.

Re: enum with classes/structs

2011-03-10 Thread bearophile
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 constants. This code doesn't compile: class A { this(uint i) {} } enum myEnum : A { entry1 = new A(0), entry2 = new A(1) } void

Re: enum with classes/structs

2011-03-10 Thread Jonathan M Davis
On Thursday, March 10, 2011 11:15:25 useo wrote: > Hey guys, > > is it possible to declare a enum where all entries are instances of a > class (or struct), like the following: > > class a { >... >public this(uint i) { > ... >} >... > } > > enum myEnum : a { >entry1 = new

Re: enum with classes/structs

2011-03-10 Thread Trass3r
... or does enumerations only support constant-expressions? Thanks! Yep, enum is a compile-time thing.

Re: enum with classes/structs

2011-03-10 Thread Simen kjaeraas
useo wrote: Hey guys, is it possible to declare a enum where all entries are instances of a class (or struct), like the following: class a { ... public this(uint i) { ... } ... } enum myEnum : a { entry1 = new a(0); entry2 = new a(1); } ... or does enumerations only s

enum with classes/structs

2011-03-10 Thread useo
Hey guys, is it possible to declare a enum where all entries are instances of a class (or struct), like the following: class a { ... public this(uint i) { ... } ... } enum myEnum : a { entry1 = new a(0); entry2 = new a(1); } ... or does enumerations only support constant-

Re: I seem to be able to crash writefln

2011-03-10 Thread bearophile
Ary Manzana: > It works because it's a specialized syntax for foreach. Oh, and I think > in case statements you can use it too, but I don't remember if the first > was inclusive and the second exclusive, or both, or what. But... it just > works for those cases. For the rest you have to use iota

Re: I seem to be able to crash writefln

2011-03-10 Thread Ary Manzana
On 3/10/11 4:40 AM, Andrew Wiley wrote: On Thu, Mar 10, 2011 at 1:31 AM, Jonathan M Davis wrote: On Wednesday 09 March 2011 23:15:13 Andrew Wiley wrote: On Wed, Mar 9, 2011 at 5:19 PM, Joel Christensen wrote: This is on Windows 7. Using a def file to stop the terminal window coming up. win.

Re: I seem to be able to crash writefln

2011-03-10 Thread Ary Manzana
On 3/10/11 4:15 AM, Andrew Wiley wrote: On Wed, Mar 9, 2011 at 5:19 PM, 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 = File( "

Re: Iterating over 0..T.max

2011-03-10 Thread bearophile
Steven Schveighoffer: > void main() > { > auto a = new ubyte[256]; > foreach(ubyte i, ref e; a) e = i; > } http://d.puremagic.com/issues/show_bug.cgi?id=5725 Bye, bearophile

Re: Iterating over 0..T.max

2011-03-10 Thread Steven Schveighoffer
On Thu, 10 Mar 2011 07:50:21 -0500, bearophile wrote: Magnus Lie Hetland: Derp. I didn't mean bool -- I was talking about byte. (Which should make quite a bit more sense, given that I'm talking about a limit of 256... :D) Please show a complete minimal program that gives you problem. (I h

Re: Iterating over 0..T.max

2011-03-10 Thread bearophile
Magnus Lie Hetland: > Derp. I didn't mean bool -- I was talking about byte. (Which should > make quite a bit more sense, given that I'm talking about a limit of > 256... :D) Please show a complete minimal program that gives you problem. (I have failed to reproduce your problem on Windows). By

Re: Iterating over 0..T.max

2011-03-10 Thread Magnus Lie Hetland
On 2011-03-09 21:24:57 +0100, Kai Meyer said: I don't see how that works in dmd2, and I don't have much experience with dmd1, so I'll admit that this may be different on dmd1. Derp. I didn't mean bool -- I was talking about byte. (Which should make quite a bit more sense, given that I'm talki

Re: I seem to be able to crash writefln

2011-03-10 Thread Steven Schveighoffer
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 = File( "z.txt", "w" ); scope( ex

Re: full ident name without mangle/demange?

2011-03-10 Thread Jacob Carlborg
On 2011-03-10 09:44, Nick Sabalausky wrote: "Tomek Sowiñski" wrote in message news:20110309225011.3e9e1d3b@Las-Miodowy... Nick Sabalausky napisa³: Is there a way to get the fully-qualified name of an identifier without doing "demange( mangledName!(foo) )"? Heh, looks like there isn't. It ma

Re: full ident name without mangle/demange?

2011-03-10 Thread Nick Sabalausky
"Tomek Sowiñski" wrote in message news:20110309225011.3e9e1d3b@Las-Miodowy... >Nick Sabalausky napisa³: > >> Is there a way to get the fully-qualified name of an identifier without >> doing "demange( mangledName!(foo) )"? > >Heh, looks like there isn't. It may be worth filing an enhancement reque

Re: Commenting out a print slows my code?

2011-03-10 Thread spir
On 03/10/2011 01:44 AM, Charles McAnany wrote: Hi, all. I'm in college, taking a freshman-level CS class. (I'm actually a senior chemist with free time.) Anyhoo, the warm-up assignment was Hardy Taxi problem, phrased like this: [Exposition removed.] 1729 is the smallest number such that for (a!=b