Cannot have properties on const references?

2011-09-24 Thread simendsjo
Sorry about the possible double post. I cannot see my previous.. struct S { @property int B() { return 1; } } void main() { S s1; auto a1 = s1.B; // ok const(S) s2; auto a2 = s2.B; // Error: function t.S.B () is not callable using argument types () }

How do formally you call the 'in' operator?

2011-09-24 Thread Andrej Mitrovic
Information about overloading opIn and opIn_r is missing from the docs, so I'm writing that section. But I don't know what is the formal name of this operator so I can put it in the title. Maybe I should just name the title "Overloading the In Operator"?

Re: Cannot have properties on const references?

2011-09-24 Thread Andrej Mitrovic
On 9/24/11, simendsjo wrote: > struct S { > @property int B() { > return 1; > } > } I've reported the error message just recently because it's very uninformative. But the solution is to add const to your property function: struct S { @property int B() const { ret

Re: How do formally you call the 'in' operator?

2011-09-24 Thread Andrej Mitrovic
Oh wait, I've just realized that opIn is actually the old way of using that operator. The new way is using opBinary and string matching instead. This is already described in the docs. I guess opIn and opIn_r are going away?

Structs, Classes, Templates

2011-09-24 Thread alex
I think I understand the concept of a template, the declaration of a class that you never actually have to create, right? But I am hazy on the difference between sructs and classes, and can't seem to get a clear understanding from the website. -- Alex Herrmann PC load letter

Re: Structs, Classes, Templates

2011-09-24 Thread Jacob Carlborg
On 2011-09-24 20:59, alex wrote: I think I understand the concept of a template, the declaration of a class that you never actually have to create, right? But I am hazy on the difference between sructs and classes, and can't seem to get a clear understanding from the website. Classes are alway

Re: Cannot have properties on const references?

2011-09-24 Thread Jonathan M Davis
On Saturday, September 24, 2011 20:19:43 Andrej Mitrovic wrote: > On 9/24/11, simendsjo wrote: > > struct S { > > > > @property int B() { > > > > return 1; > > > > } > > > > } > > I've reported the error message just recently because it's very > uninformative. But

Re: How do formally you call the 'in' operator?

2011-09-24 Thread Jonathan M Davis
On Saturday, September 24, 2011 20:37:45 Andrej Mitrovic wrote: > Oh wait, I've just realized that opIn is actually the old way of using > that operator. The new way is using opBinary and string matching > instead. This is already described in the docs. > > I guess opIn and opIn_r are going away?

class specialization for integral types

2011-09-24 Thread Charles Hixson
How would a specialize a parameterized class to only allow integral parameters (i.e., anything that would respond "true" to static if (is (T : long) ) (I'd have said "static if (is (T : cent) )" or "static if (is (T : ucent) )", but those are still marked "reserved for future use".) I do want

Re: class specialization for integral types

2011-09-24 Thread Jonathan M Davis
On Saturday, September 24, 2011 14:16:12 Charles Hixson wrote: > How would a specialize a parameterized class to only allow integral > parameters (i.e., anything that would respond "true" to > static if (is (T : long) ) > > (I'd have said "static if (is (T : cent) )" or "static if (is (T : > ucent

property aliases to existing functions

2011-09-24 Thread Andrej Mitrovic
I'm guessing the following is an accepts-invalid bug: void test(int) {} void main() { test = 4; } Anyway, if/when the above stops being legal I'd be nice if I could create property functions using aliases. Something like this: struct Bar { int getFoo() { return 0; } void setFoo(int i) {

Any way to expand a tuple?

2011-09-24 Thread Andrej Mitrovic
import std.typetuple; import std.typecons; struct Foo { void test(int x, double y) { } void opOpAssign(string op, T...)(T t) if (op == "~") { test(t); } } void main() { Foo foo; foo.opOpAssign!"~"(4, 5.0); // ok foo ~= tuple(4, 5.0); // fail } If I

Re: property aliases to existing functions

2011-09-24 Thread Jonathan M Davis
On Sunday, September 25, 2011 00:00:33 Andrej Mitrovic wrote: > I'm guessing the following is an accepts-invalid bug: > > void test(int) {} > void main() { test = 4; } > > Anyway, if/when the above stops being legal I'd be nice if I could > create property functions using aliases. Something like

Re: Any way to expand a tuple?

2011-09-24 Thread Jonathan M Davis
On Sunday, September 25, 2011 00:23:18 Andrej Mitrovic wrote: > import std.typetuple; > import std.typecons; > > struct Foo > { > void test(int x, double y) { } > > void opOpAssign(string op, T...)(T t) > if (op == "~") > { > test(t); > } > } > > void main() > { >

amd64 install dmd2.055

2011-09-24 Thread dsmith
Has anyone here succeeded with a dmd2.055 one-click install to Linux amd64? Unlike the prior dmd2.0xx, I have no luck with dmd2.055 for amd64 installs. I've tried Debian, Fedora, and Suse. After some command line work (based on http://www.d-programming-language.org/dmd- linux.html), it appeare

Re: class specialization for integral types

2011-09-24 Thread Charles Hixson
On 09/24/2011 02:33 PM, Jonathan M Davis wrote: On Saturday, September 24, 2011 14:16:12 Charles Hixson wrote: How would a specialize a parameterized class to only allow integral parameters (i.e., anything that would respond "true" to static if (is (T : long) ) (I'd have said "static if (is (T

Re: class specialization for integral types

2011-09-24 Thread Jonathan M Davis
On Saturday, September 24, 2011 16:14:48 Charles Hixson wrote: > On 09/24/2011 02:33 PM, Jonathan M Davis wrote: > > On Saturday, September 24, 2011 14:16:12 Charles Hixson wrote: > >> How would a specialize a parameterized class to only allow integral > >> parameters (i.e., anything that would res

Re: Multithreaded file IO?

2011-09-24 Thread Lutger Blijdestijn
If you didn't know, the concurrency chapter of tdpl is a free chapter: http://www.informit.com/articles/article.aspx?p=1609144 It has an example of file copying with message passing: http://www.informit.com/articles/article.aspx?p=1609144&seqNum=7

Re: How do formally you call the 'in' operator?

2011-09-24 Thread Ellery Newcomer
On 09/24/2011 01:18 PM, Andrej Mitrovic wrote: > Information about overloading opIn and opIn_r is missing from the > docs, so I'm writing that section. But I don't know what is the formal > name of this operator so I can put it in the title. Maybe I should > just name the title "Overloading the In

Re: class specialization for integral types

2011-09-24 Thread Charles Hixson
On 09/24/2011 04:31 PM, Jonathan M Davis wrote: On Saturday, September 24, 2011 16:14:48 Charles Hixson wrote: On 09/24/2011 02:33 PM, Jonathan M Davis wrote: On Saturday, September 24, 2011 14:16:12 Charles Hixson wrote: How would a specialize a parameterized class to only allow integral para

Re: class specialization for integral types

2011-09-24 Thread Charles Hixson
On 09/24/2011 04:31 PM, Jonathan M Davis wrote: On 09/24/2011 04:31 PM, Jonathan M Davis wrote: On Saturday, September 24, 2011 16:14:48 Charles Hixson wrote: On 09/24/2011 02:33 PM, Jonathan M Davis wrote: On Saturday, September 24, 2011 14:16:12 Charles Hixson wrote: How would a specialize a

Re: class specialization for integral types

2011-09-24 Thread Jonathan M Davis
On Saturday, September 24, 2011 17:30:36 Charles Hixson wrote: > OK, here's the problem: > s$ dmd -unittest test2.d > /usr/include/d/dmd/phobos/std/traits.d(2576): Error: template > std.traits.isNumeric(T) is not a function template > test2.d(8): Error: template std.traits.isNumeric(T) cannot deduc

Re: class specialization for integral types

2011-09-24 Thread Charles Hixson
I spoke too soon. class AA(Key, Data) if (isNumeric (Key) ) didn't work with a larger case, s$ dmd aa.d /usr/include/d/dmd/phobos/std/traits.d(2576): Error: template std.traits.isNumeric(T) is not a function template aa.d(200): Error: template std.traits.isNumeric(T) cannot deduce tem

Re: class specialization for integral types

2011-09-24 Thread Jonathan M Davis
On Saturday, September 24, 2011 17:41:52 Charles Hixson wrote: > I spoke too soon. > class AA(Key, Data) if (isNumeric (Key) ) > didn't work with a larger case, isNumeric!Key std.straits.isNumeric is an eponymous template, _not_ a function. I believe that everything in std.traits is an

Re: class specialization for integral types

2011-09-24 Thread Charles Hixson
On 09/24/2011 05:49 PM, Jonathan M Davis wrote: On Saturday, September 24, 2011 17:41:52 Charles Hixson wrote: I spoke too soon. class AA(Key, Data) if (isNumeric (Key) ) didn't work with a larger case, isNumeric!Key std.straits.isNumeric is an eponymous template, _not_ a function

How to check all values in a range are equal to some predicate?

2011-09-24 Thread Andrej Mitrovic
I want to use this in my unittests: assert(allEqual(Foo(1), obj1, obj2, obj3)); How would you implement a function like allEqual(needle, objects...) ? Maybe via reduce?

Re: How to check all values in a range are equal to some predicate?

2011-09-24 Thread Andrej Mitrovic
Argh, I've just realized this function would do me no good. I would get an error on the invocation line but I wouldn't know which of the objects have compared unequal. Maybe it's best to keep unittest code really simple.

Re: How to check all values in a range are equal to some predicate?

2011-09-24 Thread Jonathan M Davis
On Sunday, September 25, 2011 04:16:02 Andrej Mitrovic wrote: > Maybe it's best to keep unittest code really simple. That has always been my take on it. Sometimes, you're forced to make it more complicated, but if your unit tests are complicated, then there's a higher risk of bugs in them, which

Re: How to check all values in a range are equal to some predicate?

2011-09-24 Thread Andrej Mitrovic
On 9/25/11, Jonathan M Davis wrote: > On Sunday, September 25, 2011 04:16:02 Andrej Mitrovic wrote: >> Maybe it's best to keep unittest code really simple. > > That has always been my take on it. Sometimes, you're forced to make it more > complicated, but if your unit tests are complicated, then t

Re: How to check all values in a range are equal to some predicate?

2011-09-24 Thread Jonathan M Davis
On Sunday, September 25, 2011 04:48:56 Andrej Mitrovic wrote: > On 9/25/11, Jonathan M Davis wrote: > > On Sunday, September 25, 2011 04:16:02 Andrej Mitrovic wrote: > >> Maybe it's best to keep unittest code really simple. > > > > That has always been my take on it. Sometimes, you're forced to m

Re: How to check all values in a range are equal to some predicate?

2011-09-24 Thread Andrej Mitrovic
On 9/25/11, Jonathan M Davis wrote: > -cov Hehe, forgot about that. That should be perfect with a little script to filter things out.

Re: Any way to expand a tuple?

2011-09-24 Thread Daniel Murphy
"Andrej Mitrovic" wrote in message news:mailman.142.1316903007.26225.digitalmars-d-le...@puremagic.com... > > Is it possible to expand the phobos tuple in the call to test()? I can > use the isTuple template in a `static if` to figure out if it needs > expansion, so all that's left is to actually

Re: Multithreaded file IO?

2011-09-24 Thread Jerry Quinn
Jonathan M Davis Wrote: > On Saturday, September 24, 2011 01:05:52 Jerry Quinn wrote: > > Jonathan M Davis Wrote: > > > On Friday, September 23, 2011 23:01:17 Jerry Quinn wrote: > > > > > > A direct rewrite would involve using shared and synchronized (either on > > > the class or a synchronized b

Re: Multithreaded file IO?

2011-09-24 Thread Jerry Quinn
Lutger Blijdestijn Wrote: > If you didn't know, the concurrency chapter of tdpl is a free chapter: > http://www.informit.com/articles/article.aspx?p=1609144 > > It has an example of file copying with message passing: > http://www.informit.com/articles/article.aspx?p=1609144&seqNum=7 What I rea

Re: Multithreaded file IO?

2011-09-24 Thread Jonathan M Davis
On Sunday, September 25, 2011 02:26:18 Jerry Quinn wrote: > Jonathan M Davis Wrote: > > On Saturday, September 24, 2011 01:05:52 Jerry Quinn wrote: > > > Jonathan M Davis Wrote: > > > > On Friday, September 23, 2011 23:01:17 Jerry Quinn wrote: > > > > > > > > A direct rewrite would involve using s