Sept. 15 - The Many Faces of D

2010-09-05 Thread Walter Bright
I'll be giving a presentation on The Many Faces of D at the Northwest C++ Users' Group meeting on Sept. 15. http://nwcpp.org/ 3 copies of The D Programming Language book autographed by Andrei will be given out as door prizes. Light refreshments, too! See y'all there.

Re: Behaviour of goto into catch blocks.

2010-09-05 Thread Don
Iain Buclaw wrote: When it comes to using goto in D, the behaviour seems to be that you cannot enter a try block, and neither can you enter or exit from a finally block. What about catch blocks? It seems that there is no restrictions imposed on them, meaning that the following is legal.

Re: blosc

2010-09-05 Thread Justin Johansson
bearophile wrote: Something that seems fit for the D2 standard library, a lossless compressor meant to speed up some memory-heavy operations (already used in Pytables): http://blosc.pytables.org/trac Bye, bearophile Which specific standard D2 library module do you propose this fit for?

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Simen kjaeraas
Philippe Sigaud philippe.sig...@gmail.com wrote: I guess the D syntax would be auto x = amb([1,2,3]); auto y =amb([4,5,6]); x*y == 8; // forces desambiguation = the ambs explore the possibilities. assert(x == amb([2])); assert(y == amb([4])); There is only one value left, no more ambiguity.

Re: blosc

2010-09-05 Thread bearophile
Justin Johansson: Which specific standard D2 library module do you propose this fit for? std.memory, that contains some special allocators too :-) Bye, bearophile

Creation in Dylan

2010-09-05 Thread bearophile
Regarding the recent small thread about the new statement, this is how the Dylan language faces the problem (found through Lambda The Ultimate): http://www.opendylan.org/books/drm/Constructing_and_Initializing_Instances#make Bye, bearophile

Re: [challenge] Hamming numbers

2010-09-05 Thread Philippe Sigaud
On Sat, Sep 4, 2010 at 23:55, bearophile bearophileh...@lycos.com wrote: It computes the result (ghc-6.8.2) in 0.93s using only 8.7 MB of memory. OK, so that may the difference between GHCi and GHC proper. Less than 1s is impressive. I see I have GHC 6.12.3 on my system. I may give this code

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Philippe Sigaud
On Sun, Sep 5, 2010 at 12:00, Simen kjaeraas simen.kja...@gmail.com wrote: Philippe Sigaud philippe.sig...@gmail.com wrote: I guess the D syntax would be auto x = amb([1,2,3]); auto y =amb([4,5,6]); x*y == 8; // forces desambiguation = the ambs explore the possibilities. assert(x ==

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Denis Koroskin
On Sun, 05 Sep 2010 16:59:31 +0400, Philippe Sigaud philippe.sig...@gmail.com wrote: But the real challenge in the SO question is the 'going back in time' part, which I have trouble to understand : how can you modify x and y through a multiplication and a comparison? It can be done using

Re: [challenge] Hamming numbers

2010-09-05 Thread bearophile
Philippe Sigaud: Less than 1s is impressive. To compare, on the Ideone site the third Python version (Python 2.6.4 + Psyco) takes 1.46s and max 88 MB (this is where what Don has said about D bignums is important): http://ideone.com/5NvzR Maybe with lazy int delegates ? Right, but the devil

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Andrei Alexandrescu
On 09/05/2010 07:59 AM, Philippe Sigaud wrote: On Sun, Sep 5, 2010 at 12:00, Simen kjaeraas simen.kja...@gmail.com mailto:simen.kja...@gmail.com wrote: Philippe Sigaud philippe.sig...@gmail.com mailto:philippe.sig...@gmail.com wrote: I guess the D syntax would be auto

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Philippe Sigaud
2010/9/5 Denis Koroskin 2kor...@gmail.com On Sun, 05 Sep 2010 16:59:31 +0400, Philippe Sigaud philippe.sig...@gmail.com wrote: But the real challenge in the SO question is the 'going back in time' part, which I have trouble to understand : how can you modify x and y through a

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Philippe Sigaud
On Sun, Sep 5, 2010 at 15:56, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: equivalent to the problem: auto solution = comp!([a,b], a*b == 8)([1,2,3], [4,5,6]); solution is a range, in this case a one element range, containing only [2,4]. I did a range comprehension maybe one

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Philippe Sigaud
On Sun, Sep 5, 2010 at 16:30, Philippe Sigaud philippe.sig...@gmail.comwrote: What you call crossProduct can be seen as zipWith!tuple(range, range2), which Scratch that. zipWith *is* mapping on n ranges in parallel.

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Denis Koroskin
On Sun, 05 Sep 2010 18:24:43 +0400, Philippe Sigaud philippe.sig...@gmail.com wrote: 2010/9/5 Denis Koroskin 2kor...@gmail.com On Sun, 05 Sep 2010 16:59:31 +0400, Philippe Sigaud philippe.sig...@gmail.com wrote: But the real challenge in the SO question is the 'going back in time' part,

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread bearophile
Denis Koroskin: The code above should print: state saved state restored (not tested) On Windows, dmd 2.048, this code: import std.c.stdio: puts; version (Windows) { alias int[16] jmp_buf; extern (C) extern { int setjmp(ref jmp_buf env); void longjmp(ref jmp_buf

Re: Style updated on d-programming-language.org

2010-09-05 Thread Daevius
Looks very slick, much better then the current design. It gives a better overview, and is a relieve to the eye :) Few things I'd like to mention: - perhaps make the paragraph headers larger in font size, when scrolling down it's not too easy to scan for the right paragraph titles - the link

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Denis Koroskin
On Sun, 05 Sep 2010 19:17:55 +0400, bearophile bearophileh...@lycos.com wrote: Denis Koroskin: The code above should print: state saved state restored (not tested) On Windows, dmd 2.048, this code: import std.c.stdio: puts; version (Windows) { alias int[16] jmp_buf; extern (C)

Re: this as lvalue?

2010-09-05 Thread JMRyan
Andrei Alexandrescu seewebsiteforem...@erdani.org wrote in news:i5rovm$1q4...@digitalmars.com: For classes this must be an rvalue. Andrei I reported this as issue 4819.

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread bearophile
Denis Koroskin: Turn main into an extern(C) int main() and it works. This version: import std.c.stdio: puts; version (Windows) { alias int[16] jmp_buf; extern (C) extern { int setjmp(ref jmp_buf env); void longjmp(ref jmp_buf env, int value); } } struct State {

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Denis Koroskin
On Sun, 05 Sep 2010 20:18:13 +0400, bearophile bearophileh...@lycos.com wrote: Denis Koroskin: Turn main into an extern(C) int main() and it works. This version: import std.c.stdio: puts; version (Windows) { alias int[16] jmp_buf; extern (C) extern { int setjmp(ref

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Andrei Alexandrescu
On 09/05/2010 09:30 AM, Philippe Sigaud wrote: On Sun, Sep 5, 2010 at 15:56, Andrei Alexandrescu seewebsiteforem...@erdani.org mailto:seewebsiteforem...@erdani.org wrote: equivalent to the problem: auto solution = comp!([a,b], a*b == 8)([1,2,3], [4,5,6]); solution is

Re: [Challenge] implementing the ambiguous operator in D

2010-09-05 Thread Simen kjaeraas
Philippe Sigaud philippe.sig...@gmail.com wrote: But the real challenge in the SO question is the 'going back in time' part, which I have trouble to understand : how can you modify x and y through a multiplication and a comparison? I believe this to be possible, though horrible and

Purity in Java D

2010-09-05 Thread bearophile
A paper I've recently read: Verifiable Functional Purity in Java, by Matthew Finifter, Adrian Mettler, Naveen Sastry and David Wagner: http://www.cs.berkeley.edu/~finifter/pure-ccs08.pdf At page 12 it says some things about D2 too (this article is not updated to the last changes in D2): In

Re: Bug 3999 and 4261

2010-09-05 Thread bearophile
Don: That's impossible. That would make interfacing to C a nightmare. I see. By the way, enums which consist of flags frequently have values which have more than one bit set. The case { A=1, B=2, C=4, D=8 } is only a special case. That indeed happens, but from the code that I have seen

Re: Please comment on http://d-programming-language.org/

2010-09-05 Thread Walter Bright
David Gileadi wrote: Sorry, I think it's going to stay static HTML: the website is generated using DDoc macros and I believe Walter is unlikely to want to go in any other direction. Yes, because static HTML makes the pages load fast. There are a lot of web sites out there with dynamic

Re: this as lvalue?

2010-09-05 Thread Andrej Mitrovic
Does this mean assigning to fields won't be an option anymore when using this? E.g.: class Foo { int x; int y; void changeXY(int x, int y) { this.x = x; this.y = y; } } On Sun, Sep 5, 2010 at 6:09 PM, JMRyan nos...@nospam.com wrote: Andrei Alexandrescu

Re: this as lvalue?

2010-09-05 Thread Andrej Mitrovic
Gmail likes to eat my code for some reason, it just ate two closing parantheses.. lol. On Mon, Sep 6, 2010 at 12:02 AM, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Does this mean assigning to fields won't be an option anymore when using this? E.g.: class Foo {    int x;    int y;  

Re: this as lvalue?

2010-09-05 Thread Jonathan M Davis
On Sunday 05 September 2010 15:02:10 Andrej Mitrovic wrote: Does this mean assigning to fields won't be an option anymore when using this? E.g.: class Foo { int x; int y; void changeXY(int x, int y) { this.x = x; this.y = y; } } No, it simply

Re: Purity in Java D

2010-09-05 Thread Simen kjaeraas
bearophile bearophileh...@lycos.com wrote: class or instance immutability is necessary to ensure determinism in a concurrent program, as otherwise a mutable alias can be used to concurrently modify the object. That's the price of being a systems language - it is possible to subvert the type

Re: this as lvalue?

2010-09-05 Thread Andrej Mitrovic
Ok, thanks. I never liked the lvalue rvalue names.. For example http://en.wikipedia.org/wiki/Value_%28computer_science%29 l-value, non-lvalue, rvalue, nonlvalue.. bleh. It's the same thing as when I see mutable, non-immutable, non-mutable, immutable sprinkled with a few tripple negatives all

Re: Purity in Java D

2010-09-05 Thread bearophile
Simen kjaeraas: So it is basically exactly like D, only no mutable global state? It's similar, of couse. I think there is no 'pure' tag, the compiler infers if a method is pure on the base of its arguments. In D even a function that is technically pure is not seen as pure of you don't tag it

Re: Purity in Java D

2010-09-05 Thread Jonathan M Davis
On Sunday 05 September 2010 16:59:19 bearophile wrote: Simen kjaeraas: So it is basically exactly like D, only no mutable global state? It's similar, of couse. I think there is no 'pure' tag, the compiler infers if a method is pure on the base of its arguments. In D even a function that is

Re: this as lvalue?

2010-09-05 Thread Andrei Alexandrescu
On 09/05/2010 05:02 PM, Andrej Mitrovic wrote: Does this mean assigning to fields won't be an option anymore when using this? E.g.: class Foo { int x; int y; void changeXY(int x, int y) { this.x = x; this.y = y; } } No, guys, most everything will

Re: Purity in Java D

2010-09-05 Thread Walter Bright
Jonathan M Davis wrote: Having the compiler determine purity would be cool, but it runs into a few of problems. The most serious one I can think of is: Suppose you are depending on a function being pure. If the compiler determines its purity, it *does not tell you* if it is impure. Your code

Re: Purity in Java D

2010-09-05 Thread Simen kjaeraas
Walter Bright newshou...@digitalmars.com wrote: Jonathan M Davis wrote: Having the compiler determine purity would be cool, but it runs into a few of problems. The most serious one I can think of is: Suppose you are depending on a function being pure. If the compiler determines its

Re: this as lvalue?

2010-09-05 Thread bearophile
Andrei: If you can write (new Foo).x = x, then you can also write this.x = x. Try it now! See my bug reports/enhancement requests (about three days ago in a program of mine I have added a bug that enhancement 4407 is able to avoid): Arguments and attributes with the same name

Re: Purity in Java D

2010-09-05 Thread bearophile
Walter Bright: The most serious one I can think of is: Just to be sure: in my original post of this thread I have not asked to change D. I was just showing a paper. Bye, bearophile

Re: this as lvalue?

2010-09-05 Thread Andrej Mitrovic
++ on that bug report. On a similar note, today I was rewriting a dsource class example because I wanted to show that you can use this.name to assign to fields that have the same name as a parameter. And then I accidentally made this mistake when writing a different method: class Foo {

Cloning in D

2010-09-05 Thread dsimcha
I've started playing around with Orange a little to see whether it would meet D's cloning needs. IMHO one must-have feature for proper cloning that truly just works is full aliasing preservation. For example, the following code modified slightly from the Orange example doesn't work properly:

Bikeshedding fun: suggest a name for 64 bit Phobos library

2010-09-05 Thread Walter Bright
We already have: libphobos.a Phobos 1, 32 bit libphobos2.a Phobos 2, 32 bit What should the 64 bit Phobos be named?

Re: Bikeshedding fun: suggest a name for 64 bit Phobos library

2010-09-05 Thread Brad Roberts
On 9/5/2010 9:39 PM, Walter Bright wrote: We already have: libphobos.a Phobos 1, 32 bit libphobos2.a Phobos 2, 32 bit What should the 64 bit Phobos be named? No change in name, change in directory holding it. ie.. lib64/libphobos* That's what most major distributions do. For

CMake for D2 ready for testers

2010-09-05 Thread SK
Why labor over buggy Makefiles when you could be laboring over buggy CMake files at a much more productive level of abstraction? :o) With excellent help from Jens Mueller and Dean Calver, CMake for D2 now passes our small suite of unit tests on both Windows and Linux. Our tests include mixed C-D

Re: Generic collection/element function signatures in D2 versus D1

2010-09-05 Thread BLS
On 05/09/2010 02:16, Jonathan M Davis wrote: void foo(T)(T[] collection, T elem) { // Blah, whatever } I am curious, how this will look and feel once inout is working ? inout void foo(T)(inout(T)[] collection, inout T elem) { // Blah, whatever} }

Re: Synchronized methods in D2

2010-09-05 Thread Jacob Carlborg
On 2010-09-05 02:18, Jonathan M Davis wrote: On Saturday 04 September 2010 12:06:23 Era Scarecrow wrote: I'm currently porting a D1 code base to D2 which has the following class hierarchy: interface Map { void clear (); } class Hashtable : Map { synchronized void clear () {}; }

Re: Synchronized methods in D2

2010-09-05 Thread Jacob Carlborg
On 2010-09-04 21:06, Era Scarecrow wrote: I'm currently porting a D1 code base to D2 which has the following class hierarchy: interface Map { void clear (); } class Hashtable : Map { synchronized void clear () {}; } class HashMap : Map { void clear () {}; } When I compiler

Re: Synchronized methods in D2

2010-09-05 Thread bearophile
Jonathan M Davis: Also, according to TDPL, either your _entire class_ is synchronized, or none of it is. So, synchronized really belongs on the class, not the function, and I wouldn't expect it to compile if only a portion of your functions are synchronized (though I don't know how close

Re: Synchronized methods in D2

2010-09-05 Thread Era Scarecrow
Jonathan M Davis: Also, according to TDPL, either your _entire class_ is synchronized, or none of it is. So, synchronized really belongs on the class, not the function, and I wouldn't expect it to compile if only a portion of your functions are synchronized (though I don't know how

forks/pipes and std.socket

2010-09-05 Thread Nick Sabalausky
This may be a stupid question: Does std.socket encorporate or replace pipe usage? Ie, if I'm going to do something along the lines of (psuedo-code): auto parentToChild = pipe(); auto childToParent = pipe(); if(fork()) { // talk to other process } else { // talk to other process } Is

Fast temporary dynamic arrays? (And slicing of them)

2010-09-05 Thread Tom Kazimiers
Hi all, so I have started to look at D and dug through the documentation, but could not get a good answer on the following: How can I have a (temporary) dynamic array on stack and make references to it (no copying)? I successively put integers in an array (but don't know how much there will be

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-05 Thread bearophile
Tom Kazimiers: How can I have a (temporary) dynamic array on stack and make references to it (no copying)? I successively put integers in an array (but don't know how much there will be in advance) with an appender!(int[]) and get the date out with appender.data(). Later on I pass the result

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-05 Thread Jonathan M Davis
On Sunday 05 September 2010 18:02:29 Tom Kazimiers wrote: Hi all, so I have started to look at D and dug through the documentation, but could not get a good answer on the following: How can I have a (temporary) dynamic array on stack and make references to it (no copying)? I successively

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-05 Thread bearophile
My first test shows that it may work. But I have to grow the array backwards, and push back the array start, because that's how my stack grows (using alloca to allocate geometrically bigger chunks). So unless you want to reverse the items once the array is built, you have to change the

[Issue 4815] New: CodeView: Global and Static symbols should have unmangled names

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4815 Summary: CodeView: Global and Static symbols should have unmangled names Product: D Version: unspecified Platform: Other OS/Version: Windows Status: NEW

[Issue 4816] New: template constraint and __traits(compiles, ...) don't work properly together with a delegate

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4816 Summary: template constraint and __traits(compiles, ...) don't work properly together with a delegate Product: D Version: D2 Platform: Other OS/Version: Linux

[Issue 4817] New: CodeView: Enum members should have simple names

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4817 Summary: CodeView: Enum members should have simple names Product: D Version: unspecified Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority:

[Issue 4009] OPTLINK ruins the day yet again

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4009 --- Comment #10 from Walter Bright bugzi...@digitalmars.com 2010-09-05 03:28:45 PDT --- The overflow would happen when some of the data structures exceeded 128K in size. I checked the other seg faults for optlink in Bugzilla, but those

[Issue 4818] New: Taking address of shared member function - unshared delegate

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4818 Summary: Taking address of shared member function - unshared delegate Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity:

[Issue 4821] New: std.array.insert on string[]

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4821 Summary: std.array.insert on string[] Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal

[Issue 2943] Struct copying in presence of alias member this only copies alias this member

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2943 --- Comment #4 from Serg Kovrov kovrov+purema...@gmail.com 2010-09-05 09:16:32 PDT --- I do. As stated in comment for Bug 3135#c1 - an empty postblit function seem to workaround the issue.. -- Configure issuemail:

[Issue 2943] Struct copying in presence of alias member this only copies alias this member

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2943 --- Comment #5 from David Simcha dsim...@yahoo.com 2010-09-05 09:52:19 PDT --- (In reply to comment #3) doesn't anyone use alias this? I mostly don't, but only b/c it's currently so buggy it's not even funny. I just looked, I myself have

[Issue 4822] New: Problem with std.stdio.File.writef(%c

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4822 Summary: Problem with std.stdio.File.writef(%c Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal

[Issue 4823] New: CodeView: Thread local variables are stored as shared globals

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4823 Summary: CodeView: Thread local variables are stored as shared globals Product: D Version: unspecified Platform: Other OS/Version: Windows Status: NEW

[Issue 4824] New: stopwatch unit tests fail intermitently

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4824 Summary: stopwatch unit tests fail intermitently Product: D Version: D2 Platform: Other OS/Version: All Status: NEW Severity: normal Priority: P2

[Issue 4825] Error: non-constant expression with -inline

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4825 --- Comment #1 from nfx...@gmail.com 2010-09-05 15:46:57 PDT --- I have to add that this bug triggers even when the const int... line on function c is in a different function in a different module. This makes it a very non-obvious bug, where

[Issue 4795] druntime demangler unittests fail

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4795 Brad Roberts bra...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED

[Issue 4797] onOutOfMemoryError in dmd unit test causes segv

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4797 Brad Roberts bra...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED

[Issue 4826] New: cannot create associative array and compiler crash

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4826 Summary: cannot create associative array and compiler crash Product: D Version: D2 Platform: x86_64 OS/Version: Linux Status: NEW Severity: normal Priority: P2

[Issue 4826] cannot create associative array and compiler crash

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4826 --- Comment #1 from brian-sch...@cox.net 2010-09-05 19:29:53 PDT --- Here's the code that fails: The second opIndexAssign is written this way because of bug 2972. module testcase; struct SomeStruct { void opIndexAssign(T)(T[string] value,

[Issue 4826] cannot create associative array and compiler crash

2010-09-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4826 --- Comment #2 from brian-sch...@cox.net 2010-09-05 19:34:48 PDT --- (In reply to comment #1) That should have been: void opIndexAssign(T)(T value, string key) if(is(T : SomeStruct)) { } But the error is the same either way. Bugzilla needs