uniqueness propagation

2011-02-24 Thread Kevin Bealer
I think immutable could benefit from a Value Range Propagation-like uniqueness logic: string a; char[] b; string c = a ~ b; // result of ~ is always unique string z = c.dup; // also any kind of .dup is definitely unique char[] q = z.dup; // also okay -- assign to a non-immutable The lines w/ dup

Allocating in destructors

2011-02-24 Thread Vladimir Panteleev
On Fri, 25 Feb 2011 06:38:52 +0200, dsimcha wrote: In the process, I've built up such a good mental model of the GC codebase that I'd hate to see it go to waste. Here's a question for you. What happens when a class destructor, called by the GC during a collection, allocates? (Hint: nothi

Re: "Regular Expression Matching Can Be Simple And Fast (but...) "

2011-02-24 Thread Russel Winder
On Thu, 2011-02-24 at 17:43 -0500, Nick Sabalausky wrote: [ . . . ] Send feedback to Russ Cox? [ . . . ] > Actually, that's one of the things I really hate about academic writings in > general (not that this article is particularly academic, as far as [ . . . ] I take exception to this catego

Re: GC Blacklisting

2011-02-24 Thread Vladimir Panteleev
On Fri, 25 Feb 2011 06:38:52 +0200, dsimcha wrote: I've been optimizing the druntime garbage collector lately, and as I've found several smaller optimizations since I submitted my patch last week, I've temporarily forked the druntime Git repository to store those optimizations. The result

GC Blacklisting

2011-02-24 Thread dsimcha
I've been optimizing the druntime garbage collector lately, and as I've found several smaller optimizations since I submitted my patch last week, I've temporarily forked the druntime Git repository to store those optimizations. The results are here: https://github.com/dsimcha/druntime/wiki/Dr

Re: destructor order

2011-02-24 Thread Steven Schveighoffer
On Wed, 26 Jan 2011 13:18:58 -0500, Steven Schveighoffer wrote: On Wed, 26 Jan 2011 12:26:22 -0500, Andrei Alexandrescu wrote: On 1/26/11 10:17 AM, Steven Schveighoffer wrote: On Wed, 26 Jan 2011 11:09:45 -0500, Andrej Mitrovic wrote: I think I glanced over a recent svn commit that f

Re: Enum "Inheritance"?

2011-02-24 Thread Nick Sabalausky
"%u" wrote in message news:ik70pq$1a37$1...@digitalmars.com... >>> Lol, okay. Do you have any other suggestions for a better > solution on how to avoid duplicating generic access masks like > MAXIMUM_ALLOWED inside each access mask type? > >> You're doing it wrong. Create OO wrapper instead. > >

Re: Enum "Inheritance"?

2011-02-24 Thread %u
>> Lol, okay. Do you have any other suggestions for a better solution on how to avoid duplicating generic access masks like MAXIMUM_ALLOWED inside each access mask type? > You're doing it wrong. Create OO wrapper instead. Hm... but: (1) I'm not going to create a new instance of an entire class e

Re: Uh... destructors?

2011-02-24 Thread Steven Schveighoffer
On Thu, 24 Feb 2011 19:25:24 -0500, Steven Wawryk wrote: On 24/02/11 14:47, dsimcha wrote: On 2/22/2011 12:13 AM, Jonathan M Davis wrote: On Monday 21 February 2011 20:46:56 %u wrote: Hi, I'm just curious... why is saying something like this: extern(C) private static const pure override

Re: Uh... destructors?

2011-02-24 Thread Steven Wawryk
On 24/02/11 14:47, dsimcha wrote: On 2/22/2011 12:13 AM, Jonathan M Davis wrote: On Monday 21 February 2011 20:46:56 %u wrote: Hi, I'm just curious... why is saying something like this: extern(C) private static const pure override final synchronized ~this() { } allowed? dmd is pretty lax a

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Jonathan M Davis
On Thursday, February 24, 2011 14:55:34 bearophile wrote: > Jonathan M Davis: > > Honestly, I think that the need for actual ASCII strings is quite rare > > and that it _should_ not be encouraged. > > I need ASCII strings (or mutable/immutable arrays of ASCII chars) all the > time, they come from

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Ali Çehreli
On 02/24/2011 12:14 PM, Jonathan M Davis wrote: > the type of "test" is string Sorry to take it out of context but that statement is not always correct. String literals can be string, wstring, or dstring: void foo(string c, wstring w, dstring d) {} void main() { foo("c", "w", "d");

Re: "Regular Expression Matching Can Be Simple And Fast (but...) "

2011-02-24 Thread spir
On 02/24/2011 11:43 PM, Nick Sabalausky wrote: Actually, that's one of the things I really hate about academic writings in general (not that this article is particularly academic, as far as academic-themed stuff goes): There's rarely a decent overview. You're expected to implicitly piece together

Re: "Regular Expression Matching Can Be Simple And Fast (but...) "

2011-02-24 Thread Nick Sabalausky
"spir" wrote in message news:mailman.1923.1298557650.4748.digitalmar...@puremagic.com... > Hello, > > "Regular Expression Matching Can Be Simple And Fast (but is slow in Java, > Perl, PHP, Python, Ruby, ...)" > A *very* interesting and well written article about slow & fast regex > engines, why

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread bearophile
Jonathan M Davis: > Honestly, I think that the need for actual ASCII strings is quite rare and > that > it _should_ not be encouraged. I need ASCII strings (or mutable/immutable arrays of ASCII chars) all the time, they come from English text, genomic data, etc. Bye, bearophile

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Jonathan M Davis
On Thursday, February 24, 2011 13:55:43 bearophile wrote: > Steven Schveighoffer: > > wait, you thought char[] was an array? You poor poor soul ;) > > > > I predict we shall get 1-2 questions/claims of incredulity like this a > > month until we get a real string type. > > There's a need for both

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread bearophile
Steven Schveighoffer: > wait, you thought char[] was an array? You poor poor soul ;) > > I predict we shall get 1-2 questions/claims of incredulity like this a > month until we get a real string type. There's a need for both unicode strings, and simpler strings of 7 bit ASCII chars (both mut

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Steven Schveighoffer
On Thu, 24 Feb 2011 16:21:08 -0500, Andrej Mitrovic wrote: Of course it's not that hard. But when things can be safely automated, I don't see why they shouldn't be. Unless I'm missing some important factor of duping string literals that was not mentioned already. It's a 'hidden allocation'.

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Andrei Alexandrescu
On 2/24/11 3:13 PM, Jesse Phillips wrote: Andrej Mitrovic Wrote: Yes. And you know what's going to happen next, right? Everyone is going to create their own implementation of a string type because of these non-issues. Happens in C/C++ all the time, I see it in almost every mid-large codebase ou

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Andrej Mitrovic
On 2/24/11, Steven Schveighoffer wrote: > But what you are asking is for the compiler to implicitly dup it. Only when the lhs is a mutable type. If it's immutable (string), then you don't have to dup it. Hence: string a = "abc"; string b = "abc"; assert(&a[0] == &b[0]); There's no point in dupi

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Jesse Phillips
Andrej Mitrovic Wrote: > Yes. And you know what's going to happen next, right? Everyone is > going to create their own implementation of a string type because of > these non-issues. Happens in C/C++ all the time, I see it in almost > every mid-large codebase out there. Well, aside from discussion

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Steven Schveighoffer
On Thu, 24 Feb 2011 15:33:52 -0500, Andrej Mitrovic wrote: On 2/24/11, Jonathan M Davis wrote: "test" _is_ immutable, so assigning it to a dchar[] without duping it is bad anyway). Can't the compiler figure that out on its own? It did figure that out (that it was bad) and told you not t

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Andrej Mitrovic
On 2/24/11, Jonathan M Davis wrote: > "test" _is_ immutable, so assigning it to a dchar[] without > duping it is bad anyway). Can't the compiler figure that out on its own?

Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread Tomek Sowiński
Ali Çehreli napisał: > Implicit conversions to immutable in the following two functions feel > harmless. Has this been discussed before? > > string foo() > { > char[] s; > return s; // Error: cannot implicitly convert expression >//(s) of type char[] to

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Andrej Mitrovic
On 2/24/11, Steven Schveighoffer wrote: > > A string literal is immutable, dchar[] is mutable. These should work: > > immutable(dchar)[] test = "test"; > dstring test = "test"; > auto test = "test"d; Ah right, the postfix form. That's what i was looking for. I know a literal is immutable, I've t

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Jonathan M Davis
On Thursday, February 24, 2011 11:42:38 Andrej Mitrovic wrote: > On 2/24/11, Jesse Phillips wrote: > > Andrej Mitrovic Wrote: > >> Now I see why using char[] fails. It's because [ElementType!(R).init]; > >> returns a dchar[]. > > > > Yep, Unicode for the win. dchar[] is swappable. > > Oh looks l

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Steven Schveighoffer
On Thu, 24 Feb 2011 14:42:38 -0500, Andrej Mitrovic wrote: On 2/24/11, Jesse Phillips wrote: Andrej Mitrovic Wrote: Now I see why using char[] fails. It's because [ElementType!(R).init]; returns a dchar[]. Yep, Unicode for the win. dchar[] is swappable. Oh looks like you're right. I

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Andrej Mitrovic
On 2/24/11, Jesse Phillips wrote: > Andrej Mitrovic Wrote: > >> Now I see why using char[] fails. It's because [ElementType!(R).init]; >> returns a dchar[]. > > Yep, Unicode for the win. dchar[] is swappable. > Oh looks like you're right. I can use reverse on dchar[]. Weird, I thought I've alread

Re: Bug fixes must come with unit tests

2011-02-24 Thread Andrej Mitrovic
Regressions? Why.. we don't have those in D! See http://d.puremagic.com/issues/buglist.cgi?query_format=advanced&bug_severity=regression&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Jesse Phillips
Andrej Mitrovic Wrote: > Now I see why using char[] fails. It's because [ElementType!(R).init]; > returns a dchar[]. Yep, Unicode for the win. dchar[] is swappable.

Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread Jesse Phillips
Also there is std.exception.assumUnique()

Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread Jesse Phillips
Ali Çehreli Wrote: > I have another question: Does calling .idup copy any data below? > > string foo() > { > char[] s; > return s.idup; // Is the content copied? > } > > Ali > Yes, dup stands for duplicate and is a property of arrays. There was discussion for allowing immutable ob

Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread Simon Buerger
On 24.02.2011 19:08, Ali Çehreli wrote: Implicit conversions to immutable in the following two functions feel harmless. Has this been discussed before? string foo() { char[] s; return s; // Error: cannot implicitly convert expression // (s) of type char[] to string } string bar() { char[] s; re

Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread Ali Çehreli
On 02/24/2011 10:28 AM, spir wrote: > On 02/24/2011 07:08 PM, Ali Çehreli wrote: >> Implicit conversions to immutable in the following two functions feel >> harmless. >> Has this been discussed before? >> >> string foo() >> { >> char[] s; >> return s; // Error: cannot implicitly convert expression

Re: Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread spir
On 02/24/2011 07:08 PM, Ali Çehreli wrote: Implicit conversions to immutable in the following two functions feel harmless. Has this been discussed before? string foo() { char[] s; return s; // Error: cannot implicitly convert expression // (s) of type char[] to string } string bar() { char[] s;

Re: Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Andrej Mitrovic
Now I see why using char[] fails. It's because [ElementType!(R).init]; returns a dchar[].

Should conversion of mutable return value to immutable allowed?

2011-02-24 Thread Ali Çehreli
Implicit conversions to immutable in the following two functions feel harmless. Has this been discussed before? string foo() { char[] s; return s; // Error: cannot implicitly convert expression //(s) of type char[] to string } string bar() { char[] s;

Shouldn't hasSwappableElements work on char arrays?

2011-02-24 Thread Andrej Mitrovic
Would it be wrong if hasSwappableElements worked on char arrays? Look: import std.stdio; import std.algorithm; import std.range; import std.traits; void main() { char[] r = "abc".dup; // fails: static assert(hasSwappableElements!(char[])); // fails because reverse uses h

Bug fixes must come with unit tests

2011-02-24 Thread Ali Çehreli
I notice that some dmd and Phobos bugs are fixed without any supporting unit tests. The following approach is very effective in code quality: 1) A bug is discovered; two issues are exposed: i) the bug itself ii) the lack of a unit test that could have caught the bug 2) Write a unit test t

Re: LDC2 Status

2011-02-24 Thread Michel Fortin
On 2011-02-24 10:49:31 -0500, Andrew Wiley said: On Thu, Feb 24, 2011 at 12:56 AM, Alexey Prokhin wrote: I use cmake to compile druntime and phobos: $ cd ldc2_build_dir $ cmake -DRUNTIME_DIR=path_to_druntime -DPHOBOS2_DIR=path_to_phobos . $ make phobos2 (or 'make runtime' if you want to build

Re: LDC2 Status

2011-02-24 Thread Andrew Wiley
On Thu, Feb 24, 2011 at 12:56 AM, Alexey Prokhin wrote: > I use cmake to compile druntime and phobos: > $ cd ldc2_build_dir > $ cmake -DRUNTIME_DIR=path_to_druntime -DPHOBOS2_DIR=path_to_phobos . > $ make phobos2 (or 'make runtime' if you want to build only druntime) > I tried building on ARM jus

Re: "Regular Expression Matching Can Be Simple And Fast (but...) "

2011-02-24 Thread Andrei Alexandrescu
On 2/24/11 8:26 AM, spir wrote: Hello, "Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...)" A *very* interesting and well written article about slow & fast regex engines, why and how: http://swtch.com/~rsc/regexp/regexp1.html Denis An often-

Re: "Regular Expression Matching Can Be Simple And Fast (but...) "

2011-02-24 Thread Trass3r
Yep, finite automata FTW! Same goes for non-regexp string matching, see Aho-Corasick algorithm.

Re: "Regular Expression Matching Can Be Simple And Fast (but...) "

2011-02-24 Thread spir
On 02/24/2011 03:26 PM, spir wrote: Hello, "Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...)" A *very* interesting and well written article about slow & fast regex engines, why and how: http://swtch.com/~rsc/regexp/regexp1.html Denis (PS:

"Regular Expression Matching Can Be Simple And Fast (but...) "

2011-02-24 Thread spir
Hello, "Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...)" A *very* interesting and well written article about slow & fast regex engines, why and how: http://swtch.com/~rsc/regexp/regexp1.html Denis -- _ vita es estrany spir

Re: Lazy lists

2011-02-24 Thread Jacob Carlborg
On 2011-02-23 16:36, Andrei Alexandrescu wrote: On 2/23/11 9:30 AM, Jacob Carlborg wrote: On 2011-02-23 13:57, Andrei Alexandrescu wrote: On 2/23/11 5:10 AM, Jacob Carlborg wrote: On 2011-02-23 03:28, bearophile wrote: This is a Scala implementation of a function that prints the carpet: def

Re: std.xml empty element

2011-02-24 Thread Lars T. Kyllingstad
On Thu, 24 Feb 2011 09:09:35 -0300, Tom wrote: > Hi, how can I create an empty element with current D2 std.xml Element > implementation? > > stdout.writeln(new Element("foo")); // Yields instead of > > > Thanks in advance, > Tom; Hi, I see you asked this question in D.learn first, and that i

std.xml empty element

2011-02-24 Thread Tom
Hi, how can I create an empty element with current D2 std.xml Element implementation? stdout.writeln(new Element("foo")); // Yields instead of Thanks in advance, Tom;

Re: Enum "Inheritance"?

2011-02-24 Thread Kagamin
%u Wrote: > Lol, okay. Do you have any other suggestions for a better solution on how to > avoid duplicating > generic access masks like MAXIMUM_ALLOWED inside each access mask type? You're doing it wrong. Create OO wrapper instead.

Re: Lazy lists

2011-02-24 Thread spir
On 02/24/2011 09:55 AM, Russel Winder wrote: On Wed, 2011-02-23 at 23:51 +0100, spir wrote: [ . . . ] (sequence(["#"])(nextCarpet) drop n next) foreach println Hey guys, it's PostScript, no it's Forth ;-) Note that method chaining in typical OO syntax writes the process in chronologic

Re: Lazy lists

2011-02-24 Thread Russel Winder
On Wed, 2011-02-23 at 23:51 +0100, spir wrote: [ . . . ] > (sequence(["#"])(nextCarpet) drop n next) foreach println Hey guys, it's PostScript, no it's Forth ;-) -- Russel. = Dr Russel Winder t: +44 20 7585 220