Re: Assigning Interface to Object

2011-01-21 Thread Trass3r
Speaking of COM.. has anyone successfully used COM interfaces in D2? I once tried to create a DDraw proxy dll but I can't remember how good it worked. https://bitbucket.org/trass3r/ddrawproxy

Why we need scope(success) if I can write at the end?

2011-01-21 Thread tamir
or what's the differents between theese two: void transactionalCreate(string filename) { string tempFilename = filename - .fragment; scope(success) { std.file.rename(tempFilename, filename); } auto f = File(tempFilename, w); } and: void transactionalCreate(string filename) { string

Type-qualified functions?

2011-01-21 Thread Sean Eskapp
How does one avoid code duplication in a snippet code like this: class A{} void foo(const A, void delegate(const A) fn) { // some stuff // ... // ... } void foo(A, void delegate(A) fn) { // exact same stuff, with different qualifiers // ... // ...

Re: sort and shared

2011-01-21 Thread Steven Schveighoffer
On Thu, 20 Jan 2011 21:14:06 -0500, Adam Conner-Sax adam_conner_...@yahoo.com wrote: The following code: import std.algorithm; class Foo { private: int id_; public: shared int id() const { return id_; } } static bool compare(in shared(Foo) a, in shared(Foo) b) { return (a.id()

Re: Why we need scope(success) if I can write at the end?

2011-01-21 Thread spir
On 01/21/2011 02:18 PM, tamir wrote: or what's the differents between theese two: void transactionalCreate(string filename) { string tempFilename = filename - .fragment; scope(success) { std.file.rename(tempFilename, filename); } auto f = File(tempFilename, w); } and: void

Re: sort and shared

2011-01-21 Thread Adam Conner-Sax
Thanks! I tried to apply that patch and rebuild phobos (I changed the file, remade libphobos2.a, put it in /usr/local/lib). That worked but I still get my error. I might have done the applying or rebuilding wrong though, especially since once I did that, even with the casting away of shared, I

Re: sort and shared

2011-01-21 Thread Steven Schveighoffer
On Fri, 21 Jan 2011 10:04:56 -0500, Adam Conner-Sax adam_conner_...@yahoo.com wrote: Thanks! I tried to apply that patch and rebuild phobos (I changed the file, remade libphobos2.a, put it in /usr/local/lib). That worked but I still get my error. I might have done the applying or

Re: Why we need scope(success) if I can write at the end?

2011-01-21 Thread Steven Schveighoffer
On Fri, 21 Jan 2011 08:18:15 -0500, tamir tamir@gmail.com wrote: or what's the differents between theese two: void transactionalCreate(string filename) { string tempFilename = filename - .fragment; scope(success) { std.file.rename(tempFilename, filename); } auto f =

Re: sort and shared

2011-01-21 Thread Steven Schveighoffer
On Fri, 21 Jan 2011 10:09:18 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: On Fri, 21 Jan 2011 10:04:56 -0500, Adam Conner-Sax adam_conner_...@yahoo.com wrote: Thanks! I tried to apply that patch and rebuild phobos (I changed the file, remade libphobos2.a, put it in

Re: Type-qualified functions?

2011-01-21 Thread Steven Schveighoffer
On Fri, 21 Jan 2011 09:08:58 -0500, Sean Eskapp eatingstap...@gmail.com wrote: How does one avoid code duplication in a snippet code like this: class A{} void foo(const A, void delegate(const A) fn) { // some stuff // ... // ... } void foo(A, void delegate(A) fn) {

Re: Source code annotations alla Java

2011-01-21 Thread Ary Manzana
On 1/20/11 5:48 PM, Jacob Carlborg wrote: On 2011-01-20 21:34, Steven Schveighoffer wrote: On Thu, 20 Jan 2011 15:03:55 -0500, Jacob Carlborg d...@me.com wrote: On 2011-01-20 19:18, Steven Schveighoffer wrote: On Thu, 20 Jan 2011 13:07:58 -0500, Jacob Carlborg d...@me.com wrote: On

Re: Type-qualified functions?

2011-01-21 Thread Sean Eskapp
templates: void foo(T)(T, void delegate(T) fn) { } This parameterizes foo based on T, which could be A, const A, or int, or whatever works to compile the function. What if the parameters are more general, for instance the first parameter is always a Foo, the second is a delegate which

Re: Source code annotations alla Java

2011-01-21 Thread Jonathan M Davis
On Friday, January 21, 2011 12:36:23 Ary Manzana wrote: On 1/20/11 5:48 PM, Jacob Carlborg wrote: On 2011-01-20 21:34, Steven Schveighoffer wrote: On Thu, 20 Jan 2011 15:03:55 -0500, Jacob Carlborg d...@me.com wrote: On 2011-01-20 19:18, Steven Schveighoffer wrote: On Thu, 20 Jan 2011

Re: Why we need scope(success) if I can write at the end?

2011-01-21 Thread Jonathan M Davis
On Friday, January 21, 2011 05:18:15 tamir wrote: or what's the differents between theese two: void transactionalCreate(string filename) { string tempFilename = filename - .fragment; scope(success) { std.file.rename(tempFilename, filename); } auto f = File(tempFilename, w); }

toString why not const

2011-01-21 Thread Tom
Hi, I'm trying to override Object's toString. I've noted it isn't a const method, namely: string toString() const; This cause me troubles when using it on a const reference. Shouldn't it be const? Thanks, Tom;

Re: Type-qualified functions?

2011-01-21 Thread Jesse Phillips
Sean Eskapp Wrote: templates: void foo(T)(T, void delegate(T) fn) { } This parameterizes foo based on T, which could be A, const A, or int, or whatever works to compile the function. What if the parameters are more general, for instance the first parameter is always a Foo,

Re: toString why not const

2011-01-21 Thread Jesse Phillips
Tom Wrote: Hi, I'm trying to override Object's toString. I've noted it isn't a const method, namely: string toString() const; This cause me troubles when using it on a const reference. Shouldn't it be const? Thanks, Tom; Phobos hasn't become very const aware. There have been bugs

Re: Why we need scope(success) if I can write at the end?

2011-01-21 Thread Andrej Mitrovic
When there are multiple calls that can fail, and where I have to do clean-up code in a certain order and under certain conditions I use scope(exit). For example: import std.stdio; import std.exception; void main() { foo(); } enum NoError = true; bool Initialize() { return true; } bool

Re: toString why not const

2011-01-21 Thread Jonathan M Davis
On Friday, January 21, 2011 13:02:56 Tom wrote: Hi, I'm trying to override Object's toString. I've noted it isn't a const method, namely: string toString() const; This cause me troubles when using it on a const reference. Shouldn't it be const? Thanks, Tom; It's a long-standing

Re: Why we need scope(success) if I can write at the end?

2011-01-21 Thread Jonathan M Davis
On Friday, January 21, 2011 14:49:44 Andrej Mitrovic wrote: When there are multiple calls that can fail, and where I have to do clean-up code in a certain order and under certain conditions I use scope(exit). For example: import std.stdio; import std.exception; void main() { foo();

Re: Can/should spawn work with functions that return?

2011-01-21 Thread Jonathan M Davis
On Friday, January 21, 2011 14:12:18 Andrej Mitrovic wrote: import std.stdio; import std.concurrency; void foo(int var) { } bool bar(int var) { return true; } void barWrapper(int var) { bar(var); } void main() { spawn(foo, 1); spawn(barWrapper, 1);

Re: toString why not const

2011-01-21 Thread bearophile
Jesse Phillips: So I do believe it should be const, but between the other priorities, and possible signature change for toString, it isn't done yet. There also the idea of introducing the writeTo() standard method, that's neat :-) Bye, bearophile

Re: Can/should spawn work with functions that return?

2011-01-21 Thread Andrej Mitrovic
Sorry, I should be careful with the word side-effects. What I meant was the newly spawned thread does its own job that the main thread doesn't care much about. It doesn't touch main's state or any shared variables. It does some work other than return a value. But the function I wanted the new

Re: Why we need scope(success) if I can write at the end?

2011-01-21 Thread spir
On 01/21/2011 09:56 PM, Jonathan M Davis wrote: On Friday, January 21, 2011 05:18:15 tamir wrote: or what's the differents between theese two: void transactionalCreate(string filename) { string tempFilename = filename - .fragment; scope(success) { std.file.rename(tempFilename,

const-typed class does not have const members

2011-01-21 Thread Sean Eskapp
The following code yields results as commented. import std.stdio; class A { int b; } void main() { const A a = new A; writeln(typeof(a).stringof); // const(A) writeln(typeof(a.b).stringof); // const(int) writeln((const A).stringof); // const(A)

Re: const-typed class does not have const members

2011-01-21 Thread Ali Çehreli
Sean Eskapp wrote: The following code yields results as commented. import std.stdio; class A { int b; } void main() { const A a = new A; writeln(typeof(a).stringof); // const(A) writeln(typeof(a.b).stringof); // const(int) writeln((const A).stringof); // const(A)

Re: Can/should spawn work with functions that return?

2011-01-21 Thread Jonathan M Davis
On Friday, January 21, 2011 15:23:37 Andrej Mitrovic wrote: Sorry, I should be careful with the word side-effects. What I meant was the newly spawned thread does its own job that the main thread doesn't care much about. It doesn't touch main's state or any shared variables. It does some work