Re: Flushing denormals to zero

2012-02-17 Thread Mantis
17.02.2012 4:30, bearophile пишет: After seeing this interesting thread: http://stackoverflow.com/questions/9314534/why-does-changing-0-1f-to-0-slow-down-performance-by-10x Do you know if there's a simple way to perform _MM_SET_FLUSH_ZERO_MODE in D? According to Agner that operation is not need

Re: Hex floats

2012-02-17 Thread Don Clugston
On 16/02/12 17:36, Timon Gehr wrote: On 02/16/2012 05:06 PM, Don Clugston wrote: On 16/02/12 13:28, Stewart Gordon wrote: On 16/02/2012 12:04, Don Clugston wrote: On 15/02/12 22:24, H. S. Teoh wrote: What's the original rationale for requiring that hex float literals must always have an expon

Re: Flushing denormals to zero

2012-02-17 Thread Don Clugston
On 17/02/12 09:09, Mantis wrote: 17.02.2012 4:30, bearophile пишет: After seeing this interesting thread: http://stackoverflow.com/questions/9314534/why-does-changing-0-1f-to-0-slow-down-performance-by-10x Do you know if there's a simple way to perform _MM_SET_FLUSH_ZERO_MODE in D? According

Removing items from an Array

2012-02-17 Thread Mars
Hello everybody. Once again I have a little question, this time about removing items from an assoc array in a foreach. Why does the following code: http://pastebin.com/65P9WDNS Result in this output: http://pastebin.com/4FzEE1zi It seems rather strange to me. I'd expect the foreach_reverse to

Re: Removing items from an Array

2012-02-17 Thread Jonathan M Davis
On Friday, February 17, 2012 11:00:36 Mars wrote: > Hello everybody. > Once again I have a little question, this time about removing > items from an assoc array in a foreach. > > Why does the following code: > http://pastebin.com/65P9WDNS > Result in this output: > http://pastebin.com/4FzEE1zi >

Re: Removing items from an Array

2012-02-17 Thread Mars
On Friday, 17 February 2012 at 10:13:00 UTC, Jonathan M Davis wrote: I don't believe that removing elements from an AA while iterating over it is safe. - Jonathan M Davis Well, no. But from my experience it's okay from bottom to top... at least in other languages. What would be the alternati

Re: Removing items from an Array

2012-02-17 Thread Andrej Mitrovic
foreach_reverse isn't going to help you much since AA's do not save the order of the keys. A quick workaround: http://pastebin.com/KkECqwUU Others probably know efficient ways to do this.

Re: Removing items from an Array

2012-02-17 Thread Andrea Fontana
Usually in other languages iterators are safe. Il giorno ven, 17/02/2012 alle 11.35 +0100, Mars ha scritto: > On Friday, 17 February 2012 at 10:13:00 UTC, Jonathan M Davis > wrote: > > I don't believe that removing elements from an AA while > > iterating over it is safe. > > > > - Jonathan M Da

Re: writeln(Range) fails on 2.058

2012-02-17 Thread simendsjo
On Wed, 15 Feb 2012 11:10:45 +0100, simendsjo wrote: On 02/15/2012 09:33 AM, simendsjo wrote: import std.array; import std.stdio; struct S { string txt; void popFront() { txt.popFront(); } @property dchar front() { return txt.front; } @property bool empty() { return txt.empty; } } void ma

Re: writeln(Range) fails on 2.058

2012-02-17 Thread simendsjo
On Fri, 17 Feb 2012 12:51:11 +0100, simendsjo wrote: On Wed, 15 Feb 2012 11:10:45 +0100, simendsjo wrote: On 02/15/2012 09:33 AM, simendsjo wrote: import std.array; import std.stdio; struct S { string txt; void popFront() { txt.popFront(); } @property dchar front() { return txt.front;

Let this() figure out T implicitly?

2012-02-17 Thread kraybourne
Hi! This doesn't work: import std.stdio; class Foo(T) { T t; this(T val) { t = val; } } void main() { auto o = new Foo(5); } __

Re: Let this() figure out T implicitly?

2012-02-17 Thread bearophile
kraybourne: > Then it compiles. Is it possible to have this() figure out the type some > way? Usually people write a small global function helper. > (Side note: What _does_ that error message mean? I don't get it.) I think the meaning is: when a class template is not yet instantiated, it's no

Re: Let this() figure out T implicitly?

2012-02-17 Thread Kevin Cox
The error message is saying that you are trying to use Foo as a type but Foo is not a type, it is a template for a type. On Feb 17, 2012 7:20 AM, "kraybourne" wrote: > Hi! > > This doesn't work: > >import std.stdio; >class Foo(T) >{ >T t; >t

Re: Let this() figure out T implicitly?

2012-02-17 Thread kraybourne
On 2/17/12 1:32 PM, bearophile wrote: kraybourne: Then it compiles. Is it possible to have this() figure out the type some way? Usually people write a small global function helper. Hm, so, something like this: Foo!(T) newFoo(T)(T val) { return new Foo!(T)(v

Re: Let this() figure out T implicitly?

2012-02-17 Thread kraybourne
On 2/17/12 1:51 PM, Kevin Cox wrote: The error message is saying that you are trying to use Foo as a type but Foo is not a type, it is a template for a type. Ah, so module.Foo is really not a class, but a template? I think I get it! Thanks! (Is then module.Foo(int).Foo the actual class type

Re: Let this() figure out T implicitly?

2012-02-17 Thread Kevin Cox
Yes. At least as the compiler would say. It's a little odd but I believe that is how the D Nam mangling works. I personally just think of Foo!(Class) as the type. On Feb 17, 2012 8:05 AM, "kraybourne" wrote: > On 2/17/12 1:51 PM, Kevin Cox wrote: > >> The error message is saying that you are t

Re: Removing items from an Array

2012-02-17 Thread James Miller
AAs don't keep the key order, so when you delete something out of it, what ever system iterates to the next pointer gets confused. Its generally a bad idea to modify an array as you loop through it. -- James Miller

Re: Let this() figure out T implicitly?

2012-02-17 Thread Timon Gehr
On 02/17/2012 02:07 PM, Kevin Cox wrote: Yes. At least as the compiler would say. It's a little odd but I believe that is how the D Nam mangling works. I personally just think of Foo!(Class) as the type. class Foo(T){ ... } Is syntactic sugar for template Foo(T){ class Foo{ ... } } T

Re: Hex floats

2012-02-17 Thread Timon Gehr
On 02/17/2012 10:45 AM, Don Clugston wrote: On 16/02/12 17:36, Timon Gehr wrote: On 02/16/2012 05:06 PM, Don Clugston wrote: On 16/02/12 13:28, Stewart Gordon wrote: On 16/02/2012 12:04, Don Clugston wrote: On 15/02/12 22:24, H. S. Teoh wrote: What's the original rationale for requiring that

Re: writeln(Range) fails on 2.058

2012-02-17 Thread Timon Gehr
On 02/17/2012 12:58 PM, simendsjo wrote: On Fri, 17 Feb 2012 12:51:11 +0100, simendsjo wrote: On Wed, 15 Feb 2012 11:10:45 +0100, simendsjo wrote: On 02/15/2012 09:33 AM, simendsjo wrote: import std.array; import std.stdio; struct S { string txt; void popFront() { txt.popFront(); } @pro

Re: Removing items from an Array

2012-02-17 Thread Mars
On Friday, 17 February 2012 at 13:33:25 UTC, James Miller wrote: AAs don't keep the key order, so when you delete something out of it, what ever system iterates to the next pointer gets confused. Its generally a bad idea to modify an array as you loop through it. -- James Miller Too bad. So,

Re: Let this() figure out T implicitly?

2012-02-17 Thread kraybourne
On 2/17/12 2:38 PM, Timon Gehr wrote: On 02/17/2012 02:07 PM, Kevin Cox wrote: Yes. At least as the compiler would say. It's a little odd but I believe that is how the D Nam mangling works. I personally just think of Foo!(Class) as the type. class Foo(T){ ... } Is syntactic sugar for templa

Re: writeln(Range) fails on 2.058

2012-02-17 Thread simendsjo
On Fri, 17 Feb 2012 14:44:15 +0100, Timon Gehr wrote: On 02/17/2012 12:58 PM, simendsjo wrote: On Fri, 17 Feb 2012 12:51:11 +0100, simendsjo wrote: On Wed, 15 Feb 2012 11:10:45 +0100, simendsjo wrote: On 02/15/2012 09:33 AM, simendsjo wrote: import std.array; import std.stdio; struct

Re: Instance-specific unittests

2012-02-17 Thread Steven Schveighoffer
On Mon, 13 Feb 2012 19:32:31 -0500, H. S. Teoh wrote: On Mon, Feb 13, 2012 at 07:15:18PM -0500, Steven Schveighoffer wrote: [...] 3. If you are making classes like this, make *sure* all your unit test helper functions are non-virtual! Otherwise, if some code instantiates with unit tests on

Re: Removing items from an Array

2012-02-17 Thread Jonathan M Davis
On Friday, February 17, 2012 14:44:42 Mars wrote: > On Friday, 17 February 2012 at 13:33:25 UTC, James Miller wrote: > > AAs don't keep the key order, so when you delete something out > > of it, > > what ever system iterates to the next pointer gets confused. Its > > generally a bad idea to modify

Re: Default Implementation For an Interface

2012-02-17 Thread Steven Schveighoffer
On Wed, 15 Feb 2012 22:01:51 -0500, Kevin wrote: I was implementing a framework and I found that I wanted two things. - A strong set of interfaces so that I can get what I want from a variety of sources. - Some basic implementations of these interfaces. For example, say I was writing a

Re: Let this() figure out T implicitly?

2012-02-17 Thread Steven Schveighoffer
On Fri, 17 Feb 2012 07:19:28 -0500, kraybourne wrote: Hi! This doesn't work: import std.stdio; class Foo(T) { T t; this(T val) { t = val; } } void main()

Re: Removing items from an Array

2012-02-17 Thread Steven Schveighoffer
On Fri, 17 Feb 2012 08:44:42 -0500, Mars <-@-.-> wrote: On Friday, 17 February 2012 at 13:33:25 UTC, James Miller wrote: AAs don't keep the key order, so when you delete something out of it, what ever system iterates to the next pointer gets confused. Its generally a bad idea to modify an array

Re: Default Implementation For an Interface

2012-02-17 Thread Jacob Carlborg
On 2012-02-17 18:04, Steven Schveighoffer wrote: On Wed, 15 Feb 2012 22:01:51 -0500, Kevin wrote: I was implementing a framework and I found that I wanted two things. - A strong set of interfaces so that I can get what I want from a variety of sources. - Some basic implementations of these int

Re: Hex floats

2012-02-17 Thread H. S. Teoh
On Fri, Feb 17, 2012 at 02:41:10PM +0100, Timon Gehr wrote: > On 02/17/2012 10:45 AM, Don Clugston wrote: > >On 16/02/12 17:36, Timon Gehr wrote: [...] > >>static assert(is(typeof(7i)==idouble)); > > > >Ooh, that's bad. > > > > Indeed. But the implementation of complex and imaginary numbers is > p

Re: Default Implementation For an Interface

2012-02-17 Thread Kevin Cox
I wasn't looking to implement meathods in the interface, I was looking to have a default class that implements the interface that would be created if you called `new Interface();` I don't think this is possible. and now that I think about it I think that it is for a good reason. On Fri, Feb 17, 2

Re: Let this() figure out T implicitly?

2012-02-17 Thread Ali Çehreli
On 02/17/2012 09:08 AM, Steven Schveighoffer wrote: > What you are asking for is IFTI (Implicit Function Template > Instantiation) on constructors, and is perfectly possible, but not > implemented: > > http://d.puremagic.com/issues/show_bug.cgi?id=6082 What was the resolution for the case when t

Range question

2012-02-17 Thread H. S. Teoh
I'm trying to write a range-based template that iterates over a range and returns one of its elements according to some criterion: ElementType!R choose(R, E)(R range) if (isInputRange!R) { ElementType!R e; while (!range.empty) {

Re: Let this() figure out T implicitly?

2012-02-17 Thread Timon Gehr
On 02/18/2012 12:04 AM, Ali Çehreli wrote: On 02/17/2012 09:08 AM, Steven Schveighoffer wrote: > What you are asking for is IFTI (Implicit Function Template > Instantiation) on constructors, and is perfectly possible, but not > implemented: > > http://d.puremagic.com/issues/show_bug.cgi?id=

Re: More octal questions

2012-02-17 Thread Jonathan M Davis
On Thursday, February 16, 2012 00:38:10 Stewart Gordon wrote: > On 15/02/2012 16:41, Jonathan M Davis wrote: > > > > They're not left over at all, and they have nothing to do with octal. > > > > They are something to do with octal: because in D an integer literal > beginning with 0 is defined

Re: Let this() figure out T implicitly?

2012-02-17 Thread Ali Çehreli
On 02/17/2012 05:59 PM, Timon Gehr wrote: > On 02/18/2012 12:04 AM, Ali Çehreli wrote: >> On 02/17/2012 09:08 AM, Steven Schveighoffer wrote: >> >> > What you are asking for is IFTI (Implicit Function Template >> > Instantiation) on constructors, and is perfectly possible, but not >> > implemented

Re: Let this() figure out T implicitly?

2012-02-17 Thread Timon Gehr
On 02/18/2012 03:22 AM, Ali Çehreli wrote: On 02/17/2012 05:59 PM, Timon Gehr wrote: > On 02/18/2012 12:04 AM, Ali Çehreli wrote: >> On 02/17/2012 09:08 AM, Steven Schveighoffer wrote: >> >> > What you are asking for is IFTI (Implicit Function Template >> > Instantiation) on constructors, an

temp file

2012-02-17 Thread bioinfornatics
hi, when i try to use tmpfile from std.stdio i get this error > char 0x00ad not allowed in identifier I use dmdfe 2.058, i do just: File tmp = tmpfile();

Re: Range question

2012-02-17 Thread Mantis
18.02.2012 2:50, H. S. Teoh пишет: ... You cannot have ref local variable, so e is a copy in any case. It may be a class reference or a pointer, so calling potentially non-const methods is probably not safe here, but assignment shouldn't give you problems.

Re: Range question

2012-02-17 Thread H. S. Teoh
On Sat, Feb 18, 2012 at 05:19:52AM +0200, Mantis wrote: > 18.02.2012 2:50, H. S. Teoh пишет: > >... > You cannot have ref local variable, so e is a copy in any case. It > may be a class reference or a pointer, so calling potentially > non-const methods is probably not safe here, but assignment > sh

Re: Range question

2012-02-17 Thread Mantis
18.02.2012 7:51, H. S. Teoh пишет: On Sat, Feb 18, 2012 at 05:19:52AM +0200, Mantis wrote: 18.02.2012 2:50, H. S. Teoh пишет: ... You cannot have ref local variable, so e is a copy in any case. It may be a class reference or a pointer, so calling potentially non-const methods is probably not s

Re: Range question

2012-02-17 Thread H. S. Teoh
On Sat, Feb 18, 2012 at 08:02:15AM +0200, Mantis wrote: > 18.02.2012 7:51, H. S. Teoh пишет: > >On Sat, Feb 18, 2012 at 05:19:52AM +0200, Mantis wrote: > >>18.02.2012 2:50, H. S. Teoh пишет: > >>>... > >>You cannot have ref local variable, so e is a copy in any case. It > >>may be a class reference

Re: Range question

2012-02-17 Thread Jonathan M Davis
On Friday, February 17, 2012 22:27:06 H. S. Teoh wrote: > Hmm. But the problem is that I want to be able to handle something like > File.byLine(). Or perhaps what I really need is just to write a wrapper > around File.readln() that ensures immutability, then I can use > isImmutable() to enforce saf

Re: More octal questions

2012-02-17 Thread Daniel Murphy
"Jonathan M Davis" wrote in message news:mailman.508.1329531876.20196.digitalmars-d-le...@puremagic.com... > > They have nothing to do with octal in that they were not intentionally > octal. > I was merely using the leading 0 without thinking about it, because having > leading 0s generally makes