Re: Formal Review of region allocator begins

2011-09-08 Thread Martin Nowak
So I have used RegionAllocator. First of all, thanks for getting things like these into the std library. I didn't even know segmented stacks before and they were the perfect solution to my use case. Since first reading about this I've used a TLS Appender which I cleared occasionally. Performa

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Steven Schveighoffer
On Thu, 08 Sep 2011 17:34:50 -0400, Timon Gehr wrote: On 09/08/2011 10:33 PM, Jonathan M Davis wrote: On Thursday, September 08, 2011 15:04:56 Andrei Alexandrescu wrote: On 9/8/11 2:02 PM, Jonathan M Davis wrote: I think that it makes perfect sense to use enums for flags. What I don't thin

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Timon Gehr
On 09/08/2011 10:33 PM, Jonathan M Davis wrote: On Thursday, September 08, 2011 15:04:56 Andrei Alexandrescu wrote: On 9/8/11 2:02 PM, Jonathan M Davis wrote: I think that it makes perfect sense to use enums for flags. What I don't think makes sense is making the type of the variable which hold

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Alix Pexton
On 08/09/2011 21:02, Andrei Alexandrescu wrote: On 9/8/11 1:28 PM, Marco Leise wrote: Am 08.09.2011, 18:52 Uhr, schrieb Simen Kjaeraas : On Thu, 08 Sep 2011 11:40:01 +0200, Sean Cavanaugh wrote: In the COM based land for D3D, there is just a number tacked onto the class name. We are up to v

Re: toString or not toString

2011-09-08 Thread Steven Schveighoffer
On Thu, 08 Sep 2011 16:19:28 -0400, Christophe wrote: "Steven Schveighoffer" , dans le message (digitalmars.D:144156), a écrit : Where could I see an implementation of a delegate suitable for readUntil ? In the source code for the revamped stdio. Here is a byChunk range which uses it:

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Jonathan M Davis
On Thursday, September 08, 2011 15:04:56 Andrei Alexandrescu wrote: > On 9/8/11 2:02 PM, Jonathan M Davis wrote: > > I think that it makes perfect sense to use enums for flags. What I don't > > think makes sense is making the type of the variable which holds the > > flags to be that enum type unles

Re: toString or not toString

2011-09-08 Thread Christophe
"Steven Schveighoffer" , dans le message (digitalmars.D:144156), a écrit : >> Where could I see an >> implementation of a delegate suitable for readUntil ? > > In the source code for the revamped stdio. Here is a byChunk range which > uses it: I see. Are you not concerned by the fact that wit

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Andrei Alexandrescu
On 9/8/11 2:02 PM, Jonathan M Davis wrote: I think that it makes perfect sense to use enums for flags. What I don't think makes sense is making the type of the variable which holds the flags to be that enum type unless _every_ possible combination of flags has its own flag so that &ing or |ing en

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Andrei Alexandrescu
On 9/8/11 1:28 PM, Marco Leise wrote: Am 08.09.2011, 18:52 Uhr, schrieb Simen Kjaeraas : On Thu, 08 Sep 2011 11:40:01 +0200, Sean Cavanaugh wrote: In the COM based land for D3D, there is just a number tacked onto the class name. We are up to version 11 (e.x. ID3D11Device). It works well and

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Steven Schveighoffer
On Thu, 08 Sep 2011 15:38:43 -0400, Jacob Carlborg wrote: On 2011-09-08 15:22, Steven Schveighoffer wrote: On Thu, 08 Sep 2011 09:16:40 -0400, Jacob Carlborg wrote: The Tango XML parser doesn't read from a file, it takes the input as a string. The parser isn't affected by I/O at all. So yo

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Jonathan M Davis
On Thursday, September 08, 2011 21:38:43 Jacob Carlborg wrote: > On 2011-09-08 15:22, Steven Schveighoffer wrote: > > On Thu, 08 Sep 2011 09:16:40 -0400, Jacob Carlborg wrote: > >> The Tango XML parser doesn't read from a file, it takes the input as a > >> string. The parser isn't affected by I/O

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Jacob Carlborg
On 2011-09-08 15:17, Steven Schveighoffer wrote: You can if you make it a template parameter. For example, my openFile function that I wrote does this (in fact, I needed a template mode string because the return type depends on it). The downside is you cannot pass a runtime-generated string. I ca

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Jacob Carlborg
On 2011-09-08 15:22, Steven Schveighoffer wrote: On Thu, 08 Sep 2011 09:16:40 -0400, Jacob Carlborg wrote: The Tango XML parser doesn't read from a file, it takes the input as a string. The parser isn't affected by I/O at all. So you have to read the entire file before sending it to the parse

Re: NIH syndrome and D

2011-09-08 Thread foobar
dsimcha Wrote: > == Quote from foobar (f...@bar.com)'s article > > Recent threads discuss how D should incorporate a mechanism to version > symbols/modules. > > E.g. std.xml[2], std.io vs. std.stdio and std.regex[p]. > > My question is WHY? > > D *already* employes Git and there is no point in rei

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Jonathan M Davis
On Thursday, September 08, 2011 07:13:48 Steven Schveighoffer wrote: > On Wed, 07 Sep 2011 03:30:17 -0400, Jacob Carlborg wrote: > > On 2011-09-06 19:39, Steven Schveighoffer wrote: > >> I like enums in terms of writing code that processes them, but in > >> terms > >> of calling functions with the

Re: NIH syndrome and D

2011-09-08 Thread foobar
Vladimir Panteleev Wrote: > On Thu, 08 Sep 2011 20:58:53 +0300, foobar wrote: > > > Recent threads discuss how D should incorporate a mechanism to version > > symbols/modules. > > E.g. std.xml[2], std.io vs. std.stdio and std.regex[p]. > > My question is WHY? > > > > D *already* employes Git a

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Andrei Alexandrescu
On 9/8/11 11:11 AM, Simen Kjaeraas wrote: On Thu, 08 Sep 2011 15:17:51 +0200, Steven Schveighoffer wrote: I wonder if there's a way to give the option of using a template parameter or using a positional parameter without having two different symbol names. hm... openFile!(string modedefault =

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Marco Leise
Am 08.09.2011, 18:52 Uhr, schrieb Simen Kjaeraas : On Thu, 08 Sep 2011 11:40:01 +0200, Sean Cavanaugh wrote: In the COM based land for D3D, there is just a number tacked onto the class name. We are up to version 11 (e.x. ID3D11Device). It works well and is definitely nicer once you are

Re: NIH syndrome and D

2011-09-08 Thread Vladimir Panteleev
On Thu, 08 Sep 2011 20:58:53 +0300, foobar wrote: Recent threads discuss how D should incorporate a mechanism to version symbols/modules. E.g. std.xml[2], std.io vs. std.stdio and std.regex[p]. My question is WHY? D *already* employes Git and there is no point in reimplementing it inside t

Re: NIH syndrome and D

2011-09-08 Thread dsimcha
== Quote from foobar (f...@bar.com)'s article > Recent threads discuss how D should incorporate a mechanism to version symbols/modules. > E.g. std.xml[2], std.io vs. std.stdio and std.regex[p]. > My question is WHY? > D *already* employes Git and there is no point in reimplementing it inside > the

NIH syndrome and D

2011-09-08 Thread foobar
Recent threads discuss how D should incorporate a mechanism to version symbols/modules. E.g. std.xml[2], std.io vs. std.stdio and std.regex[p]. My question is WHY? D *already* employes Git and there is no point in reimplementing it inside the D language/tools. I suggest this simple zero-implem

Re: More on const-related issue

2011-09-08 Thread bearophile
Timon Gehr: > What about > > void generate(this Foo[] self, int len) this{ // maybe there is a better > syntax > // init self > } > > ? > > This would just have the same restrictions as a class/struct constructor > that initializes immutable fields. At a first look I like this idea. Is

templates and functions

2011-09-08 Thread Daniel
Hi, I'm trying to reimplement something like this C++ code in D: template Class A { ... } template A some_function() { ... } While I can implement the class: class A(X) { ... } I fail with the function, due to the fact that I don't know/find the correct syntax for this. The version

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Simen Kjaeraas
On Thu, 08 Sep 2011 11:40:01 +0200, Sean Cavanaugh wrote: In the COM based land for D3D, there is just a number tacked onto the class name. We are up to version 11 (e.x. ID3D11Device). It works well and is definitely nicer once you are used to it, than calling everything New or Functio

Re: templates and functions

2011-09-08 Thread Simen Kjaeraas
On Thu, 08 Sep 2011 18:53:55 +0200, Daniel wrote: Hi, I'm trying to reimplement something like this C++ code in D: template Class A { ... } template A some_function() { ... } While I can implement the class: class A(X) { ... } I fail with the function, due to the fact that I do

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Simen Kjaeraas
On Thu, 08 Sep 2011 15:17:51 +0200, Steven Schveighoffer wrote: I wonder if there's a way to give the option of using a template parameter or using a positional parameter without having two different symbol names. hm... openFile!(string modedefault = "r")(string filename, string mode =

Re: string mixins shadowing names

2011-09-08 Thread Christian Kamm
Timon Gehr wrote: > I am strongly in favor of disallowing any cases where mixin declarations > shadow declarations that were used to compute mixin declarations in a > scope that allows forward references. > > > Any thoughts on this? Order-of-static-evaluation problems are not limited to mixins:

Re: More on const-related issue

2011-09-08 Thread Jason House
Timon Gehr Wrote: > On 09/08/2011 03:07 PM, Jason House wrote: > > bearophile Wrote: > > > >> With the latest DMD versions it's easy to create an immutable array of > >> structs, with a pure function (I think this gives advantages similar to > >> the Transients of the Clojure language): > >> > >

Template type deduction should introduce 'most common type'?

2011-09-08 Thread kenji hara
I'm working for fixing issue 6208 (http://d.puremagic.com/issues/show_bug.cgi?id=6208). I found a funny behavior in template function deduction. // from std.array.replaceSlice void replaceSlice(T)(T[] s, in T[] slice, in T[] replacement) {} // 1 //void replaceSlice(T)(T[] s, const(T[]) slice, con

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Steven Schveighoffer
On Thu, 08 Sep 2011 09:16:40 -0400, Jacob Carlborg wrote: On 2011-09-08 13:25, Steven Schveighoffer wrote: On Tue, 06 Sep 2011 17:59:44 -0400, Jonathan M Davis A new std.xml is already in the works. It'll be range-based, unlike the Tango parser. But there's no reason why Phobos shouldn't be a

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Timon Gehr
On 09/08/2011 03:05 PM, Jacob Carlborg wrote: On 2011-09-08 13:04, Steven Schveighoffer wrote: On Wed, 07 Sep 2011 03:27:43 -0400, Jacob Carlborg wrote: On 2011-09-06 19:39, Steven Schveighoffer wrote: I like enums in terms of writing code that processes them, but in terms of calling functi

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Jacob Carlborg
On 2011-09-08 13:25, Steven Schveighoffer wrote: On Tue, 06 Sep 2011 17:59:44 -0400, Jonathan M Davis A new std.xml is already in the works. It'll be range-based, unlike the Tango parser. But there's no reason why Phobos shouldn't be able to have a similarly-fast XML parser. As I understand it,

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Steven Schveighoffer
On Thu, 08 Sep 2011 09:05:35 -0400, Jacob Carlborg wrote: On 2011-09-08 13:04, Steven Schveighoffer wrote: On Wed, 07 Sep 2011 03:27:43 -0400, Jacob Carlborg wrote: On 2011-09-06 19:39, Steven Schveighoffer wrote: I like enums in terms of writing code that processes them, but in terms

Re: More on const-related issue

2011-09-08 Thread Timon Gehr
On 09/08/2011 03:07 PM, Jason House wrote: bearophile Wrote: With the latest DMD versions it's easy to create an immutable array of structs, with a pure function (I think this gives advantages similar to the Transients of the Clojure language): ... Two alternate ideas: 1. Reserve the requ

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Jacob Carlborg
On 2011-09-08 13:13, Steven Schveighoffer wrote: On Wed, 07 Sep 2011 03:30:17 -0400, Jacob Carlborg wrote: On 2011-09-06 19:39, Steven Schveighoffer wrote: I like enums in terms of writing code that processes them, but in terms of calling functions with them, I mean look at a sample fstream c

Re: More on const-related issue

2011-09-08 Thread Jason House
bearophile Wrote: > With the latest DMD versions it's easy to create an immutable array of > structs, with a pure function (I think this gives advantages similar to the > Transients of the Clojure language): > > > ... Two alternate ideas: 1. Reserve the required space then start appending 2.

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Jacob Carlborg
On 2011-09-08 13:04, Steven Schveighoffer wrote: On Wed, 07 Sep 2011 03:27:43 -0400, Jacob Carlborg wrote: On 2011-09-06 19:39, Steven Schveighoffer wrote: I like enums in terms of writing code that processes them, but in terms of calling functions with them, I mean look at a sample fstream

Re: More on const-related issue

2011-09-08 Thread Timon Gehr
On 09/08/2011 03:02 PM, Timon Gehr wrote: On 09/08/2011 11:56 AM, bearophile wrote: At the moment I don't have further ideas on this. Sorry, another solution I've used to solve that problem is to split the array arr of structs in two parallel arrays, one with just the mutable fields and one wi

Re: More on const-related issue

2011-09-08 Thread Timon Gehr
On 09/08/2011 11:56 AM, bearophile wrote: At the moment I don't have further ideas on this. Sorry, another solution I've used to solve that problem is to split the array arr of structs in two parallel arrays, one with just the mutable fields and one with just the immutable ones. But this incr

Re: Formal Review of region allocator begins

2011-09-08 Thread dsimcha
On 9/8/2011 2:56 AM, Christophe wrote: Here the word "instance" is used, but is not defined. The user may think that a new instance is created when a simple copy of the RegionAllocator is performed, which is perfectly true, but do not apply to what is meant in this documentation. If the user was

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Steven Schveighoffer
On Thu, 08 Sep 2011 08:20:46 -0400, Timon Gehr wrote: On 09/08/2011 01:13 PM, Steven Schveighoffer wrote: And in response to the discussion about enum flags not being & or | together, I emphatically think enums should be used for bitfields. Remember, enum is not just an enumeration, it's a m

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Timon Gehr
On 09/08/2011 01:13 PM, Steven Schveighoffer wrote: On Wed, 07 Sep 2011 03:30:17 -0400, Jacob Carlborg wrote: On 2011-09-06 19:39, Steven Schveighoffer wrote: I like enums in terms of writing code that processes them, but in terms of calling functions with them, I mean look at a sample fstrea

Re: toString or not toString

2011-09-08 Thread Steven Schveighoffer
On Tue, 06 Sep 2011 19:46:35 -0400, Christophe wrote: I've had a look at readUntil API, and it's not completely clear. Is the delegate supposed to remember what it has read and interpreted so far, or does it have to start from scratch each time ? The start is an index at which new data was

Re: Formal Review of region allocator begins

2011-09-08 Thread Alix Pexton
On 07/09/2011 14:05, Alix Pexton wrote: 12. alignBytes [939...] just has me stumped, the introduction says that 16 byte alignment is guaranteed, so shouldn't this always return 16? I tried to follow the breadcrumbs through the source, but couldn't find where the value it returns is defined, only

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Steven Schveighoffer
On Tue, 06 Sep 2011 17:59:44 -0400, Jonathan M Davis wrote: On Tuesday, September 06, 2011 23:51:48 Marco Leise wrote: Am 06.09.2011, 22:28 Uhr, schrieb Timon Gehr : > On 09/06/2011 09:36 PM, notna wrote: >> Sorry upfront, I didn't read this hole thread, so maybe I'm missing or >> mixing

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Steven Schveighoffer
On Tue, 06 Sep 2011 18:57:00 -0400, Jonathan M Davis wrote: On Tuesday, September 06, 2011 18:48:24 bearophile wrote: Paul D. Anderson: > I think this is a terrific suggestion. I have suggested std.io time ago, but someone doesn't like it: http://d.puremagic.com/issues/show_bug.cgi?id=4718

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Steven Schveighoffer
On Wed, 07 Sep 2011 03:30:17 -0400, Jacob Carlborg wrote: On 2011-09-06 19:39, Steven Schveighoffer wrote: I like enums in terms of writing code that processes them, but in terms of calling functions with them, I mean look at a sample fstream constructor in C++: fstream ifs("filename.txt", io

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Steven Schveighoffer
On Wed, 07 Sep 2011 03:27:43 -0400, Jacob Carlborg wrote: On 2011-09-06 19:39, Steven Schveighoffer wrote: I like enums in terms of writing code that processes them, but in terms of calling functions with them, I mean look at a sample fstream constructor in C++: fstream ifs("filename.txt", i

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Tobias Pankrath
Christophe wrote: >> It is not. But there is currently no nice way to express a set of >> orthogonal flags. > Well, you could use an array of flags ? Oh, wait, that is precisely what > "r", "w", "rw" would be. > Another option is to use the power of typesafe variadic functions: > > enum Mode :ch

Re: More on const-related issue

2011-09-08 Thread bearophile
> At the moment I don't have further ideas on this. Sorry, another solution I've used to solve that problem is to split the array arr of structs in two parallel arrays, one with just the mutable fields and one with just the immutable ones. But this increases the program complexity, makes the pr

Re: More on const-related issue

2011-09-08 Thread Jonathan M Davis
On Thursday, September 08, 2011 05:33:01 bearophile wrote: > With the latest DMD versions it's easy to create an immutable array of > structs, with a pure function (I think this gives advantages similar to the > Transients of the Clojure language): [snip] My take on it is pretty much just not a go

Re: std.stdio overhaul by Steve Schveighoffer

2011-09-08 Thread Sean Cavanaugh
On 9/7/2011 2:19 AM, Jacob Carlborg wrote: On 2011-09-06 19:05, Daniel Murphy wrote: "Andrei Alexandrescu" wrote in message news:j45isu$2t3h$1...@digitalmars.com... Yah, I also think the documentation makes it easy to clarify which module is the preferred one. I think there's a lot of merit t

More on const-related issue

2011-09-08 Thread bearophile
With the latest DMD versions it's easy to create an immutable array of structs, with a pure function (I think this gives advantages similar to the Transients of the Clojure language): struct Foo { int x; bool b; } immutable(Foo[]) generate() pure nothrow { auto arr = new Foo[10];

Re: Formal Review of region allocator begins

2011-09-08 Thread Christophe
Timon Gehr , dans le message (digitalmars.D:144140), a écrit : > Well, I don't really want dangerously looking stuff in my codebase, but > I definitely am going to use the region allocator. BTW invalidatingCopy > is a bad name because: > > 1. nothing is invalidated, the other allocators are just