Re: Productions users

2012-06-30 Thread SomeDude
On Thursday, 28 June 2012 at 07:43:58 UTC, Jonathan M Davis wrote: On Thursday, June 28, 2012 09:29:14 Alex Rønne Petersen wrote: On 27-06-2012 23:31, Jonathan M Davis wrote: > On Wednesday, June 27, 2012 23:00:58 nazriel wrote: >> On Wednesday, 27 June 2012 at 08:53:14 UTC, Andrea Fontana >> w

Re: Two Scala annotations

2012-06-30 Thread SomeDude
On Sunday, 27 May 2012 at 14:04:48 UTC, Dmitry Olshansky wrote: IMHO if you use annotations for *this* then your language is as good as dead. There are far better things to aim annotations at. I couldn't say it better. @switch might have some utility in rare cases in a language with pattern

Re: Two Scala annotations

2012-06-30 Thread Jonathan M Davis
On Saturday, June 30, 2012 19:00:29 Walter Bright wrote: > On 6/30/2012 6:05 PM, bearophile wrote: > > Walter Bright: > >> It's not a bug. It's deliberate, and is there to support mechanical > >> translation of Java code. > > > > Is this stuff written somewhere in a D design rationales page? > >

Re: Two Scala annotations

2012-06-30 Thread Walter Bright
On 6/30/2012 6:05 PM, bearophile wrote: Walter Bright: It's not a bug. It's deliberate, and is there to support mechanical translation of Java code. Is this stuff written somewhere in a D design rationales page? Now that D is several years old, how much Java code was ported to D? (Despite th

Re: Two Scala annotations

2012-06-30 Thread bearophile
Walter Bright: It's not a bug. It's deliberate, and is there to support mechanical translation of Java code. Is this stuff written somewhere in a D design rationales page? Now that D is several years old, how much Java code was ported to D? (Despite there is no mechanical Java->D translator

Re: Two Scala annotations

2012-06-30 Thread Walter Bright
On 5/27/2012 6:13 AM, bearophile wrote: Currently this D2 code compiles: void main() { int x = 2; int y = 2; switch(x) { case 1: break; case y: break; default: } } I think that accepting that "case y" is a compiler bug, because y is a run-time valu

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Andrei Alexandrescu
On 6/30/12 11:15 AM, Monarch Dodra wrote: On Saturday, 30 June 2012 at 14:22:06 UTC, Andrei Alexandrescu wrote: 2) The new range is defined as a fixed length from the beginning of the range, as opposed to start and finish points. If I were to insert new items into my Slist, the new range would j

Re: std.string.format results in run-time exception

2012-06-30 Thread kenji hara
2012/7/1 d coder : > Thanks Kenji, I will use xformat. BTW, why is it named "x"format? Would not > "s"format be a better name? Where "s" could stand for string. eXtended format. > Also I feel, std.string.format should work for BitArray and BigInt too. Both > these types are defined as part of pho

Re: std.string.format results in run-time exception

2012-06-30 Thread d coder
Thanks Kenji, I will use xformat. BTW, why is it named "x"format? Would not "s"format be a better name? Where "s" could stand for string. Also I feel, std.string.format should work for BitArray and BigInt too. Both these types are defined as part of phobos. Regards - Puneet

Re: std.string.format results in run-time exception

2012-06-30 Thread kenji hara
std.string.format uses std.format.doFormat, and it is based on RTTI. On the other hand, writeln/writefln uses std.format.formattedWrite and formatValue, they are based on Compile Time Reflection. So the results are different. In 2.060head, std.string.xformat is added, and it works as like writefln

Re: std.string.format results in run-time exception

2012-06-30 Thread d coder
I have files a phobos bug report. http://d.puremagic.com/issues/show_bug.cgi?id=8326 Regards - Puneet

std.string.format results in run-time exception

2012-06-30 Thread d coder
Greetings std.string.format throws runtime exception for BigInt and for BitArray types even though writefln works fine. The run-time error says std.format.FormatException@std/format.d(4744): Can't convert std.bigint.BigInt to string: "string toString()" not defined Here is a small test case. Reg

Re: Productions users

2012-06-30 Thread Andrea Fontana
On wiki? Other projects have that list on homepage!! On Thursday, 28 June 2012 at 16:15:35 UTC, Graham Fawcett wrote: On Thursday, 28 June 2012 at 16:02:43 UTC, Jakob Bornecrantz wrote: On Thursday, 28 June 2012 at 07:38:19 UTC, Andrea Fontana wrote: In production it's just a way to say "comple

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Monarch Dodra
On Saturday, 30 June 2012 at 14:22:06 UTC, Andrei Alexandrescu wrote: 2) The new range is defined as a fixed length from the beginning of the range, as opposed to start and finish points. If I were to insert new items into my Slist, the new range would just bump the top items out of its range.

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Andrei Alexandrescu
On 6/30/12 9:15 AM, Dmitry Olshansky wrote: On 30-Jun-12 15:35, Tobias Pankrath wrote: Say I have a forward range (for example, an SList[]). I would like to create a new range containing only the first 5 elements of that old range. How can I do that? std.algorithm.take. But I would generally

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Andrei Alexandrescu
On 6/30/12 8:24 AM, monarch_dodra wrote: On Saturday, 30 June 2012 at 11:35:07 UTC, Tobias Pankrath wrote: std.algorithm.take. But I would generally avoid SList. Thanks, but isn't that kind of a crutch solution? I mean: 1) It creates a new type, so any attempt to use it to modify an existin

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Andrei Alexandrescu
On 6/30/12 7:31 AM, monarch_dodra wrote: I've been enjoying my time with D's ranges, but something is nagging at me: If the range is not random access, then how does one create a sub-view of that range? Use take or takeExactly. Say I have a forward range (for example, an SList[]). I would lik

Re: std.algorithm.splitter defect: isTerminator version does not return BiderectionalRand

2012-06-30 Thread monarch_dodra
On Saturday, 30 June 2012 at 14:01:08 UTC, Andrei Alexandrescu wrote: On 6/30/12 7:21 AM, monarch_dodra wrote: The "isTerminator" version of std.algorithm.splitter, eg: auto splitter(alias isTerminator, Range)(Range input) Returns an object that is "only" ForwardRange. This is especially weird

Re: std.algorithm.splitter defect: isTerminator version does not return BiderectionalRand

2012-06-30 Thread Andrei Alexandrescu
On 6/30/12 7:21 AM, monarch_dodra wrote: The "isTerminator" version of std.algorithm.splitter, eg: auto splitter(alias isTerminator, Range)(Range input) Returns an object that is "only" ForwardRange. This is especially weird, since the normal "separator" version is bidirectional. Comparing using

Case Variables (Re: Two Scala annotations)

2012-06-30 Thread Daniel Murphy
"bearophile" wrote in message news:dkpmzrcoppslcjqvd...@forum.dlang.org... > > Currently this D2 code compiles: > > void main() { > int x = 2; > int y = 2; > switch(x) { > case 1: break; > case y: break; > default: > } > } > > I think that accepting that "c

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Dmitry Olshansky
On 30-Jun-12 15:35, Tobias Pankrath wrote: Say I have a forward range (for example, an SList[]). I would like to create a new range containing only the first 5 elements of that old range. How can I do that? std.algorithm.take. But I would generally avoid SList. Indeed. I'd be hard pressed t

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread monarch_dodra
On Saturday, 30 June 2012 at 12:27:38 UTC, bearophile wrote: Tobias Pankrath: But I would generally avoid SList. It's not good. And in general linked lists are quite overrated. ... Bye, bearophile I appreciate the input, which I (mostly) agree with (I still love list's splice ability, whi

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread bearophile
Tobias Pankrath: But I would generally avoid SList. It's not good. And in general linked lists are quite overrated. On modern CPUs it's not easy to find situations where a linked list is better than a dynamic array or a chunked array (that is a dynamic array of pointers to arrays. It's oft

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread monarch_dodra
On Saturday, 30 June 2012 at 11:35:07 UTC, Tobias Pankrath wrote: std.algorithm.take. But I would generally avoid SList. Thanks, but isn't that kind of a crutch solution? I mean: 1) It creates a new type, so any attempt to use it to modify an existing range becomes impossible: void main()

Re: StructType.init and StructType() cause a allocation

2012-06-30 Thread Benjamin Thaut
Am 30.06.2012 13:52, schrieb bearophile: I don't know if that bug fix (in dmd 2.060alpha) has fixed your problem too. I have compiled this code from your issue 7271 with the latest beta: struct MemoryBlockInfo { size_t size; long[10] backtrace; int backtraceSize; this(siz

Re: StructType.init and StructType() cause a allocation

2012-06-30 Thread bearophile
Benjamin Thaut: I created a bug ticket for this 6 months ago, but it has been ignored so far: http://d.puremagic.com/issues/show_bug.cgi?id=7271 A similar bug was fixed very recently. D used to allocate a dynamic array of length 1 when you write "new T" where T is a struct. I don't know if

Re: StructType.init and StructType() cause a allocation

2012-06-30 Thread bearophile
I don't know if that bug fix (in dmd 2.060alpha) has fixed your problem too. I have compiled this code from your issue 7271 with the latest beta: struct MemoryBlockInfo { size_t size; long[10] backtrace; int backtraceSize; this(size_t size) { this.size = size; }

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Tobias Pankrath
Say I have a forward range (for example, an SList[]). I would like to create a new range containing only the first 5 elements of that old range. How can I do that? std.algorithm.take. But I would generally avoid SList.

Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread monarch_dodra
I've been enjoying my time with D's ranges, but something is nagging at me: If the range is not random access, then how does one create a sub-view of that range? Say I have a forward range (for example, an SList[]). I would like to create a new range containing only the first 5 elements of th

std.algorithm.splitter defect: isTerminator version does not return BiderectionalRand

2012-06-30 Thread monarch_dodra
The "isTerminator" version of std.algorithm.splitter, eg: auto splitter(alias isTerminator, Range)(Range input) Returns an object that is "only" ForwardRange. This is especially weird, since the normal "separator" version is bidirectional. Comparing using a function rather than with a value sho

Re: Inferred return types

2012-06-30 Thread Jacob Carlborg
On 2012-06-30 01:25, Martin Nowak wrote: class Foo { auto foo () { return "Foo"; } } class Bar : Foo { auto foo () { return "Bar"; } } Ouch, what a terrible idea to base a class hierachy on inference. But nonetheless covariance checking should be performed after inference. I actually found t

StructType.init and StructType() cause a allocation

2012-06-30 Thread Benjamin Thaut
If T is a struct both of the following statements will lead to a call of the _d_arrayliteral function which will allocate a array of the size of the struct just to initialize it!! void T[] data = ...; data[0] = T.init; data[0] = T(); This has proven to be the biggest performance bottleneck in