Re: Don't use arrays as stacks

2011-09-25 Thread Andrei Alexandrescu
On 9/25/11 1:37 AM, Nick Sabalausky wrote: If anyone cares, I've put up a little thing about why it's best not to use D's arrays as stacks. This is drawn from a direct experience a few months ago. Figured if I fell into that trap then others might too, so this could be helpful for some people. Th

Re: Don't use arrays as stacks

2011-09-25 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:j5mi7l$1dtf$1...@digitalmars.com... > If anyone cares, I've put up a little thing about why it's best not to use > D's arrays as stacks. This is drawn from a direct experience a few months > ago. Figured if I fell into that trap then others might too, so

Re: Don't use arrays as stacks

2011-09-25 Thread Andrew Wiley
On Sun, Sep 25, 2011 at 1:45 AM, Jonathan M Davis wrote: > On Sunday, September 25, 2011 02:37:25 Nick Sabalausky wrote: >> If anyone cares, I've put up a little thing about why it's best not to use >> D's arrays as stacks. This is drawn from a direct experience a few months >> ago. Figured if I f

Re: Don't use arrays as stacks

2011-09-25 Thread Jonathan M Davis
On Sunday, September 25, 2011 03:18:29 Andrew Wiley wrote: > On Sun, Sep 25, 2011 at 1:45 AM, Jonathan M Davis wrote: > > On Sunday, September 25, 2011 02:37:25 Nick Sabalausky wrote: > >> If anyone cares, I've put up a little thing about why it's best not to > >> use D's arrays as stacks. This i

Re: How can I use D to develop web application?

2011-09-25 Thread mta`chrono
> Thank you very much. I think the cgi module is lower effecient. I found > fcgi(http://www.dsource.org/projects/fastcgi4d) and > mango(http://www.dsource.org/projects/mango) which support servlet. But they > don't > support D2, anyone else can merge them to D2? > > zsxxsz I've some D2 code work

Re: Anonymous function syntax

2011-09-25 Thread Mafi
Am 22.09.2011 22:54, schrieb Andrei Alexandrescu: On 9/21/11 5:17 PM, Walter Bright wrote: I've collected a few from various languages for comparison: [snip] I think we should do the following: 1. Introduce a new token "=>" 2. Add this rewrite to the grammar: symbol => expression translate

Re: Anonymous function syntax

2011-09-25 Thread Timon Gehr
On 09/25/2011 11:43 AM, Mafi wrote: Am 22.09.2011 22:54, schrieb Andrei Alexandrescu: On 9/21/11 5:17 PM, Walter Bright wrote: I've collected a few from various languages for comparison: [snip] I think we should do the following: 1. Introduce a new token "=>" 2. Add this rewrite to the gram

Re: Don't use arrays as stacks

2011-09-25 Thread Nick Sabalausky
"Jonathan M Davis" wrote in message news:mailman.160.1316939358.26225.digitalmar...@puremagic.com... > On Sunday, September 25, 2011 03:18:29 Andrew Wiley wrote: >> >> Isn't this exactly what assumeSafeAppend is for? Hmm, I didn't know about that. (Actually, I remember hearing it mentioned befo

Re: Don't use arrays as stacks

2011-09-25 Thread Jonathan M Davis
On Sunday, September 25, 2011 07:05:34 Nick Sabalausky wrote: > "Jonathan M Davis" wrote in message > news:mailman.160.1316939358.26225.digitalmar...@puremagic.com... > > > On Sunday, September 25, 2011 03:18:29 Andrew Wiley wrote: > >> Isn't this exactly what assumeSafeAppend is for? > > Hmm, I

Re: Why do we have transitive const, again?

2011-09-25 Thread bearophile
Walter: > struct LogicalConst(T) > { > @property T v() { > if (!set) { >_v = some_expensive_computation(); >set = true; > } > return _v; > } > >private: > bool set = false; > T _v; > } If this idiom becomes common (thanks to

Re: Don't use arrays as stacks

2011-09-25 Thread bearophile
Nick Sabalausky: > https://www.semitwist.com/articles/article/view/don-t-use-arrays-as-stacks Is it possible to write a function like: ForeachType!A unsafePop(A)(A)if(isDynamicArray!A) { /*...*/ } that contains both the popping (and something like assumeSafeAppend to mess with the druntime dat

Re: Don't use arrays as stacks

2011-09-25 Thread Lutger Blijdestijn
Nick Sabalausky wrote: > "Jonathan M Davis" wrote in message > news:mailman.160.1316939358.26225.digitalmar...@puremagic.com... >> On Sunday, September 25, 2011 03:18:29 Andrew Wiley wrote: >>> >>> Isn't this exactly what assumeSafeAppend is for? > > Hmm, I didn't know about that. (Actually, I r

Re: Why do we have transitive const, again?

2011-09-25 Thread Peter Alexander
On 25/09/11 3:51 AM, Andrei Alexandrescu wrote: On 9/24/11 9:07 PM, Peter Alexander wrote: Heading off on a tangent here, but isn't the const this(this) problem a language problem rather than a QoI problem? The design exists but the implementation has not yet been finalized yet. Walter and I h

Re: thoughts on immutability in D

2011-09-25 Thread Peter Alexander
On 25/09/11 4:49 AM, Walter Bright wrote: On 9/24/2011 6:03 AM, Peter Alexander wrote: I only use const/immutable for concurrency. Nothing else. How do you avoid race conditions when setting logical const values? You can't and don't. That's not what logical const is for. That's what physica

Re: this(this) must be cheap and O(1)

2011-09-25 Thread Michel Fortin
On 2011-09-25 02:52:47 +, Andrei Alexandrescu said: On 9/24/11 9:31 PM, Michel Fortin wrote: Perhaps I am missing the point. What would be gained by forcing this(this) to be nothrow? It further frees the standard library to cater for the throwing case. Concretely, what does it simplif

Re: Possible way to achieve lazy loading with const objects

2011-09-25 Thread Peter Alexander
On 24/09/11 6:53 PM, Timon Gehr wrote: On 09/24/2011 07:21 PM, Peter Alexander wrote: On 24/09/11 12:47 PM, Jonathan M Davis wrote: On Saturday, September 24, 2011 12:19:33 Peter Alexander wrote: Lazy loading and caching are the same thing. No. Caching is more general. Lazy loading is explic

Re: Why do we have transitive const, again?

2011-09-25 Thread Timon Gehr
On 09/25/2011 01:18 PM, bearophile wrote: Walter: struct LogicalConst(T) { @property T v() { if (!set) { _v = some_expensive_computation(); set = true; } return _v; } private: bool set = false; T _v; } If this idi

Re: Why do we have transitive const, again?

2011-09-25 Thread bearophile
Timon Gehr: > I think it should be a language feature, as proposed by Jonathan. I did miss his post. I see he has turn that idiom into a language feature :-) >From Jonathan's post: > 2. __varLoaded is default-initialized to false, and __var is void (so, > garbage). The GC has to read __varLoa

Re: q{ @ }

2011-09-25 Thread Peter Alexander
On 25/09/11 4:49 PM, Peter Alexander wrote: See: http://d-programming-language.org/lex.html It says: q{ @ } // error, @ is not a valid D token but... http://d-programming-language.org/lex.html#Token This clearly shows that @ is a token. So, which is it? btw... import std.stdio; void mai

q{ @ }

2011-09-25 Thread Peter Alexander
See: http://d-programming-language.org/lex.html It says: q{ @ } // error, @ is not a valid D token but... http://d-programming-language.org/lex.html#Token This clearly shows that @ is a token. So, which is it?

Re: Vote on region allocator

2011-09-25 Thread Sean Kelly
On Sep 24, 2011, at 4:55 PM, Andrei Alexandrescu wrote: > > Making the allocator a part of the container type would go the STL way, and > STL allocators are essentially a failed experiment. I'm only partially clear > on why it has failed, but it does seem that part of the reason was making the

Re: Vote on region allocator

2011-09-25 Thread Sean Kelly
No. If this were just a scoped allocator, that would be fine, but a general purpose allocator interface needs more discussion.

Re: q{ @ }

2011-09-25 Thread Timon Gehr
On 09/25/2011 05:49 PM, Peter Alexander wrote: See: http://d-programming-language.org/lex.html It says: q{ @ } // error, @ is not a valid D token but... http://d-programming-language.org/lex.html#Token This clearly shows that @ is a token. So, which is it? @ is a token. The documentation

Re: Liskov principle and unittest

2011-09-25 Thread deadalnix
I think what he wants is to have automatically generated unittests for derived classes that check if the unittests of the parent still pass for them. I don't know of a nice way to do that without requiring some minimal effort by the implementor of the derived class. Contracts quickly detect and r

std.algorithm.nWayUnion and nWayMerge

2011-09-25 Thread bearophile
In std.algorithm there is a section of set functions that work on ordered iterables, like nWayUnion: http://www.d-programming-language.org/phobos/std_algorithm.html#nWayUnion This is an example of nWayUnion usage: import std.algorithm; void main() { auto data = [[1, 2, 3], [1, 3, 5]]; a

Re: Vote on region allocator

2011-09-25 Thread deadalnix
Le 24/09/2011 01:14, Jonathan M Davis a écrit : On Friday, September 23, 2011 16:02 Martin Nowak wrote: I already added a comment on github (sorrowly allows comments only on diffs). Bugs should be fixed whenever they are know and should only be a concern for voting if there is a gross number of

Re: this(this) must be cheap and O(1)

2011-09-25 Thread deadalnix
Le 25/09/2011 04:52, Andrei Alexandrescu a écrit : On 9/24/11 9:31 PM, Michel Fortin wrote: Perhaps I am missing the point. What would be gained by forcing this(this) to be nothrow? It further frees the standard library to cater for the throwing case. Andrei If I understand, what is explain

Re: this(this) must be cheap and O(1)

2011-09-25 Thread Peter Alexander
On 25/09/11 7:37 PM, deadalnix wrote: Le 25/09/2011 04:52, Andrei Alexandrescu a écrit : On 9/24/11 9:31 PM, Michel Fortin wrote: Perhaps I am missing the point. What would be gained by forcing this(this) to be nothrow? It further frees the standard library to cater for the throwing case. An

Re: 64 bit version?

2011-09-25 Thread Robert Clipsham
On 22/09/2011 21:12, Trass3r wrote: or ldc, I thought that could also compile d2 LLVM still doesn't support SEH, though it's being worked on. The latest development code does for Win64. -- Robert http://octarineparrot.com/

Re: this(this) must be cheap and O(1)

2011-09-25 Thread deadalnix
Le 25/09/2011 21:02, Peter Alexander a écrit : On 25/09/11 7:37 PM, deadalnix wrote: Le 25/09/2011 04:52, Andrei Alexandrescu a écrit : On 9/24/11 9:31 PM, Michel Fortin wrote: Perhaps I am missing the point. What would be gained by forcing this(this) to be nothrow? It further frees the stan

Re: Liskov principle and unittest

2011-09-25 Thread Philippe Sigaud
On Sun, Sep 25, 2011 at 20:02, deadalnix wrote: >> I think what he wants is to have automatically generated unittests for >> derived classes that check if the unittests of the parent still pass for >> them. I don't know of a nice way to do that without requiring some >> minimal effort by the imple

Re: Vote on region allocator

2011-09-25 Thread Peter Alexander
On 25/09/11 12:55 AM, Andrei Alexandrescu wrote: On 9/24/11 9:33 AM, dsimcha wrote: On 9/24/2011 2:10 AM, Andrei Alexandrescu wrote: On 9/23/11 22:30 CDT, dsimcha wrote: On 9/23/2011 11:25 PM, Robert Jacques wrote: On Fri, 23 Sep 2011 15:53:46 -0400, Jonathan M Davis wrote: No. I cannot bui

Re: Vote on region allocator

2011-09-25 Thread Peter Alexander
On 25/09/11 1:20 AM, dsimcha wrote: On 9/24/2011 7:55 PM, Andrei Alexandrescu wrote: Defining and using an allocator interface would have a small speed impact (i.e. allocation would entail an indirect call) but I think that would be acceptable. Agreed. My much bigger concern w.r.t. dynamic int

Re: Why do we have transitive const, again?

2011-09-25 Thread Jonathan M Davis
On Sunday, September 25, 2011 11:12:10 bearophile wrote: > Timon Gehr: > > I think it should be a language feature, as proposed by Jonathan. > > I did miss his post. I see he has turn that idiom into a language feature > :-) > From Jonathan's post: > > 2. __varLoaded is default-initialized to fals

Re: Vote on region allocator

2011-09-25 Thread dsimcha
On 9/25/2011 4:40 PM, Peter Alexander wrote: On 25/09/11 1:20 AM, dsimcha wrote: On 9/24/2011 7:55 PM, Andrei Alexandrescu wrote: Defining and using an allocator interface would have a small speed impact (i.e. allocation would entail an indirect call) but I think that would be acceptable. Agr

Re: Vote on region allocator

2011-09-25 Thread Peter Alexander
On 25/09/11 10:57 PM, dsimcha wrote: On 9/25/2011 4:40 PM, Peter Alexander wrote: On 25/09/11 1:20 AM, dsimcha wrote: On 9/24/2011 7:55 PM, Andrei Alexandrescu wrote: Defining and using an allocator interface would have a small speed impact (i.e. allocation would entail an indirect call) but I

Re: Possible way to achieve lazy loading with const objects

2011-09-25 Thread Simen Kjaeraas
On Sat, 24 Sep 2011 13:19:33 +0200, Peter Alexander wrote: Lazy loading and caching are the same thing. struct Foo { T m_lazyObj = null; bool m_isLoaded = false; T getObj() { if (!m_isLoaded) { m_lazyObj = func(); m_isLoaded =

Re: Possible way to achieve lazy loading with const objects

2011-09-25 Thread Simen Kjaeraas
On Mon, 26 Sep 2011 02:02:06 +0200, Simen Kjaeraas wrote: On Sat, 24 Sep 2011 13:19:33 +0200, Peter Alexander wrote: Lazy loading and caching are the same thing. struct Foo { T m_lazyObj = null; bool m_isLoaded = false; T getObj() { if (!m_isLoaded)

Re: Possible way to achieve lazy loading with const objects

2011-09-25 Thread Jonathan M Davis
On Monday, September 26, 2011 02:02:06 Simen Kjaeraas wrote: > On Sat, 24 Sep 2011 13:19:33 +0200, Peter Alexander > > wrote: > > Lazy loading and caching are the same thing. > > > > struct Foo > > { > > > > T m_lazyObj = null; > > bool m_isLoaded = false; > > > > T getObj(

Re: Possible way to achieve lazy loading with const objects

2011-09-25 Thread Jonathan M Davis
On Monday, September 26, 2011 02:03:23 Simen Kjaeraas wrote: > On Mon, 26 Sep 2011 02:02:06 +0200, Simen Kjaeraas > > wrote: > > On Sat, 24 Sep 2011 13:19:33 +0200, Peter Alexander > > > > wrote: > >> Lazy loading and caching are the same thing. > >> > >> struct Foo > >> { > >> > >> T m_

Re: Possible way to achieve lazy loading with const objects

2011-09-25 Thread Walter Bright
On 9/23/2011 9:11 PM, Jonathan M Davis wrote: Okay. I'm not saying that we should necessarily implement this. I'm just looking to air out an idea here and see if there are any technical reasons why it can't be done or is unreasonable. Andrei and I talked about this some time back. Where it ran

Re: Possible way to achieve lazy loading with const objects

2011-09-25 Thread Jonathan M Davis
On Sunday, September 25, 2011 17:46:00 Walter Bright wrote: > On 9/23/2011 9:11 PM, Jonathan M Davis wrote: > > Okay. I'm not saying that we should necessarily implement this. I'm just > > looking to air out an idea here and see if there are any technical > > reasons why it can't be done or is unre

std.benchmark is in reviewable state

2011-09-25 Thread Andrei Alexandrescu
I've had a good time with std.benchmark today and made it ready for submission to Phobos. As a perk I've added the %h format specifier, which formats a number in human-readable form using SI prefixes. For those interested in discussing this prior to the formal review process, the code is at:

Re: Possible way to achieve lazy loading with const objects

2011-09-25 Thread Walter Bright
On 9/25/2011 6:03 PM, Jonathan M Davis wrote: I don't know that what it adds merits the extra complexity that it requires. I think that's the real issue. D has a lot of stuff in it, we ought to be very demanding of significant new features.

Re: std.benchmark is in reviewable state

2011-09-25 Thread bearophile
Andrei Alexandrescu: > http://erdani.com/d/web/phobos-prerelease/std_benchmark.html Is the micron symbol visible on Windows too? Bye, bearophile

Re: q{ @ }

2011-09-25 Thread Bernard Helyer
On Sun, 25 Sep 2011 18:10:53 +0200, Timon Gehr wrote: > @ is a token. The documentation was probably written when it was not. Yep, so Peter's stumbled on a bug. Bugzilla that shit, Peter! :D

Re: std.benchmark is in reviewable state

2011-09-25 Thread Robert Jacques
On Sun, 25 Sep 2011 21:08:45 -0400, Andrei Alexandrescu wrote: I've had a good time with std.benchmark today and made it ready for submission to Phobos. As a perk I've added the %h format specifier, which formats a number in human-readable form using SI prefixes. For those interested in discus

Re: std.benchmark is in reviewable state

2011-09-25 Thread Adam D. Ruppe
bearophile wrote: > Is the micron symbol visible on Windows too? Yes, of course. It's a matter of fonts though - if you don't have the character in your font (regardless of operating system) it might not show. The micro sign is very common though, so unlikely to have any font without it.

Am I stupid?

2011-09-25 Thread dame
Well am I?

Re: std.benchmark is in reviewable state

2011-09-25 Thread Andrei Alexandrescu
On 9/25/11 8:41 PM, bearophile wrote: Andrei Alexandrescu: http://erdani.com/d/web/phobos-prerelease/std_benchmark.html Is the micron symbol visible on Windows too? Ionno, haven't tried. Andrei

Re: Am I stupid?

2011-09-25 Thread Ali Çehreli
On Sun, 25 Sep 2011 21:44:44 -0500, dame wrote: > Well am I? \|||/ (o o) ,ooO--(_)---. | Please| | don't feed the | | TROLLs ! | '--Ooo--' |__|__| || || ooO Ooo Ali

Re: Am I stupid?

2011-09-25 Thread so
On Mon, 26 Sep 2011 05:44:44 +0300, dame wrote: Well am I? Of course you are not. If you were, you'd choose a high profile language as your prey. On another thought i think you are, you keep trying and i am the only one feeding you with this reply, not a healthy environment for a troll

Re: std.benchmark is in reviewable state

2011-09-25 Thread Vladimir Panteleev
On Mon, 26 Sep 2011 05:03:32 +0300, Adam D. Ruppe wrote: bearophile wrote: Is the micron symbol visible on Windows too? Yes, of course. It's a matter of fonts though - if you don't have the character in your font (regardless of operating system) it might not show. The micro sign is very

Re: std.benchmark is in reviewable state

2011-09-25 Thread Andrei Alexandrescu
On 9/25/11 9:02 PM, Robert Jacques wrote: On Sun, 25 Sep 2011 21:08:45 -0400, Andrei Alexandrescu wrote: I've had a good time with std.benchmark today and made it ready for submission to Phobos. As a perk I've added the %h format specifier, which formats a number in human-readable form using SI

Re: std.benchmark is in reviewable state

2011-09-25 Thread Andrej Mitrovic
I'm thinking we could shorten the function names. benchmarkResume is a mouthful, and we already came to the conclusion that we shouldn't repeat module names in function names. But I'm all out of ideas for naming things, sorry. :)

Re: std.benchmark is in reviewable state

2011-09-25 Thread Adam D. Ruppe
Vladimir Panteleev wrote: > There are two problems with Unicode characters in console D programs: I was thinking of the website documentation, not the program itself. The symbols works for the website, but not really for the program. (even most my linux terminals aren't UTF-8)

Re: std.benchmark is in reviewable state

2011-09-25 Thread so
On Mon, 26 Sep 2011 06:14:59 +0300, Andrej Mitrovic wrote: I'm thinking we could shorten the function names. benchmarkResume is a mouthful, and we already came to the conclusion that we shouldn't repeat module names in function names. But I'm all out of ideas for naming things, sorry. :) Al

Re: std.benchmark is in reviewable state

2011-09-25 Thread so
On Mon, 26 Sep 2011 04:08:45 +0300, Andrei Alexandrescu wrote: I've had a good time with std.benchmark today and made it ready for submission to Phobos. As a perk I've added the %h format specifier, which formats a number in human-readable form using SI prefixes. For those interested in

Re: Vote on region allocator

2011-09-25 Thread dsimcha
On 9/25/2011 6:24 PM, Peter Alexander wrote: On 25/09/11 10:57 PM, dsimcha wrote: On 9/25/2011 4:40 PM, Peter Alexander wrote: On 25/09/11 1:20 AM, dsimcha wrote: On 9/24/2011 7:55 PM, Andrei Alexandrescu wrote: Defining and using an allocator interface would have a small speed impact (i.e. a

Re: Vote on region allocator

2011-09-25 Thread Daniel Murphy
"dsimcha" wrote in message news:j5otvn$2qg1$1...@digitalmars.com... > > T newArray(T, I...)(I sizes); > > // Usage: > auto foo = newArray!(uint[])(5); > > This would be marginally do-able but very ugly if RTTI were used. You can do this with a final templated interface method and forward to the

Re: std.benchmark is in reviewable state

2011-09-25 Thread Jonathan M Davis
On Sunday, September 25, 2011 21:51:49 Andrei Alexandrescu wrote: > On 9/25/11 8:41 PM, bearophile wrote: > > Andrei Alexandrescu: > >> http://erdani.com/d/web/phobos-prerelease/std_benchmark.html > > > > Is the micron symbol visible on Windows too? > > Ionno, haven't tried. core.time.Duration h

Re: std.benchmark is in reviewable state

2011-09-25 Thread Robert Jacques
On Sun, 25 Sep 2011 23:06:01 -0400, Andrei Alexandrescu wrote: On 9/25/11 9:02 PM, Robert Jacques wrote: On Sun, 25 Sep 2011 21:08:45 -0400, Andrei Alexandrescu wrote: I've had a good time with std.benchmark today and made it ready for submission to Phobos. As a perk I've added the %h format

Re: Am I stupid?

2011-09-25 Thread dame
so wrote: > On Mon, 26 Sep 2011 05:44:44 +0300, dame > wrote: > >> Well am I? > > Of course you are not. If you were, you'd choose a high profile > language as your prey. > On another thought i think you are, you keep trying and i am the only > one feeding you with this reply, not a healthy enviro

Re: Am I stupid?

2011-09-25 Thread dame
or maybe I want you to get the fu I am not a warrior. >so wrote: > On Mon, 26 Sep 2011 05:44:44 +0300, dame > wrote: > >> Well am I? > > Of course you are not. If you were, you'd choose a high profile > language as your prey. > On another thought i think you are, you keep trying and i am the on

Re: thoughts on immutability in D

2011-09-25 Thread Rainer Schuetze
On 25.09.2011 04:25, Peter Alexander wrote: On 24/09/11 4:47 PM, Rainer Schuetze wrote: Sorry for the bad example, here's one that is not thread-safe, and where the invariant can fail in a multi-threaded environment: shared(int) globId; class C { invariant() { assert((globId & 1) == 0); } @p

Re: thoughts on immutability in D

2011-09-25 Thread Jonathan M Davis
On Monday, September 26, 2011 08:14:31 Rainer Schuetze wrote: > Which finally brings us back to the original question: What does > immutable guarantee in the face of non-pure property getter functions? immutable guarantees that when an object is immutable, none of its member variables will _ever_

Re: Am I stupid?

2011-09-25 Thread dame
and you shut the fuck up and stand the fuck down, and get the fuck out of my face

hmmm?

2011-09-25 Thread dame
I have not lived a day without her.

Re: std.benchmark is in reviewable state

2011-09-25 Thread Walter Bright
On 9/25/2011 6:08 PM, Andrei Alexandrescu wrote: I've had a good time with std.benchmark today and made it ready for submission to Phobos. As a perk I've added the %h format specifier, which formats a number in human-readable form using SI prefixes. We already have std.perf: http://www.d-pro