Re: AI Challenge - Ants

2011-10-21 Thread Marco Leise
Am 21.10.2011, 06:31 Uhr, schrieb Jonathan M Davis : On Friday, October 21, 2011 06:22:43 Marco Leise wrote: Hi! I've been part of the team behind http://aichallenge.org/. We just started our next challenge about 30 minutes ago. This will be the first time that DMD 2.054 is supported ther

Re: FIFO stack

2011-10-26 Thread Marco Leise
Am 26.10.2011, 17:20 Uhr, schrieb Simen Kjaeraas : On Wed, 26 Oct 2011 17:15:37 +0200, Simen Kjaeraas wrote: On Wed, 26 Oct 2011 10:58:12 +0200, Dominic Jones wrote: Hello, I was looking for a FIFO stack in std.containers but only found SList and Array which both appear to essentially

Re: AA clear property

2011-11-05 Thread Marco Leise
Am 05.11.2011, 21:30 Uhr, schrieb Alex_Dovhal : Hi, D have "clear" property for arrays and AA, but I failed to find it's description in docs. Where it's? Are you this Alex? http://aichallenge.org/forums/viewtopic.php?f=21&t=1315#p10776 As I understand it this function is defined in object_.d

Re: std.container & ranges

2011-11-05 Thread Marco Leise
Am 02.11.2011, 12:48 Uhr, schrieb Steven Schveighoffer : In dcollections, removing a specific element (using the default comparison operator for that element) on a *fast lookup* container is as simple as: container.remove(container.find(x)); Which removes the element x if it's found. Howe

Re: FIFO stack

2011-11-05 Thread Marco Leise
Am 26.10.2011, 18:00 Uhr, schrieb Dominic Jones : Also an plain array is a good stack. :) I'd rather not use a plain array because (I assume) that when I push or pop using arrays, a swap array is created to resize the original. If this is not the case, then an array will certainly do. -Dominic

Re: AA clear property

2011-11-06 Thread Marco Leise
Am 06.11.2011, 00:15 Uhr, schrieb Alex_Dovhal : "Marco Leise" wrote: Are you this Alex? yes. As I understand it this function is defined in object_.d which is always imported by default and can be called on an (associative) array through a mechanism called "universa

Re: AI Challenge - Ants

2011-11-08 Thread Marco Leise
Am 23.10.2011, 19:52 Uhr, schrieb Jesse Phillips : On Sun, 23 Oct 2011 16:24:09 +0200, maarten van damme wrote: I'm noticing some problems, there are some methods missing used in the tutorial like "unocupied", the do_setup part and the visible method. Is this package complete or am I missing

Re: What is shared functions?

2011-11-08 Thread Marco Leise
Am 23.10.2011, 21:51 Uhr, schrieb bearophile : Jonathan M Davis: my general take on it is that dmd should _never_ ignore attributes, I agree. Such sloppiness is a very good source for problems, long term ones too, and it makes it harder to learn D. Bye, bearophile +1 For example I stil

Re: AI Challenge - Ants

2011-11-08 Thread Marco Leise
Am 08.11.2011, 21:04 Uhr, schrieb maarten van damme : I have stolen an isvisible method from the c# bot bool isVisible(Loc loc){ Loc[] offsets; int squares = cast(int)floor(sqrt(_viewradius2)); for (int r = -1 * squares; r <= squares; ++r){ for (int c = -1 * squares; c <= squares; ++c){ int

Re: Looking for documentation of D's lower-level aspects.

2011-11-09 Thread Marco Leise
Am 23.10.2011, 06:04 Uhr, schrieb Jonathan M Davis : I'd have to go digging through the newsgroup archives to give all of the reasons but it basically comes down to the fact that people very rarely want to pass containers by value, and the fact that C++ makes it so that the default behavior o

Re: Looking for documentation of D's lower-level aspects.

2011-11-09 Thread Marco Leise
Am 24.10.2011, 03:57 Uhr, schrieb Sean Silva : For example, if you look in the LLVM source tree, you'll see that they bend over backwards to avoid heap allocations. For example, in some cases, std::vector causes too much heap traffic so they have SmallVector which preallocates a certain amount o

Re: IDE with renaming possibility

2011-11-09 Thread Marco Leise
Am 07.11.2011, 11:08 Uhr, schrieb Jabba Laci : I use Emacs and replace regexp. Hi, I'm looking for a solution that replaces just in the scope. A regexp replace would change all occurrences :( Also, if you have a function that is implemented in a module and you call it in another file, it shou

Re: AI Challenge - Ants

2011-11-09 Thread Marco Leise
Am 09.11.2011, 18:52 Uhr, schrieb maarten van damme : dmd: glue.c:719: virtual void FuncDeclaration::toObjFile(int): Assertion `!vthis->csym' failed. Not able to reduce the code that causes it as it compiles fine here and it takes 10 minutes to upload new code and let it compile/play. 201

Re: AI Challenge - Ants

2011-11-09 Thread Marco Leise
Looks like issue #6395 or any of the issues linked in there: http://d.puremagic.com/issues/show_bug.cgi?id=6395 It could actually depend on the order the source files are found and appended to the command line by the server's compile script. :-/

Re: [OT] news group test

2011-11-28 Thread Marco Leise

Re: Array initialization quiz

2011-11-29 Thread Marco Leise
Am 29.11.2011, 14:53 Uhr, schrieb bearophile : deadalnix: No it has nothing to do with this bug. I tend to agree. But actually, this exemple should generate a warning at least, or being illegal eventually. I'd like that code to loop on all array 256 items once, and then stop :-) Bye, b

Re: Array initialization quiz

2011-11-29 Thread Marco Leise
Am 29.11.2011, 20:41 Uhr, schrieb Marco Leise : Am 29.11.2011, 14:53 Uhr, schrieb bearophile : deadalnix: No it has nothing to do with this bug. I tend to agree. But actually, this exemple should generate a warning at least, or being illegal eventually. I'd like that code to lo

Re: sub() in D2?

2012-01-30 Thread Marco Leise
Am 30.01.2012, 16:57 Uhr, schrieb adamss3 : Thanks. The only downside of strings being arrays: a lot of typical string functions are in std.array. :D

Re: Arrays - Inserting and moving data

2012-02-10 Thread Marco Leise
Am 09.02.2012, 22:03 Uhr, schrieb MattCodr : On Thursday, 9 February 2012 at 19:49:43 UTC, Timon Gehr wrote: Note that this code does the same, but is more efficient if you don't actually need the array: Yes I know, In fact I need re-think the way I code with this new features of D, like r

Re: What should do a D lint?

2012-02-10 Thread Marco Leise
Am 04.02.2012, 18:37 Uhr, schrieb bioinfornatics : hi, What should do a D lint? - check if in code the are no mixin between space / tab for indent - check indent (4 spaces as default) complete the list Do you want to collect ideas or advertise the use of 4 spaces for indentation? Look, i

Re: Immutable immutable strings??

2012-02-10 Thread Marco Leise
Am 10.02.2012, 19:07 Uhr, schrieb H. S. Teoh : I'm not sure whether the following a compiler/language bug or a Phobos bug, but it's definitely some kind of bug: auto s = "abc"; immutable t = "def"; writeln(typeid(s)); // immutable(char)[] writeln(typeid(t));

Re: dmd thrashes fedora

2012-02-11 Thread Marco Leise
Am 11.02.2012, 00:16 Uhr, schrieb Ellery Newcomer : On 02/10/2012 01:59 PM, Timon Gehr wrote: I seem to have more RAM than you. The behavior is apparently caused by a Phobos bug: That is likely. The code is a dustmite reduction, so I don't really care what the error is, just that it sho

Re: Rewrite of std.range docs (Was: Re: Making sense of ranges)

2012-03-27 Thread Marco Leise
Am Tue, 27 Mar 2012 06:00:58 +0200 schrieb "Jesse Phillips" : > On Monday, 26 March 2012 at 00:50:32 UTC, H. S. Teoh wrote: > > > This thread has further convinced me that std.range's docs > > *need* this > > rewrite. So here's my first attempt at it: > > > > https://github.com/quickfur/phob

Re: D slower ~1s from C ?!

2012-04-08 Thread Marco Leise
Am Thu, 05 Apr 2012 19:22:37 +0200 schrieb "Minas" : > Many of you should know the website "projecteuler.net", where > there are mathematical problems to solve with computers. > > I am doing those in D, and after I finished one today, I decided > to compile it in C as well to compare the result

Re: Multiple %s format specifiers with a single argument

2012-04-11 Thread Marco Leise
Am Thu, 12 Apr 2012 13:11:16 +1200 schrieb James Miller : > Its less using the email interface, and more people using braindead > email clients. Gmail and Mutt (the two I use most) seem to handle > replying well, setting the correct headers to indicate things. But I've > seen some odd postings fro

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-24 Thread Marco Leise
Am Sat, 14 Apr 2012 19:31:40 -0700 schrieb Jonathan M Davis : > On Sunday, April 15, 2012 04:21:09 Joseph Rushton Wakeling wrote: > > On 14/04/12 23:03, q66 wrote: > > > He also uses a class. And -noboundscheck should be automatically induced > > > by > > > -release. > > > > ... but the methods a

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-24 Thread Marco Leise
Am Sat, 14 Apr 2012 21:05:36 +0200 schrieb "ReneSac" : > I have this simple binary arithmetic coder in C++ by Mahoney and > translated to D by Maffi. I added "notrow", "final" and "pure" > and "GC.disable" where it was possible, but that didn't made much > difference. Adding "const" to the Pre

Re: A "general" tag

2012-04-25 Thread Marco Leise
Am Mon, 16 Apr 2012 20:52:16 +0200 schrieb "Xan" : > Uf!, it's more than I can process > It's really a **complicated** thing to do that in D. Too much information, yes. Too complicated no. :) D is statically typed (Fantom allows both static and dynamic typing). That means that for every vari

Re: Strange measurements when reproducing issue 5650

2012-04-25 Thread Marco Leise
Am Wed, 25 Apr 2012 10:34:38 +0200 schrieb "SomeDude" : > Discussion here: > http://d.puremagic.com/issues/show_bug.cgi?id=5650 > > On my Windows box, the following program > > import std.stdio, std.container, std.range; > > void main() { > enum int range = 100; > enum int n = 1_000_

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-25 Thread Marco Leise
Am Sun, 22 Apr 2012 09:23:45 +0200 schrieb "Jay Norwood" : > On Sunday, 22 April 2012 at 06:26:42 UTC, Jonathan M Davis wrote: > > > > You can look at the code. It checks each of the characters in > > place. Unlike > > toLower, it doesn't need to generate a new string. But as far > > as the > >

Re: What am I doing wrong ?

2012-04-25 Thread Marco Leise
Am Sun, 22 Apr 2012 23:47:20 +0200 schrieb "SomeDude" : > void main() { > auto array = new Foo[10]; > --> for(int i = array.length; i > 1; i--) { array[i].x = i; } > writeln(); > foreach(Foo f; array) { write(f.x);} > } > > throws core.exception.RangeError@bug(8): Range violation o

Re: [Kinda OT] httpd permissions

2012-04-26 Thread Marco Leise
Am Thu, 26 Apr 2012 05:44:59 +0200 schrieb "Nathan M. Swan" : > > Have you checked that your web server has write access to > > /Users/nathanmswan/Sites/ ? > > Yes, it works now, thanks! > NMS > > P.S. Sorry this might be in the wrong forum, but now I can > advertise my homepage as "index.d" i

Re: [Kinda OT] httpd permissions

2012-04-26 Thread Marco Leise
Am Thu, 26 Apr 2012 16:12:05 +0200 schrieb Joseph Rushton Wakeling : > > D is not a virtual machine language. You have to compile your code to > > execute it. (In case that was unclear.) > > ... don't see why you shouldn't use rdmd. Yes, rdmd is one of the tools that compile your code. It's jus

Re: Strange measurements when reproducing issue 5650

2012-04-27 Thread Marco Leise
Am Fri, 27 Apr 2012 04:18:47 + (UTC) schrieb David Brown : > On 2012-04-25, SomeDude wrote: > > On Wednesday, 25 April 2012 at 15:35:44 UTC, Steven Schveighoffer > > wrote: > >> On Wed, 25 Apr 2012 07:27:29 -0400, SomeDude > >> wrote: > >> > >>> On Wednesday, 25 April 2012 at 08:34:40 UTC,

Re: ufcs and integer params

2012-07-18 Thread Marco Leise
Am Sun, 15 Jul 2012 19:17:11 +0200 schrieb Philippe Sigaud : > > On Sunday, July 15, 2012 05:30:55 Jay Norwood wrote: > > > I see from this other discussions that it looks like 2.059 ( or > > > maybe 2.060) does support something like 3.cm(). Not sure from > > > the discussion if it would also a

Re: A few questions

2012-07-28 Thread Marco Leise
Am Sat, 28 Jul 2012 05:07:44 +0200 schrieb "bearophile" : > >> // x is a nullable class reference > >> if (x == null) { > >> ... > >> } else { > >> // here the type system sees x as not null. > >> } > > > In the else branch the state of the type of x is not-null, so as > example in the

Re: Function that calculates in compile time when it can

2012-08-07 Thread Marco Leise
Am Mon, 06 Aug 2012 14:21:37 +0200 schrieb "Minas Mina" : > I want to write a fibonacci(n) function that calculates the > result. > a) if n is known at compile time, use a template > b) if not, use a normal function > > I know how to write a template version: > template fib(ulong n) > { >

Re: Error while trying to allocate memory (malloc)

2012-08-07 Thread Marco Leise
Am Mon, 6 Aug 2012 18:25:01 +0200 schrieb Andrej Mitrovic : > On 8/6/12, CrudOMatic wrote: > > another quick question - are these allocations automatically > > entered into the GC heap? If so then I can just disable garbage > > collection? > > No, there is the standard C malloc/free in std.c.std

Re: Null Object works still fine

2012-08-11 Thread Marco Leise
Am Sun, 12 Aug 2012 00:23:10 +0200 schrieb "Namespace" : > This code works fine but it shouldn't, or? > > http://dpaste.dzfl.pl/b9027fff That's fine. There is no check for null at every possible occasion, like I think in Java. The operating system will catch any actual null dereference though,

Re: "For" infinite loop

2012-08-13 Thread Marco Leise
Am Mon, 13 Aug 2012 00:53:43 +0200 schrieb "bearophile" : > It looks better. But you every time you use a cast in D you need > to be careful, because they are like a sharp tool with almost no > safeties. > > Bye, > bearophile So true. It happens to me sometimes that I cast away const although

Re: Resizing array of classes

2012-10-19 Thread Marco Leise
Am Fri, 19 Oct 2012 11:09:42 +0200 schrieb "m0rph" : > Suppose I have a dynamic array of classes, something like: > > class Foo { > int value; > } > > Foo[] a; > > Now I want to resize it and initialize new items with default > values, so I do following: > > a.length = 10; > a[0].value =

Re: why my tail implementation is much more slower than coreutil ?

2012-11-04 Thread Marco Leise
tail from coreutils was compiled using the GCC. Use the same compiler backend (GDC). Any difference that still remains is from runtime initialization/termination, the overhead of using a wrapper class around the C routines (for the memory mapping or printing to terminal) and possibly a faster scan

Re: Manually freeing up memory

2012-11-07 Thread Marco Leise
Am Wed, 07 Nov 2012 19:56:35 +0100 schrieb Joseph Rushton Wakeling : > On 11/07/2012 06:53 PM, H. S. Teoh wrote: > > I think on Posix systems, malloc/free does not return freed memory back > > to the OS, it just gets reused by the process later on. > > I have to say that in this program, it looks

Deimos (How to port a header)

2013-01-31 Thread Marco Leise
Maybe Deimos (the GitHub presence) could use a dry piece of text that explains how to convert a header. I have just had the need for xcb for example, but no idea how a good header translation is supposed to look like, if all files need to be converted already on the first go and other questions, li

Re: Finding large difference b/w execution time of c++ and D codes for same problem

2013-02-13 Thread Marco Leise
I like optimization challenges. This is an excellent test program to check the effect of different floating point types on intermediate values. Remember that when you store values in a float variable, the FPU actually has to round it down to that precision, store it in a 32-bit memory location, the

Re: Finding large difference b/w execution time of c++ and D codes for same problem

2013-02-13 Thread Marco Leise
Am Wed, 13 Feb 2013 14:44:36 +0100 schrieb FG : > On 2013-02-13 14:26, Marco Leise wrote: > > template Julia(TReal) > > { > > struct ComplexStruct > > { > > float r; > > float i; > > ... > > Why aren&#

Re: Finding large difference b/w execution time of c++ and D codes for same problem

2013-02-13 Thread Marco Leise
Am Wed, 13 Feb 2013 14:48:21 +0100 schrieb Joseph Rushton Wakeling : > On 02/13/2013 02:26 PM, Marco Leise wrote: > > You get both, 50% more speed and more precision! It is a > > win-win situation. Also take a look at Phobos' std.math that > > returns real everywhere. &g

Re: Finding large difference b/w execution time of c++ and D codes for same problem

2013-02-13 Thread Marco Leise
Am Wed, 13 Feb 2013 15:00:21 +0100 schrieb Joseph Rushton Wakeling : > Compiling with ldmd2 -O -inline -release on 64-bit Ubuntu, latest from-GitHub > LDC, LLVM 3.2: > >D code serial with dimension 32768 ... > using floats Total time: 4.751 [sec] > using doubles Total time: 4.362 [

Re: Finding large difference b/w execution time of c++ and D codes for same problem

2013-02-13 Thread Marco Leise
Am Wed, 13 Feb 2013 15:45:13 +0100 schrieb Joseph Rushton Wakeling : > On 02/13/2013 03:29 PM, Marco Leise wrote: > > They are actual storage in memory, where every increase in > > size hurts. > > When I replaced with TReal, it sped things up for double. Give me that stuff

Re: Finding large difference b/w execution time of c++ and D codes for same problem

2013-02-13 Thread Marco Leise
Am Wed, 13 Feb 2013 15:45:13 +0100 schrieb Joseph Rushton Wakeling : > On 02/13/2013 03:29 PM, Marco Leise wrote: > > They are actual storage in memory, where every increase in > > size hurts. > > When I replaced with TReal, it sped things up for double. Oh this gets even b

Re: Finding large difference b/w execution time of c++ and D codes for same problem

2013-02-13 Thread Marco Leise
Am Wed, 13 Feb 2013 16:17:12 +0100 schrieb FG : > Good point about choosing the right type of floating point numbers. > Conclusion: when there's enough space, always pick double over float. > Tested with GDC in win64. floats: 16.0s / doubles: 14.1s / reals: 11.2s. > I thought to myself: cool, I al

Re: Finding large difference b/w execution time of c++ and D codes for same problem

2013-02-13 Thread Marco Leise
Am Wed, 13 Feb 2013 18:10:47 +0100 schrieb Joseph Rushton Wakeling : > Just to update on times. I was running another large job at the same time as > doing all these tests, so there was some slowdown. Current results are: > > -- with g++ -O3 and using double rather than float: about 4.3 s > >

Re: Stack overflow checking?

2013-02-18 Thread Marco Leise
Am Wed, 02 May 2012 02:45:32 +0200 schrieb "bearophile" : > I'd like to open an enhancement request for something like this > as a feature for all D compilers, what do you think? (Generally > Ada has something to teach to D design): > > http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gnat_ugn_unw/Stack

Re: How to detect current executable file name?

2013-02-18 Thread Marco Leise
Am Mon, 18 Feb 2013 10:07:45 +0100 schrieb Jacob Carlborg : > Yeah, GetModuleFileNameW should be used. I'm pretty sure the other > platforms will return UTF-8. I also found that console output on Windows works best with wchars. Linux doesn't have any official support to get the module file name,

What's the replacement for this array initialization: "ubyte[4096] window =0;"

2013-02-21 Thread Marco Leise
struct ExpandData { /// Last seen bytes during expansion. ubyte[4096] window = 0; ... } I noticed in 2.062 this code doesn't work anymore. The compiler still does the initial type conversion of 0 from int to ubyte, but the assignment fails with: cannot implicitly convert expr

Re: What's the replacement for this array initialization: "ubyte[4096] window =0;"

2013-02-21 Thread Marco Leise
Am Thu, 21 Feb 2013 20:26:56 -0800 schrieb Ali Çehreli : > On 02/21/2013 08:10 PM, Marco Leise wrote: > >struct ExpandData > >{ > > /// Last seen bytes during expansion. > > ubyte[4096] window = 0; > > ... > >} > > &

Re: What's the replacement for this array initialization: "ubyte[4096] window =0;"

2013-02-21 Thread Marco Leise
This is now: http://d.puremagic.com/issues/show_bug.cgi?id=9566 -- Marco

Re: What's the replacement for this array initialization: "ubyte[4096] window =0;"

2013-02-22 Thread Marco Leise
Am Fri, 22 Feb 2013 08:02:14 +0100 schrieb "monarch_dodra" : > That's not entirely true. For integers, the initialization is > always 0, which is expected and convenient. Yes, luckily for us integers didn't have a wrong/garbage value like floats and UTF-8 chars. But the design intent was to prov

Re: Appender cannot add struct with immutable members

2013-03-04 Thread Marco Leise
Am Mon, 04 Mar 2013 14:14:42 +0100 schrieb "Namespace" : > Is this intended behavior or just a bug / missing feature? > http://dpaste.1azy.net/21f100d3 > > I ask because it would be very easy to solve, with memcpy / > memmove. > http://dpaste.1azy.net/ac2b38e5 (line 192) There are several issue

Re: Reading bigger file

2013-03-08 Thread Marco Leise
Am Fri, 08 Mar 2013 16:31:45 +0100 schrieb "Chris Cain" : > On Friday, 8 March 2013 at 15:25:02 UTC, bioinfornatics wrote: > > why when reading a huge file more i advance into the file more > > that take time to get a line ? > > > StopWatch sw; > while( !fastq1.empty ){ >

Re: using debug version of phobos and druntime on linux

2013-03-10 Thread Marco Leise
Am Sun, 10 Mar 2013 19:19:13 +0700 schrieb Druzhinin Alexandr : > I use dmd/ubuntu 64 bit, rebuild phobos and druntime with debug option > and I cannot realize where dmd get them from so I can substitute my > version of these libs. Could someone hint me where I should place them? On another not

Re: GC, memory leaks and 32/64 bit

2013-03-12 Thread Marco Leise
Am Tue, 12 Mar 2013 21:08:01 +0100 schrieb "Rob T" : > It should be a plugin so that components like an alternate GC can > be swapped in and out easily. I hope once shared lib support > becomes available we'll finally see plugins introduced into dmd. > > --rt Well, you can already today set a

Re: GC, memory leaks and 32/64 bit

2013-03-12 Thread Marco Leise
Am Tue, 12 Mar 2013 21:44:11 +0100 schrieb "Rob T" : > Do you know if there are instructions posted somewhere on how to > override or proxy the GC? > > --rt Maybe someone else knows, I just started from here: https://github.com/D-Programming-Language/druntime/blob/master/src/gcstub/gc.d When

Re: Array operation with boolean operator

2013-03-14 Thread Marco Leise
Am Thu, 14 Mar 2013 22:15:11 +0100 schrieb "bearophile" : > Andrea Fontana: > > > But does sort!"a > See the difference in syntax: > > a < b > a[] < b[] > > Bye, > bearophile This is "just" a syntax ambiguity. a[] takes the complete slice of the array 'a'. And a dynamic array in D is a slice.

Re: Strange Segfault using XCB bindings from dsource

2013-04-28 Thread Marco Leise
Am Tue, 16 Apr 2013 17:57:55 +0200 schrieb "Mpnordladn" : > Hey all, > I'm poking around D, trying to see if it will be worth my while > to learn it. > I've used XCB in C++ and Python before, and I was delighted to > see that D has an XCB > binding as well. The problem, however, is in the exampl

Re: Simple delete directory tree?

2013-04-28 Thread Marco Leise
Am Fri, 26 Apr 2013 23:15:20 +0200 schrieb Andrej Mitrovic : > On 4/26/13, Nick Sabalausky wrote: > > I don't know how I managed to overlook that! Thanks :) > > I'd actually prefer if it was an enum or some other default parameter > in the rmdir function itself: > > rmdir(string path, bool doRe

Re: How i can clear Associative Arrays

2013-04-28 Thread Marco Leise
Am Mon, 15 Apr 2013 13:06:01 -0400 schrieb "Steven Schveighoffer" : > On Sun, 14 Apr 2013 02:50:07 -0400, gedaiu wrote: > > > On Saturday, 13 April 2013 at 21:10:16 UTC, Nicolas Guillemot wrote: > >>> I think we should introduce a removeAll function for hashes. Either > >>> through Druntime or t

Re: Calculation differences between Debug and Release mode

2013-04-28 Thread Marco Leise
Am Mon, 15 Apr 2013 11:51:43 -0400 schrieb "Steven Schveighoffer" : > On Mon, 15 Apr 2013 11:51:07 -0400, Steven Schveighoffer > wrote: > > > I would suspect that the issue is floating point error. On certain > > hardware, the CPU uses higher-precision 80-bit floating points. When > > yo

Re: Avoid initializing a struct field.

2013-05-05 Thread Marco Leise
Am Sat, 04 May 2013 21:00:17 +0200 schrieb "jerro" : > I tried using float[42] instead of int[42] and found out that > buffer actually isn't initialized to its default initializer if I > use "= void" (the numbers were all 0 instead of NaN), but the > performance cost is still there. Zero is th

Re: double vs real

2013-05-30 Thread Marco Leise
Am Thu, 30 May 2013 17:47:14 +0530 schrieb Shriramana Sharma : > Hello. I like that D exposes to me the real type to maximally utilize > the machine's numerical precision. Since I am writing a program > (currently in C++ but I am thinking of moving to D) that has to handle > lots of fractional num

Re: double vs real

2013-05-30 Thread Marco Leise
Am Fri, 31 May 2013 07:02:11 +0530 schrieb Shriramana Sharma : > Thanks to all who replied. > > On Thu, May 30, 2013 at 10:07 PM, Diggory wrote: > > > > Since D does all operations at highest possible precision anyway (even for > > double or float) it only makes a difference when the value is be

Re: Exception isn't thrown as expected

2013-05-30 Thread Marco Leise
Am Fri, 31 May 2013 10:26:49 +0700 schrieb Alexandr Druzhinin : > 31.05.2013 8:59, Adam D. Ruppe пишет: > > three questions come to mind: > > > > 1) what operating system and 32 bit or 64 bit? > > 2) what D compiler? > > 3) are you sure you didn't catch the exception somewhere up the chain > > and

Re: Exception isn't thrown as expected

2013-05-31 Thread Marco Leise
Am Fri, 31 May 2013 10:59:09 +0700 schrieb Alexandr Druzhinin : > You mean I didn't initialize c? It was a wild guess, that you might come from C++ and write SomeClass c; which would be an instance of that class in C++, but a null reference in D. As you said you only get the hanging when you

GC dead-locking ?

2013-06-13 Thread Marco Leise
Here is an excerpt from a stack trace I got while profiling with OProfile: #0 sem_wait () from /lib64/libpthread.so.0 #1 thread_suspendAll () at core/thread.d:2471 #2 gc.gcx.Gcx.fullcollect() (this=...) at gc/gcx.d:2427 #3 gc.gcx.Gcx.bigAlloc() (this=..., size=16401, poolPtr=0x7fc3d4bfe3c8, a

Re: GC dead-locking ?

2013-06-13 Thread Marco Leise
One more note: I get this consistently during profiling, but not without. I don't count kernel involvement out either, since OProfile is a kernel based profiler and there could be a quirk in its interaction with semaphores. -- Marco

Re: GC dead-locking ?

2013-06-18 Thread Marco Leise
Am Mon, 17 Jun 2013 10:46:19 -0700 schrieb Sean Kelly : > On Jun 13, 2013, at 2:22 AM, Marco Leise wrote: > > > Here is an excerpt from a stack trace I got while profiling > > with OProfile: > > > > #0 sem_wait () from /lib64/libpthread.so.0 > > #1 thread

Re: How would you solve this 'interview' question in D?

2013-06-26 Thread Marco Leise
Am Wed, 26 Jun 2013 22:52:17 +0200 schrieb "Gary Willoughby" : > The text from the question: > > Design a function f, such that: > > f(f(n)) == -n > Where n is a 32 bit signed integer; you can't use complex numbers > arithmetic. > > If you can't design such a function for the whole range of > n

Re: How would you solve this 'interview' question in D?

2013-06-26 Thread Marco Leise
> Anyway I've yet to see a solution that works for all input ;) Scratch that. -- Marco

Re: Scope of temporaries as function arguments

2013-06-28 Thread Marco Leise
Am Fri, 28 Jun 2013 02:15:19 -0400 schrieb Nick Sabalausky : > BTW, for anyone else reading, I just searched bugzilla and it looks > like the relevant issue is #9704. Reminds me of an issue I reported later: http://d.puremagic.com/issues/show_bug.cgi?id=10409 -- Marco

Re: memcpy in D

2013-06-30 Thread Marco Leise
Am Sun, 30 Jun 2013 07:07:23 -0400 schrieb "Tyro[17]" : > What is the equivalent of memcpy > > module memcopy; > > immutable ADDRESS_BUS_SIZE = 20; // 2^20 address bus > byte memory[1 << ADDRESS_BUS_SIZE]; > > void main() > { > ushort val = 12345; > > for (int i = 0x12340; i < 0x12

Re: memcpy in D

2013-06-30 Thread Marco Leise
... or alternatively: // Simple integers can be compile-time literals (i.e. C's #define) enum ADDRESS_BUS_SIZE = 20; // 2^20 address bus // In D it is more ideomatic to put the array length first. // For example this wouldn't work: byte x, *y, memory[1 << ADDRESS_BUS_SIZE]; byte[1 << ADDRESS_BUS_S

Re: GC dead-locking ?

2013-07-01 Thread Marco Leise
Am Tue, 18 Jun 2013 19:12:06 -0700 schrieb Sean Kelly : > On Jun 18, 2013, at 7:01 AM, Marco Leise wrote: > > > Am Mon, 17 Jun 2013 10:46:19 -0700 > > schrieb Sean Kelly : > > > >> On Jun 13, 2013, at 2:22 AM, Marco Leise wrote: > >> > >>

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-07-03 Thread Marco Leise
Am Sat, 22 Jun 2013 23:27:00 +0200 schrieb "bearophile" : > Ali Çehreli: > > > The code compiles under 32-bit (e.g. with the -m32 compiler > > switch) where size_t is an alias of uint. > > Oh, I see. I compile most of the code on a 32 bit system. > > I asked Walter to warn d programmers agains

Re: Stop to! rounding?

2013-07-03 Thread Marco Leise
Am Tue, 2 Jul 2013 22:21:52 -0700 schrieb "H. S. Teoh" : > On Tue, Jul 02, 2013 at 10:14:33PM -0700, Ali Çehreli wrote: > [...] > > import std.stdio; > > import std.conv; > > > > void main() > > { > > auto a = to!double("151.42499"); > > writefln("%.60f", a); > > } > > I wouldn't write i

Re: Building from source for ubuntu

2013-07-07 Thread Marco Leise
Am Sun, 07 Jul 2013 12:25:50 +0200 schrieb "monarch_dodra" : > I'm hitting a wall at building phobos, because of curl: > make -f posix.mak DMD=../dmd/src/dmd > /usr/bin/ld: cannot find -lcurl > > I've isntalled curl via apt-get ("sudo apt-get curl"), and it > seems to be installed. Just not in l

Re: Building from source for ubuntu

2013-07-07 Thread Marco Leise
Am Sun, 7 Jul 2013 14:45:56 +0200 schrieb Marco Leise : > Am Sun, 07 Jul 2013 12:25:50 +0200 > schrieb "monarch_dodra" : > > > I'm hitting a wall at building phobos, because of curl: > > make -f posix.mak DMD=../dmd/src/dmd > > /usr/bin/ld: cannot find -

Re: Allocating a slice object

2013-07-08 Thread Marco Leise
Am Thu, 04 Jul 2013 15:54:48 +0200 schrieb "monarch_dodra" : > > This should work: > > > > int[] *pSlice = (new int[][1]).ptr; > > > > -Steve > > Hum... That would allocate a dynamic array of slices though > right? There'd be the Appendable overhead for just one element... No, it allocates a st

Re: enforcing alias this on derived types

2013-07-08 Thread Marco Leise
Am Mon, 08 Jul 2013 10:59:14 +0200 schrieb "JS" : > I have an interface that I would like to make sure that any > classes derived from it will use alias this, else it can > potentially break code. > > interface A(T) > { > @property T Value(); > @property T Value(T value); > // ne

GktD: exceptions in handlers cause segfaults.

2013-07-19 Thread Marco Leise
I am trying to throw exceptions in gtk signal handlers, but I am greeted with segfaults. What's the cause and are there solutions? (DMD 2.063.2 on Linux x86-64) Here is some reduced code: import gtk.Main; import gtk.MainWindow; import gdk.Event; import gtk.Widget; class TestWindow : MainWindow {

Re: GktD: exceptions in handlers cause segfaults.

2013-07-19 Thread Marco Leise
Am Fri, 19 Jul 2013 11:10:04 +0200 schrieb Marco Leise : dav1d gave me advice on rebuilding druntime with debug symbols. That lead me to this "GitHub" stack trace: https://github.com/D-Programming-Language/druntime/blob/v2.063.2/src/rt/deh2.d#L104 https://github.com/D-Programmin

Re: GktD: exceptions in handlers cause segfaults.

2013-07-19 Thread Marco Leise
Am Fri, 19 Jul 2013 11:47:41 +0200 schrieb Marco Leise : > Am Fri, 19 Jul 2013 11:10:04 +0200 > schrieb Marco Leise : > > dav1d gave me advice on rebuilding druntime with debug symbols. > That lead me to this "GitHub" stack trace: > > https://github.com/D-Pro

Re: GktD: exceptions in handlers cause segfaults.

2013-07-22 Thread Marco Leise
Am Fri, 19 Jul 2013 21:43:38 +0200 schrieb Johannes Pfau : > Am Fri, 19 Jul 2013 12:38:45 +0200 > schrieb Marco Leise : > > Would be nice to know if this is working with gdc or ldc. In theory it > should work as we use gcc's exception handling/stack unwinding so it&#x

Re: Why is size_t unsigned?

2013-07-22 Thread Marco Leise
Am Mon, 22 Jul 2013 05:47:34 +0200 schrieb "JS" : > Doing simple stuff like > > for(int i = 0; i < s.length - 1; i++) fails catastrophically if s > is empty. To make right one has to reduce performance by writing > extra checks. And my opinion on the matter is that it is catastrophic style to

Re: UFCS and error messages

2013-10-31 Thread Marco Leise
Am Thu, 31 Oct 2013 11:58:18 +0100 schrieb "Andrea Fontana" : > Check this simple code: > > import std.stdio; > import std.conv; > > bool is_zero(T)(T i) { return to!int(i) == 0; } > > void main() { "0".is_zero.writeln; } > > This code print "true" of course. > > If you replace "to!int(i) ==

Re: new Type[count] takes too much?

2013-10-31 Thread Marco Leise
Am Thu, 31 Oct 2013 02:52:49 -0700 schrieb Jonathan M Davis : > On Thursday, October 31, 2013 10:15:51 Namespace wrote: > > I'm sure we had already this conversation but I don't find the > > thread. > > > > T[] buffer = new T[N]; assumes more space than stated (in average > > 2010 elements more.

Re: new Type[count] takes too much?

2013-10-31 Thread Marco Leise
Am Thu, 31 Oct 2013 10:42:35 +0100 schrieb "Namespace" : > On Thursday, 31 October 2013 at 09:27:11 UTC, bearophile wrote: > > In Python if you append items to an array, it sovra-allocates, > Never heard of 'sovra'. What does it mean? That's bearophilian for 'over'. :p -- Marco

Re: Limiting template functions to template instantiations of a struct

2013-11-07 Thread Marco Leise
Am Wed, 06 Nov 2013 14:22:13 +0100 schrieb "simendsjo" : > template isFoo(T) { > static if(is(T:Foo!U, int U)) > enum isFoo = true; > else > enum isFoo = false; > } enum isFoo(T) = is(T:Foo!U, int U); correct ? -- Marco

Re: How to re-initialise an associative array.

2013-11-07 Thread Marco Leise
Am Wed, 06 Nov 2013 18:14:54 +0100 schrieb "Gary Willoughby" : > I'm not taking the chance and currently using: > > x = (int[string]).init; x = null; is shorter. Just saying ;) -- Marco

Re: Best data structure for a particle system?

2013-11-15 Thread Marco Leise
Am Fri, 15 Nov 2013 21:56:15 +0900 schrieb Mike Parker : > On 11/15/2013 9:19 PM, Mikko Ronkainen wrote: > > > > If relevant, doubly-linked might work better? dcollections LinkList, or > > maybe DList? I'm asking mostly because I'd like the container to avoid > > memory allocations while in use. >

Re: Weird timing issue with Thread.sleep

2011-08-14 Thread Marco Leise
Am 03.08.2011, 19:21 Uhr, schrieb Steven Schveighoffer : On Wed, 03 Aug 2011 13:14:50 -0400, Andrej Mitrovic wrote: Take a look at this: import std.stdio; import core.thread; void main() { foreach (x; 0 .. 1000) { Thread.sleep(dur!("usecs")(999)); writeln(x);

  1   2   3   >