Re: alias c=mixin(expr); disallowed, why?

2013-06-22 Thread Timothee Cour
On Sat, Jun 22, 2013 at 2:55 PM, Timon Gehr wrote: > On 06/22/2013 11:51 PM, Timothee Cour wrote: > >> >> >> On Sat, Jun 22, 2013 at 2:47 PM, Timon Gehr > > wrote: >> >> On 06/22/2013 09:52 PM, Timothee Cour wrote: >> >> Is there a reason the language spec di

Re: alias c=mixin(expr); disallowed, why?

2013-06-22 Thread Timon Gehr
On 06/22/2013 11:51 PM, Timothee Cour wrote: On Sat, Jun 22, 2013 at 2:47 PM, Timon Gehr mailto:timon.g...@gmx.ch>> wrote: On 06/22/2013 09:52 PM, Timothee Cour wrote: Is there a reason the language spec disallows this? void main(){ auto a=mixin(

Re: Can call static method with null reference

2013-06-22 Thread Timon Gehr
On 06/22/2013 10:20 PM, Jacob Carlborg wrote: On 2013-06-22 19:11, monarch_dodra wrote: I don't see what's so terrible about it: If A can do it, I don't see what an instance of a couldn't? The problem is that you cannot overload on "static". That is, have a two methods with the same name, one

Re: alias c=mixin(expr); disallowed, why?

2013-06-22 Thread Timothee Cour
On Sat, Jun 22, 2013 at 2:47 PM, Timon Gehr wrote: > On 06/22/2013 09:52 PM, Timothee Cour wrote: > >> Is there a reason the language spec disallows this? >> >> >> void main(){ >> auto a=mixin("1");//OK >> alias b=a;//OK >> mixin("alias c=a;");//OK >> // alias c=mixin("a");//

Re: alias c=mixin(expr); disallowed, why?

2013-06-22 Thread Timon Gehr
On 06/22/2013 09:52 PM, Timothee Cour wrote: Is there a reason the language spec disallows this? void main(){ auto a=mixin("1");//OK alias b=a;//OK mixin("alias c=a;");//OK // alias c=mixin("a");//NG : Error: basic type expected, not mixin } No, it is arbitrary.

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-06-22 Thread bearophile
I asked Walter to warn d programmers against such mistakes, and Walter closed it down. Someone else has opened the ER again... I meant this: http://d.puremagic.com/issues/show_bug.cgi?id=5063 In the meantime I have fixed the Rosettacode entry. Bye, bearophile

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-06-22 Thread bearophile
Ali Çehreli: The code compiles under 32-bit (e.g. with the -m32 compiler switch) where size_t is an alias of uint. Oh, I see. I compile most of the code on a 32 bit system. I asked Walter to warn d programmers against such mistakes, and Walter closed it down. Someone else has opened the ER a

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-06-22 Thread Ali Çehreli
On 06/22/2013 11:53 AM, Brian Rogoff wrote: > The current D code for Dining philosophers does not compile with dmd > v2.063.2, the error message being > > dining.d(34): Error: cannot uniquely infer foreach argument types The code compiles under 32-bit (e.g. with the -m32 compiler switch) where

Re: Can call static method with null reference

2013-06-22 Thread Jacob Carlborg
On 2013-06-22 19:11, monarch_dodra wrote: I don't see what's so terrible about it: If A can do it, I don't see what an instance of a couldn't? The problem is that you cannot overload on "static". That is, have a two methods with the same name, one being declared "static". Usually it's possib

alias c=mixin(expr); disallowed, why?

2013-06-22 Thread Timothee Cour
Is there a reason the language spec disallows this? void main(){ auto a=mixin("1");//OK alias b=a;//OK mixin("alias c=a;");//OK // alias c=mixin("a");//NG : Error: basic type expected, not mixin }

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-06-22 Thread bearophile
Brian Rogoff: The current D code for Dining philosophers does not compile with dmd v2.063.2, the error message being dining.d(34): Error: cannot uniquely infer foreach argument types I try to keep the D entries on Rosettacode updated, but every dmd release breaks tons of code, and Rosettac

Problems building docs

2013-06-22 Thread Joseph Rushton Wakeling
Hello all, I'm having problems building the docs. I've got the latest d-programming-language.org checked out, and have tried to build with make -f posix.mak. The basic html part builds fine, but it falls over when trying to build phobos-prerelease with the error: make --directory=../phobos

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-06-22 Thread Brian Rogoff
On Saturday, 16 February 2013 at 11:30:00 UTC, Jos van Uden wrote: On 16-2-2013 8:58, qznc wrote: On Saturday, 16 February 2013 at 06:58:01 UTC, qznc wrote: On Saturday, 16 February 2013 at 02:23:42 UTC, Jos van Uden wrote: On 5-2-2013 20:45, Jos van Uden wrote: By the way, I think 'Qznc' may

Re: Multiple return type from object factory possible?

2013-06-22 Thread deed
auto o = getO("info3"); if (cast(Container)o != null) { ... } Thanks Simen. (Compiler requires !is instead of !=)

Re: Can call static method with null reference

2013-06-22 Thread monarch_dodra
On Saturday, 22 June 2013 at 16:44:36 UTC, H. S. Teoh wrote: On Sat, Jun 22, 2013 at 06:34:25PM +0200, Namespace wrote: >but that's a problem caused by the fact that static functions >can be >called via an instance, and fixing that would mean making it >illegal >to call static functions on inst

Re: Multiple return type from object factory possible?

2013-06-22 Thread Simen Kjaeraas
On Sat, 22 Jun 2013 18:58:22 +0200, deed wrote: class A { ... } class NonContainer : A { ... } class Container : A { A[] container; } class NC1 : NonContainer {} ... class C1 : Container {} ... A getO(string info) { switch (info) { default : retur

Multiple return type from object factory possible?

2013-06-22 Thread deed
class A { ... } class NonContainer : A { ... } class Container : A { A[] container; } class NC1 : NonContainer {} ... class C1 : Container {} ... A getO(string info) { switch (info) { default : return new NonContainer(); case "info1": return new

Re: Passing Appender by value

2013-06-22 Thread monarch_dodra
On Saturday, 22 June 2013 at 16:31:16 UTC, Namespace wrote: On Saturday, 22 June 2013 at 16:08:01 UTC, Andrej Mitrovic wrote: On 6/22/13, monarch_dodra wrote: I think you can work around the problem using "appender": auto buffer = appender!(int[])(); Yes, because it has a default argument wh

Re: Can call static method with null reference

2013-06-22 Thread H. S. Teoh
On Sat, Jun 22, 2013 at 06:34:25PM +0200, Namespace wrote: > >but that's a problem caused by the fact that static functions can be > >called via an instance, and fixing that would mean making it illegal > >to call static functions on instances (which I would love to have > >happen but don't expect

Re: Can call static method with null reference

2013-06-22 Thread Namespace
but that's a problem caused by the fact that static functions can be called via an instance, and fixing that would mean making it illegal to call static functions on instances (which I would love to have happen but don't expect to ever happen). - Jonathan M Davis What was the reason for this

Re: Passing Appender by value

2013-06-22 Thread Namespace
On Saturday, 22 June 2013 at 16:08:01 UTC, Andrej Mitrovic wrote: On 6/22/13, monarch_dodra wrote: I think you can work around the problem using "appender": auto buffer = appender!(int[])(); Yes, because it has a default argument which it passes to the Appender constructor. If only we had de

Re: Passing Appender by value

2013-06-22 Thread Andrej Mitrovic
On 6/22/13, monarch_dodra wrote: > I think you can work around the problem using "appender": > auto buffer = appender!(int[])(); Yes, because it has a default argument which it passes to the Appender constructor. If only we had default constructors for structs in D.. or a general solution to this

Re: Passing Appender by value

2013-06-22 Thread monarch_dodra
On Saturday, 22 June 2013 at 13:48:53 UTC, Andrej Mitrovic wrote: On 6/22/13, Andrej Mitrovic wrote: Appender!(int[]) buffer; call(buffer); writeln(buffer.data); // writes [], it's empty Apparently it's the same thing as the old AA problem. Essentially the buffer would have to

Re: Passing Appender by value

2013-06-22 Thread monarch_dodra
On Saturday, 22 June 2013 at 14:19:45 UTC, Diggory wrote: The problem occurs whenever the internal array is resized because what actually happens is that a new array is allocated and the contents copied over - the original Appender still references the original array (or in this case null). The

Re: Passing Appender by value

2013-06-22 Thread Diggory
On Saturday, 22 June 2013 at 13:48:53 UTC, Andrej Mitrovic wrote: On 6/22/13, Andrej Mitrovic wrote: Appender!(int[]) buffer; call(buffer); writeln(buffer.data); // writes [], it's empty Apparently it's the same thing as the old AA problem. Essentially the buffer would have to

Re: Passing Appender by value

2013-06-22 Thread Andrej Mitrovic
On 6/22/13, Andrej Mitrovic wrote: > Appender!(int[]) buffer; > call(buffer); > writeln(buffer.data); // writes [], it's empty Apparently it's the same thing as the old AA problem. Essentially the buffer would have to be initialized first by appending: - import std.array; import

Re: Passing Appender by value

2013-06-22 Thread Andrej Mitrovic
On 6/22/13, Andrej Mitrovic wrote: > I just learned today that passing Appender by value does not have the > semantics I thought it would: > > - > import std.array; > import std.stdio; > > void call(Appender!(int[]) buffer) > { > buffer.put(1); > } > > void main() > { > Appender!(int[]

Passing Appender by value

2013-06-22 Thread Andrej Mitrovic
I just learned today that passing Appender by value does not have the semantics I thought it would: - import std.array; import std.stdio; void call(Appender!(int[]) buffer) { buffer.put(1); } void main() { Appender!(int[]) buffer; writeln(buffer.data); // writes [], it's empty }

Re: limits for numeric types

2013-06-22 Thread Craig Dillabaugh
On Saturday, 22 June 2013 at 11:20:18 UTC, Craig Dillabaugh wrote: On Saturday, 22 June 2013 at 02:47:04 UTC, Jesse Phillips wrote: On Friday, 21 June 2013 at 19:30:28 UTC, Craig Dillabaugh wrote: Thank you very much. Now, is there any way to get Google to find my question/your answer if someon

Re: Is it possible to use global variables spanning modules?

2013-06-22 Thread Gary Willoughby
That works great thanks all.

Re: limits for numeric types

2013-06-22 Thread Craig Dillabaugh
On Saturday, 22 June 2013 at 02:47:04 UTC, Jesse Phillips wrote: On Friday, 21 June 2013 at 19:30:28 UTC, Craig Dillabaugh wrote: Thank you very much. Now, is there any way to get Google to find my question/your answer if someone searches for "dlang numeric limits"? Cheers, Craig Yes, get the

Re: Creating a growable binary heap or priority queue using Phobos?

2013-06-22 Thread qznc
On Saturday, 22 June 2013 at 07:48:25 UTC, qznc wrote: On Monday, 14 November 2011 at 06:15:18 UTC, SimonM wrote: On 2011/11/14 02:10 AM, bearophile wrote: SimonM: 2009, 27 April: http://www.digitalmars.com/d/archives/digitalmars/D/std.algorithm.BinaryHeap_88811.html See the working version

Re: Creating a growable binary heap or priority queue using Phobos?

2013-06-22 Thread qznc
On Monday, 14 November 2011 at 06:15:18 UTC, SimonM wrote: On 2011/11/14 02:10 AM, bearophile wrote: SimonM: 2009, 27 April: http://www.digitalmars.com/d/archives/digitalmars/D/std.algorithm.BinaryHeap_88811.html See the working version: http://rosettacode.org/wiki/Huffman_coding#D Bye, bea