Re: Linking 2 c++ libraries with D

2013-06-27 Thread Juan Manuel Cabo
On 06/27/2013 10:12 PM, Milvakili wrote: I have successfully link c++ with D. Have ever when I create a dependency: cpp2-cpp1-d when compile with dmd dmd cpp1.a cpp2.a file.d -L-lstdc++ I tried it and it works _perfectly_ for me, but instead of .a I compiled the C++ files to .o

Re: D vs Haskell

2013-06-23 Thread Juan Manuel Cabo
On 06/23/2013 05:42 AM, Joseph Rushton Wakeling wrote: On Saturday, 22 June 2013 at 21:45:48 UTC, Juan Manuel Cabo wrote: Right, the author of the article used ldc. I'm always used to dmd. You know that you can use ldmd2 to invoke LDC using the same flags as DMD? This time I used LDC

Re: fun project - improving calcHash

2013-06-23 Thread Juan Manuel Cabo
On 06/23/2013 06:22 PM, Walter Bright wrote: https://github.com/D-Programming-Language/dmd/blob/master/src/root/stringtable.c#L21 Profiling shows the calcHash function is a significant contributor to compilation time (3.25% of total time). So making it faster is a win. Even making dmd 1%

Re: fun project - improving calcHash

2013-06-23 Thread Juan Manuel Cabo
On 06/23/2013 09:20 PM, Juan Manuel Cabo wrote: On 06/23/2013 06:22 PM, Walter Bright wrote: https://github.com/D-Programming-Language/dmd/blob/master/src/root/stringtable.c#L21 Profiling shows the calcHash function is a significant contributor to compilation time (3.25% of total time). So

Re: D vs Haskell

2013-06-22 Thread Juan Manuel Cabo
On 06/22/2013 03:25 PM, Szymon Gatner wrote: Word counting problem in D and Haskell: http://leonardo-m.livejournal.com/109201.html I thought that the D time could be improved further with little changes. Testing against Complete Works of William Shakespeare (5.3 MiB plaintext):

Re: D vs Haskell

2013-06-22 Thread Juan Manuel Cabo
On 06/22/2013 06:29 PM, Joseph Rushton Wakeling wrote: On 06/22/2013 10:11 PM, Juan Manuel Cabo wrote: Testing against Complete Works of William Shakespeare (5.3 MiB plaintext): http://www.gutenberg.org/ebooks/100 and using dmd -O -inline -noboundscheck -release on both the last version

Re: DConf 2013 Day 3 Talk 1: Metaprogramming in the Real World by Don Clugston

2013-06-12 Thread Juan Manuel Cabo
On 06/11/2013 09:33 AM, Andrei Alexandrescu wrote: Reddit: http://www.reddit.com/r/programming/comments/1g47df/dconf_2013_metaprogramming_in_the_real_world_by/ Hackernews: https://news.ycombinator.com/item?id=5861237 Twitter: https://twitter.com/D_Programming/status/344431490257526785

Re: DConf 2013 Day 2 Talk 5: A Precise Garbage Collector for D by Rainer Schütze

2013-06-12 Thread Juan Manuel Cabo
On 06/05/2013 10:23 AM, Andrei Alexandrescu wrote: Reddit: http://www.reddit.com/r/programming/comments/1fpw2r/dconf_2013_day_2_talk_5_a_precise_garbage/ Hackernews: https://news.ycombinator.com/item?id=5825320 Twitter: https://twitter.com/D_Programming/status/342269600689430529

Re: DConf 2013 Day 2 Talk 5: A Precise Garbage Collector for D by Rainer Schütze

2013-06-12 Thread Juan Manuel Cabo
On 06/05/2013 10:23 AM, Andrei Alexandrescu wrote: Reddit: http://www.reddit.com/r/programming/comments/1fpw2r/dconf_2013_day_2_talk_5_a_precise_garbage/ Hackernews: https://news.ycombinator.com/item?id=5825320 Twitter: https://twitter.com/D_Programming/status/342269600689430529

Re: xUnit Testing Framework for D

2013-06-12 Thread Juan Manuel Cabo
On 06/12/2013 07:15 PM, Mario Kroeplin wrote: Here is the 'dunit' mentioned in the talk by Stefan Rohe: https://github.com/linkrope/dunit D-stroy ;-) I'm glad that dunit was of use to you and that the fork went well. I'm sorry I couldn't follow up on it. --jm

Re: Low hanging fruit for optimizing loops

2013-06-08 Thread Juan Manuel Cabo
On Saturday, 8 June 2013 at 05:11:11 UTC, Walter Bright wrote: On 6/7/2013 9:15 PM, Juan Manuel Cabo wrote: Given the recent surge in interest for performance, I dusted off a small test that I made long ago and determined myself to find the cause of the performance difference. It's great

Low hanging fruit for optimizing loops

2013-06-07 Thread Juan Manuel Cabo
Given the recent surge in interest for performance, I dusted off a small test that I made long ago and determined myself to find the cause of the performance difference. I tested the linear version of fibonacci both in DMD and in C with GCC. Without optimization switches, I'm happy to see that

Re: DConf 2013 Day 2 Talk 3: C# to D by Adam Wilson

2013-05-31 Thread Juan Manuel Cabo
On 05/31/2013 09:33 AM, Andrei Alexandrescu wrote: http://www.reddit.com/r/programming/comments/1feem1/dconf_2013_day_2_talk_3_from_c_to_d_by_adam_wilson/ {Enj,Destr}oy! Andrei Just watched it over lunch and I liked this talk very much. For transforming pieces of code I very often write

Re: DConf 2013 Day 2 Talk 3: C# to D by Adam Wilson

2013-05-31 Thread Juan Manuel Cabo
On 05/31/2013 05:18 PM, Nick Sabalausky wrote: On Fri, 31 May 2013 15:29:40 +0100 Regan Heath re...@netmail.co.nz wrote: I have old SHA etc hashing routines in old style D, this makes me want to spend some time bringing them up to date... http://dlang.org/phobos/std_digest_sha.html

Re: DConf 2013 Day 2 Talk 3: C# to D by Adam Wilson

2013-05-31 Thread Juan Manuel Cabo
On 05/31/2013 03:42 PM, Steven Schveighoffer wrote: [..] I would love to say that I have set aside enough time to do it, but it's very difficult to find the time :( I hate to commit to a certain time frame, I have done that here in the past and have been very wrong with my expectations.

Re: Slow performance compared to C++, ideas?

2013-05-31 Thread Juan Manuel Cabo
On 05/31/2013 10:27 PM, Jonathan M Davis wrote: On Saturday, June 01, 2013 09:04:50 Manu wrote: **applause** Someone other than me said it, out loud! This is a magnificent day! :) Well, the discussions at dconf convinced me. Certainly, at this point, I think that the only semi-viable

Re: Slow performance compared to C++, ideas?

2013-05-31 Thread Juan Manuel Cabo
On 05/31/2013 10:27 PM, Jonathan M Davis wrote: On Saturday, June 01, 2013 09:04:50 Manu wrote: **applause** Someone other than me said it, out loud! This is a magnificent day! :) Well, the discussions at dconf convinced me. Certainly, at this point, I think that the only semi-viable

Re: Slow performance compared to C++, ideas?

2013-05-30 Thread Juan Manuel Cabo
On 05/30/2013 11:31 PM, finalpatch wrote: Hi Walter, Thanks for the reply. I have already tried these flags. However, DMD's codegen is lagging behind GCC and LLVM at the moment, so even with these flags, the runtime is ~10x longer than the C++ version compiled with clang++ (2sec with DMD,

Re: Slow performance compared to C++, ideas?

2013-05-30 Thread Juan Manuel Cabo
On 05/31/2013 12:45 AM, finalpatch wrote: Hi FeepingCreature, Thanks for the tip, getting rid of the array constructor helped a lot, Runtime is down from 800+ms to 583ms (with LDC, still cannot match C++ though). Maybe I should get rid of all arrays and use hardcoded x,y,z member

Re: Slow performance compared to C++, ideas?

2013-05-30 Thread Juan Manuel Cabo
On 05/31/2013 02:15 AM, nazriel wrote: On Friday, 31 May 2013 at 01:26:13 UTC, finalpatch wrote: Recently I ported a simple ray tracer I wrote in C++11 to D. Thanks to the similarity between D and C++ it was almost a line by line translation, in other words, very very close. However, the D

Re: DLang Spec rewrite (?)

2013-05-26 Thread Juan Manuel Cabo
On Sunday, 26 May 2013 at 08:09:16 UTC, Borden wrote: [...] My 'complaint' - although I would prefer to have my observations about difficulties working with a markup system be called 'observations' - is that the current body of text files which comprise the DLang spec source cannot be easily

Re: New UTF-8 stride function

2013-05-26 Thread Juan Manuel Cabo
On Sunday, 26 May 2013 at 20:49:36 UTC, Dmitry Olshansky wrote: [..] Thus I encourage curious folks to measure/analyze it and report back (don't forget to include your processor model). [..] Ok, I just tested on my old trusty linux 64bit (Ubuntu 12.04). I had to download those *wiki* files

Re: New UTF-8 stride function

2013-05-26 Thread Juan Manuel Cabo
And these are the results for the same linux 64bit system but compiling with -m32: $ dmd -m32 -O -inline -release -noboundscheck fast_stride.d $ for a in *wiki*; do echo ; echo $a: ; ./fast_stride $a; done arwiki-latest-all-titles-in-ns0: stride 89362 myStride 49974 myStride 51140 stride

Re: Why UTF-8/16 character encodings?

2013-05-25 Thread Juan Manuel Cabo
░ⓌⓉⒻ░ ╔╗░╔╗░╔╗╔╗╔╗░░ ║║░║║░║║╚═╗╔═╝║╔═══╝░░ ║║░║║░║║░░║║░░║╚═╗ ║╚═╝╚═╝║╔╗║║╔╗║╔═╝╔╗░░ ╚══╝╚╝╚╝╚╝╚╝░░╚╝░░ █░█░█░░▐░░▐░ █░█░█▐▀█▐▀█▐░█▐▀█▐▀█▐▀█░ █░█░█▐▄█▐▄█▐▄▀▐▄█▐░█▐░█░ █▄█▄█▐▄▄▐▄▄▐░█▐▄▄▐░█▐▄█░ --jm

Re: Why UTF-8/16 character encodings?

2013-05-25 Thread Juan Manuel Cabo
On Saturday, 25 May 2013 at 19:51:43 UTC, Joakim wrote: On Saturday, 25 May 2013 at 19:03:53 UTC, Dmitry Olshansky wrote: You can map a codepage to a subset of UCS :) That's what they do internally anyway. If I take you right you propose to define string as a header that denotes a set of

Re: DConf 2013 Day 1 Talk 6: Concurrent Garbage Collection for D by Leandro Lucarella

2013-05-24 Thread Juan Manuel Cabo
On Monday, 20 May 2013 at 12:50:23 UTC, Andrei Alexandrescu wrote: On reddit: http://www.reddit.com/r/programming/comments/1eovfu/dconf_2013_day_1_talk_6_concurrent_garbage/ Enjoy! Discuss!! Vote!!! Andrei I know that this is slightly offtopic, since the topic lately seems to be how to

Re: Problem with object understanding and datatypes

2013-05-24 Thread Juan Manuel Cabo
On Saturday, 25 May 2013 at 01:03:53 UTC, Namal wrote: 255 - 129 is less than 128 so the result is T.max, which is 255, which is not equal to 0. I dont understand this at all 255 - 129 should be 126 in ubyte or not? I checked, and operation between two ubyte is an int. When you cast

Re: Example for creating multiple signals?

2013-05-23 Thread Juan Manuel Cabo
On Thursday, 23 May 2013 at 15:22:06 UTC, Gary Willoughby wrote: I'm just looking at the signals example here: http://dlang.org/phobos/std_signals.html#.Signal where it says Different signals can be added to a class by naming the mixins.. Has anyone got an example of this please? I'd like to

Re: Ideal D GUI Toolkit

2013-05-22 Thread Juan Manuel Cabo
On Tuesday, 21 May 2013 at 07:47:56 UTC, eles wrote: On Tuesday, 21 May 2013 at 06:41:24 UTC, Jacob Carlborg wrote: On 2013-05-20 07:25, Tyler Jameson Little wrote: Here we go again, yet another massive thread about GUI toolkits :) Anyway, the thread is already started, I think the

Re: Investigation: downsides of being generic and correct

2013-05-16 Thread Juan Manuel Cabo
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-based snippet has surprised me. I did explore issue a bit and

Re: Investigation: downsides of being generic and correct

2013-05-16 Thread Juan Manuel Cabo
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-based snippet has surprised me. I did explore issue a bit and

Re: Investigation: downsides of being generic and correct

2013-05-16 Thread Juan Manuel Cabo
On Thursday, 16 May 2013 at 22:58:42 UTC, 1100110 wrote: On 05/16/2013 01:46 PM, Nick Sabalausky wrote: On Thu, 16 May 2013 09:03:36 -0500 1100110 0b1100...@gmail.com wrote: May I also recommend my tool avgtime to make simple benchmarks, instead of time (you can see an ascii histogram as the

Re: What sync object should i use?

2013-05-15 Thread Juan Manuel Cabo
On Wednesday, 15 May 2013 at 02:25:02 UTC, Heinz wrote: I have this main loop wich is named here as my consumer function. I didn't want this main loop to be cycling all the time if there was nothing to do. So i needed an event object (condition/mutex) that locked the loop until any of

Re: What sync object should i use?

2013-05-14 Thread Juan Manuel Cabo
On Tuesday, 14 May 2013 at 17:59:55 UTC, Heinz wrote: Guys, this is a precise example of what i'm trying to do. You'll notice that there're 2 ways of waking up the consumer: / Condition cond; // Previously instantiated. bool

Re: What sync object should i use?

2013-05-13 Thread Juan Manuel Cabo
On Monday, 13 May 2013 at 20:44:37 UTC, Heinz wrote: Ok, here's a summary in case someone else is in the same need: 1) Want to know what mutex/condition are, how do they work and when to use them? Here's a good resource: http://stackoverflow.com/a/4742236 2) If you come to the question Why

Re: how to instantiate explicitly template parameters in struct A(T1){this(T2)(){...}}

2013-05-13 Thread Juan Manuel Cabo
On Tuesday, 14 May 2013 at 03:34:52 UTC, Timothee Cour wrote: A) The behavior of __ctor (whether or not documented) seems broken / unreliable: struct A{this(T)(T x){}} void fun(T){ auto a=A.__ctor!(int)(1); } void main(){ auto a=A.__ctor!(int)(1); //ok fun!int(); //Error: type A is not

Re: DConf 2013 keynote

2013-05-12 Thread Juan Manuel Cabo
On Sunday, 12 May 2013 at 03:58:04 UTC, Nick Sabalausky wrote: The nicest thing of all, IMO, about not strictly needing all that support software is that basic things like editing/navigating/opening/closing code is always and forever 100% unobstructed by things like startup delays and keyboard

Re: Tricky code with exceptions

2013-05-09 Thread Juan Manuel Cabo
Tested on Linux - Kubuntu 12.04 64bits dmd 2.058 -m32 dmd 2.058 64 bits dmd 2.062 -m32 dmd 2.062 and the output is this for all of the above: Loop: 0 Loop: 1 Caught Loop: 2 Loop: 3 Caught Loop: 4 Loop: 5 Caught Then, tested on Windows

Re: Tricky code with exceptions

2013-05-09 Thread Juan Manuel Cabo
On Friday, 10 May 2013 at 01:05:39 UTC, Juan Manuel Cabo wrote: Then, tested on Windows XP SP3 32 bits, dmd 2.062, and it DIDN'T CRASH. The output is: Mm, sorry!!, it did crash but I had dr watson disabled in that VM. Confirmed adding a writeln(finished) after the foreach, which isn't

Re: Deallocate array?

2013-05-07 Thread Juan Manuel Cabo
Why isn't the memory deallocating? The memory might be free, but still not released to the OS. Especially in windows, when you free memory it still isn't freed from your process. But you can reuse it in your program if the GC has collected it. The correct test would be to copy and paste

Re: Deallocate array?

2013-05-07 Thread Juan Manuel Cabo
I found this problem with a program that reads a large xml file (25+ lines), then stores the lines in a string[], does a comparison with another array and finally clears the original array. On the second or third file I always get an OutOfMemoryError, when the Task Manager shows about

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-26 Thread Juan Manuel Cabo
On Tuesday, 27 March 2012 at 00:58:26 UTC, Ary Manzana wrote: On 3/23/12 4:11 PM, Juan Manuel Cabo wrote: On Friday, 23 March 2012 at 06:51:48 UTC, James Miller wrote: Dude, this is awesome. I tend to just use time, but if I was doing anything more complicated, I'd use this. I would suggest

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-26 Thread Juan Manuel Cabo
On Thursday, 22 March 2012 at 17:13:58 UTC, Manfred Nowak wrote: Juan Manuel Cabo wrote: like the unix 'time' command `version linux' is missing. -manfred Done!, it works in windows now too. (release 0.5 in github). --jm

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-26 Thread Juan Manuel Cabo
On Tuesday, 27 March 2012 at 03:39:56 UTC, Ary Manzana wrote: On Tuesday, 27 March 2012 at 01:19:22 UTC, Juan Manuel Cabo wrote: On Tuesday, 27 March 2012 at 00:58:26 UTC, Ary Manzana wrote: On 3/23/12 4:11 PM, Juan Manuel Cabo wrote: On Friday, 23 March 2012 at 06:51:48 UTC, James Miller

Re: some regex vs std.ascii vs handcode times

2012-03-26 Thread Juan Manuel Cabo
On Monday, 26 March 2012 at 07:10:00 UTC, Jay Norwood wrote: On Thursday, 22 March 2012 at 04:29:41 UTC, Jay Norwood wrote: On the use of larger files ... yes that will be interesting, but for these current measurements the file reads are only taking on the order of 30ms for 20MB, which tells

Re: some regex vs std.ascii vs handcode times

2012-03-26 Thread Juan Manuel Cabo
On Tuesday, 27 March 2012 at 00:23:46 UTC, Juan Manuel Cabo wrote: [] I forgot to mention that for Linux Kubuntu x64 I had to put change the type of a variable to auto in this line of wcTest.d: auto c_cnt = input.length; And that in windows7 x64, the default for dmd is -m32, so I compiled

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-23 Thread Juan Manuel Cabo
On Friday, 23 March 2012 at 05:16:20 UTC, Andrei Alexandrescu wrote: [.] (man, the gaussian curve is everywhere, it never ceases to perplex me). I'm actually surprised. I'm working on benchmarking lately and the distributions I get are very concentrated around the minimum. Andrei

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-23 Thread Juan Manuel Cabo
On Thursday, 22 March 2012 at 17:13:58 UTC, Manfred Nowak wrote: Juan Manuel Cabo wrote: like the unix 'time' command `version linux' is missing. -manfred Linux only for now. Will make it work in windows this weekend. I hope that's what you meant. --jm

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-23 Thread Juan Manuel Cabo
On Friday, 23 March 2012 at 06:51:48 UTC, James Miller wrote: Dude, this is awesome. I tend to just use time, but if I was doing anything more complicated, I'd use this. I would suggest changing the name while you still can. avgtime is not that informative a name given that it now does more

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-23 Thread Juan Manuel Cabo
On Friday, 23 March 2012 at 05:51:40 UTC, Manfred Nowak wrote: | For samples, if it is known that they are drawn from a symmetric | distribution, the sample mean can be used as an estimate of the | population mode. I'm not printing the population mode, I'm printing the 'sample mode'. It

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-23 Thread Juan Manuel Cabo
On Friday, 23 March 2012 at 15:33:18 UTC, Andrei Alexandrescu wrote: On 3/23/12 3:02 AM, Juan Manuel Cabo wrote: On Friday, 23 March 2012 at 05:16:20 UTC, Andrei Alexandrescu wrote: [.] (man, the gaussian curve is everywhere, it never ceases to perplex me). I'm actually surprised. I'm

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-23 Thread Juan Manuel Cabo
On Friday, 23 March 2012 at 10:51:37 UTC, Don Clugston wrote: No, it's easy. Student t is in std.mathspecial. Aargh, I didn't get around to copying it in. But this should do it. /** Inverse of Student's t distribution * [.] Great!!! Thank you soo much Don!!! --jm

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-23 Thread Juan Manuel Cabo
On Friday, 23 March 2012 at 05:26:54 UTC, Nick Sabalausky wrote: Wow, that's just fantastic! Really, this should be a standard system tool. I think this guy would be proud: http://zedshaw.com/essays/programmer_stats.html Thanks for the good vibes! Hahahhah, that article is so ing

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-22 Thread Juan Manuel Cabo
On Thursday, 22 March 2012 at 22:22:31 UTC, Andrei Alexandrescu wrote: Sweet! You may want to also print the mode of the distribution, which is the time of the maximum sample density. http://en.wikipedia.org/wiki/Mode_(statistics) (Warning: nontrivial but informative.) Andrei Thanks for

Re: DUnit - class MyTest { mixin TestMixin; void testMethod1() {} void testMethod2() {}}

2012-03-21 Thread Juan Manuel Cabo
On Saturday, 17 March 2012 at 12:30:49 UTC, Marc P. Michel wrote: On Monday, 20 February 2012 at 01:49:04 UTC, Juan Manuel Cabo wrote: I thought I could do a better effort to describe why DUnit is so extraordinary, for a native language, especially for those unfamiliar with xUnit frameworks

Re: DUnit - class MyTest { mixin TestMixin; void testMethod1() {} void testMethod2() {}}

2012-03-21 Thread Juan Manuel Cabo
On Sunday, 18 March 2012 at 11:05:59 UTC, Marc P. Michel wrote: Oh and also, changing version(linux) with version(Posix) for the color output management would be great. ( I'm on FreeBSD and was wondering why I had no colors as advertised :} ). Yeahp, will fix it. Sorry! Thanks for finding

Re: DUnit - class MyTest { mixin TestMixin; void testMethod1() {} void testMethod2() {}}

2012-03-21 Thread Juan Manuel Cabo
On Wednesday, 21 March 2012 at 20:04:39 UTC, Rio wrote: On Wednesday, 21 March 2012 at 17:29:59 UTC, Juan Manuel Cabo wrote: Btw, here is the whole list: http://www.junit.org/junit/javadoc/3.8.1/junit/framework/Assert.html Do you have any thoughts? Be careful: for JUnit 4

avgtime - Small D util for your everyday benchmarking needs

2012-03-21 Thread Juan Manuel Cabo
This is a small util I wrote in D which is like the unix 'time' command but can repeat the command N times and show median, average, standard deviation, minimum and maximum. As you all know, it is not proper to conclude that a program is faster than another program by running them just once.

Re: avgtime - Small D util for your everyday benchmarking needs

2012-03-21 Thread Juan Manuel Cabo
On Thursday, 22 March 2012 at 01:37:19 UTC, Tove wrote: Awesome, I do have a tiny feature request for the next version... a commandline switch to enable automatically discarding the first run as an outlier. /Tove Done, I just put it in github. (-d switch). But maybe you should be looking

Re: some regex vs std.ascii vs handcode times

2012-03-21 Thread Juan Manuel Cabo
On Wednesday, 21 March 2012 at 05:49:29 UTC, Juan Manuel Cabo wrote: On Monday, 19 March 2012 at 04:12:33 UTC, Jay Norwood wrote: [] Ok, this was the good surprise. Reading by chunks was faster than reading the whole file, by several ms. // read files by chunk ...!better than full

Re: some regex vs std.ascii vs handcode times

2012-03-20 Thread Juan Manuel Cabo
On Monday, 19 March 2012 at 17:23:36 UTC, Andrei Alexandrescu wrote: [.] I wanted for a long time to improve byLine by allowing it to do its own buffering. That means once you used byLine it's not possible to stop it, get back to the original File, and continue reading it. Using

Re: some regex vs std.ascii vs handcode times

2012-03-20 Thread Juan Manuel Cabo
On Monday, 19 March 2012 at 04:12:33 UTC, Jay Norwood wrote: [] Ok, this was the good surprise. Reading by chunks was faster than reading the whole file, by several ms. // read files by chunk ...!better than full input //finished! time: 23 ms void wcp_files_by_chunk(string fn) {

Re: new std.variant (was Re: The Right Approach to Exceptions)

2012-02-22 Thread Juan Manuel Cabo
No, because the array doesn't actually exist until appender makes copy. Will one be able to use the sort!()() algorithm directly on your appender, that is, without accessing/creating the underlying array? --jm

Re: new std.variant (was Re: The Right Approach to Exceptions)

2012-02-22 Thread Juan Manuel Cabo
On Wednesday, 22 February 2012 at 20:59:15 UTC, Jonathan M Davis wrote: speed [...] is really its whole point of existance. I don't know why else you'd ever use appender. [...] - Jonathan M Davis A use case is to give identity to a built-in array. Consider this: class MyClass {

Re: new std.variant (was Re: The Right Approach to Exceptions)

2012-02-22 Thread Juan Manuel Cabo
UTC, Juan Manuel Cabo wrote: No, because the array doesn't actually exist until appender makes copy. Will one be able to use the sort!()() algorithm directly on your appender, that is, without accessing/creating the underlying array? --jm

Re: new std.variant (was Re: The Right Approach to Exceptions)

2012-02-22 Thread Juan Manuel Cabo
On Thursday, 23 February 2012 at 00:51:38 UTC, Jonathan M Davis wrote: [...] If appender ends up with multiple arrays in it, then random access is no longer O(1) and is therefore unacceptable. As such, most sort algorithms wouldn't work with it. If all I want is binary search on a big

Re: new std.variant (was Re: The Right Approach to Exceptions)

2012-02-22 Thread Juan Manuel Cabo
On Thursday, 23 February 2012 at 01:36:32 UTC, Juan Manuel Cabo wrote: If all I want is binary search on a big appender, then it is O(k * n * log(n)), and that k right there doesn't bother me. (Where binary search is of course O(log(n)) and accessing individual elements with the proposed

Re: new std.variant (was Re: The Right Approach to Exceptions)

2012-02-22 Thread Juan Manuel Cabo
On Thursday, 23 February 2012 at 00:51:38 UTC, Jonathan M Davis wrote: P.S. Please don't top post. Replies should go _after_ the preceding message. P.S: You are right though, that it wouldn't be O(1) anymore and it should be said big in the documentation that it is amortized. --jm

Re: new std.variant (was Re: The Right Approach to Exceptions)

2012-02-22 Thread Juan Manuel Cabo
On Thursday, 23 February 2012 at 01:36:32 UTC, Juan Manuel Cabo wrote: On Thursday, 23 February 2012 at 00:51:38 UTC, Jonathan M Davis wrote: [...] If appender ends up with multiple arrays in it, then random access is no longer O(1) and is therefore unacceptable. As such, most sort algorithms

Re: new std.variant (was Re: The Right Approach to Exceptions)

2012-02-22 Thread Juan Manuel Cabo
On Thursday, 23 February 2012 at 01:57:49 UTC, Jonathan M Davis wrote: The D equivalent would really be Array, not Appender. Array!T in D is ref counted and more geared towards T being a struct. And I had big trouble sorting it with sort!()() in D2.056, so I made my own sort just to be able to

Re: new std.variant (was Re: The Right Approach to Exceptions)

2012-02-22 Thread Juan Manuel Cabo
On Thursday, 23 February 2012 at 02:12:20 UTC, Juan Manuel Cabo wrote: If we are going to get ideallistic [..] I'm sorry. I went over the top. I apollogize. ..I won't post for a while. This thread is almost poping a vein in my neck.. Passion can do that! I love D. Love all your good work

Re: GoingNative 6: The D Episode with Walter Bright and Andrei Alexandrescu

2012-02-21 Thread Juan Manuel Cabo
We want to have many users. dUsers ~= (juanManuel); :-) :-) :-) --jm On 02/21/2012 09:39 PM, Walter Bright wrote: http://channel9.msdn.com/Shows/C9-GoingNative/GoingNative-6-The-D-Episode-with-Walter-Bright-and-Andrei-Alexandrescu

Re: The Right Approach to Exceptions

2012-02-21 Thread Juan Manuel Cabo
This works: // note: the int parameter above isn't static dbConn.query(select age from people where id='foobar'); throw new WithErrorCode!FileNotFoundException( db.rs.getValue(1), file not found); ... Can you offer a real world use-case where the above isn't sufficient? What

Re: The Right Approach to Exceptions

2012-02-21 Thread Juan Manuel Cabo
of staticlly typed language doesn't mean that one must turn the advantages into disadvantages and start hammering screws because we love hammers. --jm On 02/21/2012 11:20 AM, Andrei Alexandrescu wrote: On 2/21/12 6:36 AM, Jacob Carlborg wrote: On 2012-02-20 23:44, Juan Manuel Cabo wrote: I

Re: The Right Approach to Exceptions

2012-02-21 Thread Juan Manuel Cabo
Never mind modifying fields of the exception at some intermediate catch place. Someone could even catch the exception and not rethrow it. So: do some trusting. Life gets easier :-) --jm On 02/21/2012 12:46 PM, Juan Manuel Cabo wrote: I think he meant to say things have been like

Re: The Right Approach to Exceptions

2012-02-21 Thread Juan Manuel Cabo
FileNotFoundException is the super class of the others so the first catch clause is enough. in fact, the others will never be called if listed in the above order. Nice! I missed that. But what if you want to add ErrorCode and Rainbows? And with your approach, one has to test for type and

Re: The Right Approach to Exceptions

2012-02-21 Thread Juan Manuel Cabo
, and it is the correct thing (for instance, java doesn't lose the stacktrace when rethrowing, and C++ with its throw; statement for rethrowing doesn't either). --jm On 02/21/2012 01:15 PM, Juan Manuel Cabo wrote: FileNotFoundException is the super class of the others so the first catch clause is enough

Re: The Right Approach to Exceptions

2012-02-21 Thread Juan Manuel Cabo
virtual functions overrideable (getExceptionData(string dataName) or something). but they would all have to return Object or Variant, so it's the same thing. --jm On 02/21/2012 01:39 PM, foobar wrote: On Tuesday, 21 February 2012 at 16:15:17 UTC, Juan Manuel Cabo wrote: FileNotFoundException

Re: The Right Approach to Exceptions

2012-02-21 Thread Juan Manuel Cabo
I didn't know where I last read it, it got stuck in my head. I wrote: [...] doesn't mean that one must turn the advantages into disadvantages and start hammering screws because we love hammers. I forget to be careful with metaphors, I realize that some must be emotionally loaded and don't

Re: The Right Approach to Exceptions

2012-02-21 Thread Juan Manuel Cabo
:03 PM, Jacob Carlborg wrote: On 2012-02-21 17:57, Andrei Alexandrescu wrote: On 2/21/12 10:50 AM, Juan Manuel Cabo wrote: I thought that an alternative to Variant[string] would be to have some virtual functions overrideable (getExceptionData(string dataName) or something). but they would all

Re: size_t + ptrdiff_t

2012-02-21 Thread Juan Manuel Cabo
c_long and c_ulong are guaranteed to match target long size (here would also go c_int and c_uint ;-). https://bitbucket.org/goshawk/gdc/src/87241c8e754b/d/druntime/core/stdc/config.d#cl-22 That is so good! Thanks! Currently, htod translates unsigned long to uint, which is wrong in linux 64

Re: size_t + ptrdiff_t

2012-02-21 Thread Juan Manuel Cabo
. If you want to keep D's size_t unsigned, then let c_size_t do whatever C does, and let D use sane types that do what the documentation says. :-) --jm On 02/21/2012 09:10 PM, Sean Kelly wrote: On Feb 21, 2012, at 3:50 PM, Juan Manuel Cabo wrote: Eh? All the type sizes vary in broken ways

Re: size_t + ptrdiff_t

2012-02-21 Thread Juan Manuel Cabo
, Juan Manuel Cabo wrote: size_t is intended to be the C representation. I very much do not want to end up with a c_size_t. Hahah, hold your jaw because it might drop: Looking for size_t extravagancies in C, I found that VC uses __int64 for size_t in x64 target. So this behaves

Re: size_t + ptrdiff_t

2012-02-21 Thread Juan Manuel Cabo
On 02/21/2012 10:13 PM, Sean Kelly wrote: I think this is actually a good thing, since working with unsigned integers is a pain. Yes, I would prefer that msb bit to be the sign too, but behavior might depend on it, and correctness and predictability is important. My first code snippet was

Re: size_t + ptrdiff_t

2012-02-21 Thread Juan Manuel Cabo
PM, Stewart Gordon wrote: On 21/02/2012 22:45, Juan Manuel Cabo wrote: snip The C standard only guarantees that: sizeof(char)= sizeof(int)= sizeof(long)= sizeof(size_t) snip I'm surprised. I'd assumed that, under 16-bit DOS/Windows, a size_t would be 16 bits. But no. Could memory

Re: size_t + ptrdiff_t

2012-02-21 Thread Juan Manuel Cabo
I'm surprised. I'd assumed that, under 16-bit DOS/Windows, a size_t would be 16 bits. But no. Could memory blocks 64K or larger actually be allocated under those systems? size_t being the typeof sizeof() expressions, tell you the upper bound for the size of static arrays, statically

Re: Please try rdmd on large projects

2012-02-20 Thread Juan Manuel Cabo
GOOD! Is the missing chmod problem fixable? So that the binary has the same permissions as the D file? If my D file is not readable or runnable by 'other', the binary shouldn't be either. (the cached .deps should have the same readability as the D file too perhaps). I think that this is the big

Re: Please try rdmd on large projects

2012-02-20 Thread Juan Manuel Cabo
AM, Juan Manuel Cabo wrote: GOOD! Is the missing chmod problem fixable? So that the binary has the same permissions as the D file? If my D file is not readable or runnable by 'other', the binary shouldn't be either. (the cached .deps should have the same readability as the D file too

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
On 02/20/2012 02:57 PM, Andrei Alexandrescu wrote: On 2/20/12 11:44 AM, foobar wrote: This extra processing is orthogonal to the exception. the same exception can be logged to a file, processed (per above example) and generate graphical notification to the user, etc. The exception contains the

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
I like the idea! Remember please for anyone reading: Use positional arguments in format strings. Otherwise: The '%s' file's size is %d which is wrong translated to El tamaño %d es incorrecto para el archivo %s will be trouble. Instead please do: The '%1$s'

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
And so variant is the way to go ? Clearly, this is a very strong arguement in favor of typed Exception, that provide usefull information about what went wrong. This is a safe approach. Because this Variant stuff is going to require massive ducktyping of Exceptions, with all possible

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
[custom_url] = getenv(URI); throw ex; } (don't beat me if URI wasn't the envvar that apache sends for uri, I don't remember it at the moment). --jm On 02/20/2012 04:27 PM, Juan Manuel Cabo wrote: And so variant is the way to go ? Clearly, this is a very strong arguement

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
) [0x7fc83b628eff] On 02/20/2012 04:44 PM, deadalnix wrote: Le 20/02/2012 20:32, Juan Manuel Cabo a écrit : So, if your boss wants the URL of the request that was made when the standard library threw you a FileNotFoundException, you can do: try { ... } catch

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
guess that you are proving my point. --jm On 02/20/2012 04:48 PM, Juan Manuel Cabo wrote: That wouldn't work, because you'll erase the stacktrace. Plus, you are confusing inheritance with composition here. What you want is throw a COMException and link it to the original Exception. You have

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
With all due respect, I don't see module exception categories as something good for the categorization of exceptions. As I said in a previous post, long lost in this mega thread, please don't create exception categories, unless it makes sense to write a catch (MyNewShinyCategory ex) {} for it.

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
that the runtime took to unwind the stack and serve the exception to your catch block. --jm On 02/20/2012 05:05 PM, Sean Kelly wrote: On Feb 20, 2012, at 11:54 AM, Juan Manuel Cabo wrote: About this part: What you want is throw a COMException and link it to the original Exception. You have

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
On 02/20/2012 03:23 PM, Jonathan M Davis wrote: I don't see how you could possibly make that uniform. It's very non-uniform by its very nature. The handling _needs_ to be non-uniform. The handling might need to be non-uniform, but the exception hierarchy doesn't. Not talking about i18n

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
... Sure. Again, this is not advocating replacement of exception hierarchies with tables! ... Andrei I think that the case of rethrowing an exception with added detail is the worst enemy of clean Exception hierarchies. The idea of Variant[string] remedies that case without creating a

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
Alexandrescu wrote: On 2/20/12 1:32 PM, Juan Manuel Cabo wrote: So, if your boss wants the URL of the request that was made when the standard library threw you a FileNotFoundException, you can do: try { ... } catch (Exception ex) { //Rethrow the exception

Re: The Right Approach to Exceptions

2012-02-20 Thread Juan Manuel Cabo
* of the error so that I can pick one when writing a catch block. --jm On 02/20/2012 05:51 PM, Jonathan M Davis wrote: On Monday, February 20, 2012 17:31:28 Juan Manuel Cabo wrote: ... Sure. Again, this is not advocating replacement of exception hierarchies with tables! ... Andrei I think

  1   2   >