Re: [challenge] Linker surgery

2013-05-17 Thread Rainer Schuetze
On 18.05.2013 00:47, Igor Stepanov wrote: On Friday, 17 May 2013 at 17:57:54 UTC, Rainer Schuetze wrote: On 17.05.2013 14:29, Dmitry Olshansky wrote: 15-May-2013 04:17, IgorStepanov пишет: Do this table linked, if you remove all functions, which use it? Thanks for this try, but they DO l

Re: [challenge] Linker surgery

2013-05-17 Thread Rainer Schuetze
On 18.05.2013 00:49, Dmitry Olshansky wrote: 17-May-2013 21:57, Rainer Schuetze пишет: On 17.05.2013 14:29, Dmitry Olshansky wrote: 15-May-2013 04:17, IgorStepanov пишет: Do this table linked, if you remove all functions, which use it? Thanks for this try, but they DO link in always. And

Re: Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

2013-05-17 Thread Maxim Fomin
On Saturday, 18 May 2013 at 02:34:46 UTC, Andrej Mitrovic wrote: On 5/18/13, Timothee Cour wrote: S.init should be known at compile time by the spec. But why is this needed? It is needed in any place where such object is created due to default initialization. However if default ctor is CTF

Re: Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

2013-05-17 Thread Andrej Mitrovic
On 5/18/13, Timothee Cour wrote: > S.init should be known at compile time by the spec. But why is this needed?

Re: Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

2013-05-17 Thread Timothee Cour
calling the default ctor static this() removes any such illusion. struct A{ int[]x; static this(){ x=[1,2,3]; } } void main(){ enum a=A.init; static assert(a is A.init); } would work under this proposal. What would be your alternate proposal that would still allow to initialize x to [1,2,

Re: Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

2013-05-17 Thread Igor Stepanov
When programmer see constructor, he think that it will be evaluated each time when he create a new object. This code will seem obvious for any C++ coder. And this coder will be deceived. If we'll add default constructor to structs, we'll must safe of illusion, that constructor is called any tim

Re: Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

2013-05-17 Thread Timothee Cour
>> But there is one trouble. I don't see the trouble. struct Foo > { > int[] arr; > this()//can be interpreted at compile time > { >arr = new int[3]; >arr[0] = 1; >arr[1] = 2; >arr[2] = 3; > } > } > semantically, all new instances of Foo must get se

Re: [challenge] Linker surgery

2013-05-17 Thread Igor Stepanov
module fmod; public immutable int[] fable = [1,2,3]; module mod; //import fmod; int foo(int i) { pragma(mangle, "_D4fmod5fableyAi") extern immutable int[] fable; return fable[i]; }

Re: Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

2013-05-17 Thread Igor Stepanov
On Friday, 17 May 2013 at 22:45:01 UTC, Timothee Cour wrote: Although I agree that having a default constructor would be convenient, I think the problem is that S.init should be known at compile time by the spec. Maybe we could support the following syntax, with a static this instead of this

Re: [challenge] Linker surgery

2013-05-17 Thread Igor Stepanov
And how then I would use these tables if even importing these modules then pulls in the data? without import with pragma(mangle) help. But this dark linker magic no much better you template solution.

Re: Writing a unit test for a singleton implementation

2013-05-17 Thread Idan Arye
On Friday, 17 May 2013 at 21:06:30 UTC, Diggory wrote: I think we all understand it's not going to catch every race condition, or even a given race condition every time, ie. it can't prove that the code is correct. What it can do however is prove that code is incorrect. If the unit test fails

Re: [challenge] Linker surgery

2013-05-17 Thread Dmitry Olshansky
17-May-2013 21:57, Rainer Schuetze пишет: On 17.05.2013 14:29, Dmitry Olshansky wrote: 15-May-2013 04:17, IgorStepanov пишет: Do this table linked, if you remove all functions, which use it? Thanks for this try, but they DO link in always. And I believe this is a key problem - each function

Re: [challenge] Linker surgery

2013-05-17 Thread Igor Stepanov
On Friday, 17 May 2013 at 17:57:54 UTC, Rainer Schuetze wrote: On 17.05.2013 14:29, Dmitry Olshansky wrote: 15-May-2013 04:17, IgorStepanov пишет: Do this table linked, if you remove all functions, which use it? Thanks for this try, but they DO link in always. And I believe this is a key pr

Re: Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

2013-05-17 Thread Timothee Cour
Although I agree that having a default constructor would be convenient, I think the problem is that S.init should be known at compile time by the spec. Maybe we could support the following syntax, with a static this instead of this : struct S { int x=11; int y = void; static this()

Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

2013-05-17 Thread Andrej Mitrovic
On 5/17/13, Walter Bright wrote: > I oppose this. D has a lot of nice features because of the .init property. > Default constructors wreck that. Would they? I'm thinking the process would be: struct S { int x; int y = void; this() // hypothetical { // x would already be

Re: Writing a unit test for a singleton implementation

2013-05-17 Thread Diggory
I think we all understand it's not going to catch every race condition, or even a given race condition every time, ie. it can't prove that the code is correct. What it can do however is prove that code is incorrect. If the unit test fails there is definitely something wrong with the code, the

Re: Writing a unit test for a singleton implementation

2013-05-17 Thread Idan Arye
On Friday, 17 May 2013 at 10:16:21 UTC, Dmitry Olshansky wrote: Can you show the code actually - bogus singleton and correct one? Here: https://gist.github.com/someboddy/5601276 I thinned down the implementation to a minimum working example. `enum BREAK_IMPLEMENTATION` at the top of the file d

Re: rename our github organization?

2013-05-17 Thread Brad Anderson
On Sunday, 12 May 2013 at 15:08:22 UTC, Andrei Alexandrescu wrote: I'm thinking we should rename D-programming-language on github with dlang. While we're at it, project d-programming-language.org should be renamed dlang.org. This may cause disruption. Thoughts? Andrei I suggest renaming the

Re: [challenge] Linker surgery

2013-05-17 Thread Rainer Schuetze
On 17.05.2013 14:29, Dmitry Olshansky wrote: 15-May-2013 04:17, IgorStepanov пишет: Do this table linked, if you remove all functions, which use it? Thanks for this try, but they DO link in always. And I believe this is a key problem - each function goes into a separate object but globals ar

Re: primitive value overflow

2013-05-17 Thread Ary Borenszweig
On 5/16/13 5:24 PM, luka8088 wrote: Hello everyone. Today I ran into a interesting issue. I wrote auto offset = text1.length - text2.length; and in case text2 was longer then text1 I got something around 4294967291. So I opened an issue: http://d.puremagic.com/issues/show_bug.cgi?id=10093

Re: rename our github organization?

2013-05-17 Thread Mr. Anonymous
On Sunday, 12 May 2013 at 15:08:22 UTC, Andrei Alexandrescu wrote: I'm thinking we should rename D-programming-language on github with dlang. While we're at it, project d-programming-language.org should be renamed dlang.org. This may cause disruption. Thoughts? Andrei The URL in the descrip

Re: rename our github organization?

2013-05-17 Thread Brad Anderson
On Friday, 17 May 2013 at 15:40:40 UTC, Andrei Alexandrescu wrote: On 5/16/13 8:39 PM, Mehrdad wrote: On Sunday, 12 May 2013 at 15:08:22 UTC, Andrei Alexandrescu wrote: I'm thinking we should rename D-programming-language on github with dlang. While we're at it, project d-programming-language.o

Re: rename our github organization?

2013-05-17 Thread Andrei Alexandrescu
On 5/16/13 8:39 PM, Mehrdad wrote: On Sunday, 12 May 2013 at 15:08:22 UTC, Andrei Alexandrescu wrote: I'm thinking we should rename D-programming-language on github with dlang. While we're at it, project d-programming-language.org should be renamed dlang.org. This may cause disruption. Thoughts

Re: rename our github organization?

2013-05-17 Thread Iain Buclaw
On 12 May 2013 18:29, Calin Grosan wrote: > On Sunday, 12 May 2013 at 15:08:22 UTC, Andrei Alexandrescu wrote: > >> I'm thinking we should rename D-programming-language on github with >> dlang. While we're at it, project d-programming-language.org should be >> renamed dlang.org. >> >> This may ca

Re: rename our github organization?

2013-05-17 Thread Andrei Alexandrescu
On 5/16/13 9:18 PM, Andrej Mitrovic wrote: Also please rename the d-programming-language.org *project* into dlang.org if you can. (the website files) Probably that's the only thing I'll end up renaming for now. Andrei

Re: Array void init

2013-05-17 Thread Steven Schveighoffer
On Fri, 17 May 2013 02:46:31 -0400, Stewart Gordon wrote: On 27/04/2013 06:29, Steven Schveighoffer wrote: Have you considered what this does? Consider a standard [1.0, 2.0] call: In essence, it pushes 1.0 and 2.0 onto the stack, then calls a function to allocate the memory and use the

Re: Binding D to C

2013-05-17 Thread Regan Heath
On Fri, 17 May 2013 13:53:20 +0100, Jacob Carlborg wrote: On 2013-05-17 10:46, Regan Heath wrote: On Fri, 17 May 2013 08:44:14 +0100, Jacob Carlborg wrote: .. lots of great things. Can we get all the advice from the article and these replies onto a D wiki or howto page pls. If someone can

Re: Binding D to C

2013-05-17 Thread Jacob Carlborg
On 2013-05-17 10:46, Regan Heath wrote: On Fri, 17 May 2013 08:44:14 +0100, Jacob Carlborg wrote: .. lots of great things. Can we get all the advice from the article and these replies onto a D wiki or howto page pls. If someone can point me to where to add it, I can do a rough copy/paste. As

Re: [challenge] Linker surgery

2013-05-17 Thread Dmitry Olshansky
15-May-2013 04:17, IgorStepanov пишет: Do this table linked, if you remove all functions, which use it? Thanks for this try, but they DO link in always. And I believe this is a key problem - each function goes into a separate object but globals are always pulled in! Anyone ever used digits,

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread Samuel Lampa
On 05/17/2013 11:41 AM, Jonathan M Davis wrote: We need to do more to optimize Phobos, but given our stance of correctness by default, we're kind of stuck with string functions taking a performance hit in a number of common cases simply due to the necessary decoding of code points. We can do bett

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread John Colvin
On Friday, 17 May 2013 at 11:26:27 UTC, deadalnix wrote: On Friday, 17 May 2013 at 10:09:11 UTC, John Colvin wrote: If naive D code has to be significantly faster than optimised C for people to not go "D sucks, it's only as fast as python" then we're pretty much doomed by peoples stupidity. N

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread deadalnix
On Friday, 17 May 2013 at 10:09:11 UTC, John Colvin wrote: If naive D code has to be significantly faster than optimised C for people to not go "D sucks, it's only as fast as python" then we're pretty much doomed by peoples stupidity. No. The whole benefit of D is lost if you have to tweak ev

Re: Writing a unit test for a singleton implementation

2013-05-17 Thread Dmitry Olshansky
17-May-2013 04:57, Idan Arye пишет: On Thursday, 16 May 2013 at 21:10:52 UTC, Dmitry Olshansky wrote: 16-May-2013 02:21, Idan Arye пишет: But I *want* to (almost)cause a race condition here You can't "cause" a race condition - it's there by definition of code. What you can cause is a data cor

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread John Colvin
On Friday, 17 May 2013 at 08:28:38 UTC, Jacob Carlborg wrote: On 2013-05-16 21:54, Walter Bright wrote: We should also be aware that while Python code itself is slow, its library functions are heavily optimized C code. So, if the benchmark consists of calling a Python library function, it'll r

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread Jonathan M Davis
On Thursday, May 16, 2013 12:54:35 Walter Bright wrote: > On 5/16/2013 12:15 PM, Jonathan M Davis wrote: > > And if python is faster than > > D at something, odds are that either the code in question is poorly > > written or that whatever Phobos functions it's using haven't been > > properly optimi

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread Jonathan M Davis
On Friday, May 17, 2013 11:15:24 Dicebot wrote: > On Thursday, 16 May 2013 at 19:15:57 UTC, Jonathan M Davis wrote: > > 1. In general, if you want to operate on ASCII, and you want > > your code to be > > fast, use immutable(ubyte)[], not immutable(char)[]. Obviously, > > that's not > > gonig to wo

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread Dicebot
On Thursday, 16 May 2013 at 19:15:57 UTC, Jonathan M Davis wrote: 1. In general, if you want to operate on ASCII, and you want your code to be fast, use immutable(ubyte)[], not immutable(char)[]. Obviously, that's not gonig to work in this case, because the function is in std.string, but maybe

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread Dicebot
On Thursday, 16 May 2013 at 14:23:22 UTC, nazriel wrote: Very nice blog post. Something similar should go into D wiki database so it won't get lost in "In 80s we had..." topics. For sure there is a space for improvements in Phobos but such articles are good start to prevent wave of "D is slo

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread Dicebot
On Thursday, 16 May 2013 at 13:52:01 UTC, Juan Manuel Cabo wrote: ... Thanks for the tool, it is a good one. But I was not doing benchmarks this time, only cared about 2x difference at least, so "time" was enough :)

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread Dicebot
On Thursday, 16 May 2013 at 13:48:45 UTC, Juan Manuel Cabo wrote: On Thursday, 16 May 2013 at 10:35:12 UTC, Dicebot wrote: Want to bring into discussion people that are not on Google+. Samuel recently has posted there some simple experiments with bioinformatics and bad performance of Phobos-bas

Re: Binding D to C

2013-05-17 Thread Regan Heath
On Fri, 17 May 2013 08:44:14 +0100, Jacob Carlborg wrote: .. lots of great things. Can we get all the advice from the article and these replies onto a D wiki or howto page pls. If someone can point me to where to add it, I can do a rough copy/paste. Assuming both authors are happy with

Re: primitive value overflow

2013-05-17 Thread Regan Heath
On Thu, 16 May 2013 23:23:20 +0100, Marco Leise wrote: Am Thu, 16 May 2013 22:39:16 +0200 schrieb luka8088 : On 16.5.2013. 22:29, Andrej Mitrovic wrote: > On Thursday, 16 May 2013 at 20:24:31 UTC, luka8088 wrote: >> Hello everyone. >> >> Today I ran into a interesting issue. I wrote >> >> aut

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread Dicebot
On Thursday, 16 May 2013 at 11:37:14 UTC, bearophile wrote: Dicebot: In the first of his posts I don't see -noboundscheck used, and it compares different algorithms from C++ (a switch) and D (two nested ifs, that are not optimal). From my experience if you have some care you are able to write

Re: Investigation: downsides of being generic and correct

2013-05-17 Thread Jacob Carlborg
On 2013-05-16 21:54, Walter Bright wrote: We should also be aware that while Python code itself is slow, its library functions are heavily optimized C code. So, if the benchmark consists of calling a Python library function, it'll run as fast as any optimized C code. But someone using Python w

Re: Binding D to C

2013-05-17 Thread Jacob Carlborg
On 2013-05-16 02:37, Walter Bright wrote: http://www.gamedev.net/page/resources/_/technical/game-programming/binding-d-to-c-r3122 http://www.reddit.com/r/programming/comments/1eerd9/binding_d_to_c/ https://news.ycombinator.com/newest It's a good article. I haven't read it completely to the e