Re: Internal Compiler Error Help

2015-05-21 Thread John Colvin via Digitalmars-d-learn
On Thursday, 21 May 2015 at 10:24:59 UTC, John Colvin wrote: On Thursday, 21 May 2015 at 08:55:45 UTC, Saurabh Das wrote: Thanks! Wow, dustmite is really useful. It reduces the expression down to: double someFunction(double AvgPriceChangeNormalized, double TicksTenMinutesNormalized

Re: Internal Compiler Error Help

2015-05-21 Thread John Colvin via Digitalmars-d-learn
On Thursday, 21 May 2015 at 11:36:15 UTC, Saurabh Das wrote: PS: The original expression: http://dpaste.dzfl.pl/raw/e7a66aa067ab double someFunction(double AvgPriceChangeNormalized, double DayFactor, double TicksTenMinutesNormalized) { return

Re: Monday is last day for DConf 2015 registrations

2015-05-21 Thread John Colvin via Digitalmars-d-announce
On Thursday, 21 May 2015 at 13:42:37 UTC, Steven Schveighoffer wrote: On 5/19/15 6:59 PM, Brad Anderson wrote: On Monday, 18 May 2015 at 19:59:08 UTC, Steven Schveighoffer wrote: [snip] I just booked a car, but could cancel it. Anyone from the area know whether it's worth having a car there

Re: Type tuple pointers

2015-05-21 Thread John Colvin via Digitalmars-d
On Thursday, 21 May 2015 at 16:11:30 UTC, Timon Gehr wrote: On 05/21/2015 05:37 PM, Dicebot wrote: On Thursday, 21 May 2015 at 15:30:59 UTC, Alex Parrill wrote: They aren't types themselves, so `TypeTuple!(int, char) var` doesn't make sense. Sadly, you are wrong on this one - this is

Re: Using arrays of function pointers in D

2015-05-21 Thread John Colvin via Digitalmars-d-learn
On Thursday, 21 May 2015 at 16:23:15 UTC, John wrote: I've been rewriting one of my emulators in D and am fairly new to the language. I'm having trouble finding documentation on creating/initializing/use of arrays of function pointers in D. If anyone has a code example I'd appreciate it!

Re: 0 is not a power of 2

2015-05-20 Thread John Colvin via Digitalmars-d
On Tuesday, 19 May 2015 at 20:46:09 UTC, Matthias Bentrup wrote: I think you can make the over/underflow at zero work in your favor: bool isPowerOf2(uint x) { return (x -x) (x - 1); } Very nice

Re: 0 is not a power of 2

2015-05-19 Thread John Colvin via Digitalmars-d
On Tuesday, 19 May 2015 at 05:16:48 UTC, Andrei Alexandrescu wrote: So there's this classic trick: bool isPowerOf2(uint x) { return (x (x - 1)) == 0; } Pretty neat, but it wrongly returns true for x == 0. So the obvious fix is: bool isPowerOf2(uint x) { return x (x (x - 1)) == 0;

Re: 0 is not a power of 2

2015-05-19 Thread John Colvin via Digitalmars-d
On Tuesday, 19 May 2015 at 15:39:16 UTC, safety0ff wrote: On Tuesday, 19 May 2015 at 08:28:11 UTC, John Colvin wrote: I tested with a few different (modern) backends to see what was generated, they all essentially give you this (gcc 5.1.0 -O3 -march=broadwell): isPowerOf2: xorl

Re: The analogue of fill-pointer in D

2015-05-18 Thread John Colvin via Digitalmars-d-learn
On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote: Hi, In Common Lisp, there is such a thing as a fill-pointer (Example 5): http://www.tutorialspoint.com/lisp/lisp_arrays.htm Does D some equivalent? Fill pointers, combined with the various helper functions (e.g. vector-push)

Re: Convert C array pointer to a D slice without data copy

2015-05-18 Thread John Colvin via Digitalmars-d-learn
On Monday, 18 May 2015 at 09:23:26 UTC, tcak wrote: On Monday, 18 May 2015 at 09:18:33 UTC, ParticlePeter wrote: I get the point to an array from a c function, the data size from another function. The data should be only readable at the D side, but I would like to use it as a D slice without

Re: The analogue of fill-pointer in D

2015-05-18 Thread John Colvin via Digitalmars-d-learn
On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote: On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: No, afraid not. Function capacity is not an analogue of fill-pointers! It's exactly the same. But in D capacity is affected by other things. auto a = new int[20]; auto b

Re: The analogue of fill-pointer in D

2015-05-18 Thread John Colvin via Digitalmars-d-learn
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: On Monday, 18 May 2015 at 10:14:33 UTC, Kagamin wrote: On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote: Hi, In Common Lisp, there is such a thing as a fill-pointer (Example 5):

Re: control flow with a functional template ?

2015-05-18 Thread John Colvin via Digitalmars-d-learn
On Monday, 18 May 2015 at 06:13:50 UTC, Baz wrote: who's never had to do this: --- if (comparison) { statement; break; } --- ans then thought it's a pity to open/closes the braces just for a simple statement. Would it be possible to have a template to simplify this to: --- if

Re: control flow with a functional template ?

2015-05-18 Thread John Colvin via Digitalmars-d-learn
On Monday, 18 May 2015 at 08:46:36 UTC, John Colvin wrote: On Monday, 18 May 2015 at 06:13:50 UTC, Baz wrote: who's never had to do this: --- if (comparison) { statement; break; } --- ans then thought it's a pity to open/closes the braces just for a simple statement. Would

Re: The analogue of fill-pointer in D

2015-05-18 Thread John Colvin via Digitalmars-d-learn
On Monday, 18 May 2015 at 17:43:50 UTC, Ali Çehreli wrote: On 05/18/2015 05:26 AM, John Colvin wrote: On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote: On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: No, afraid not. Function capacity is not an analogue of fill-pointers

Re: Linking to Dynamic Library on Mac OS X

2015-05-15 Thread John Colvin via Digitalmars-d-learn
On Friday, 15 May 2015 at 03:33:47 UTC, TJB wrote: I have built a toy dynamic shared library on Mac OS X (in C), and I have verified that it works from C. Now I would like to call it from D. So I have created the following interface file: $ cat hello.di extern (C): void printHelloWorld();

Re: Destructured Tuple Assignment

2015-05-15 Thread John Colvin via Digitalmars-d-learn
On Friday, 15 May 2015 at 10:23:24 UTC, Per Nordlöw wrote: I recall having seen an example of using some D magic (via mixin perhaps?) to realize tuple destructuring in assignments like magic(first, _, second) = expression.findSplit(separator); somewhere. But I can't seem to find it right

Re: SIG11 crashing - can't figure it out

2015-05-15 Thread John Colvin via Digitalmars-d-learn
On Friday, 15 May 2015 at 11:08:06 UTC, Rob Pieké wrote: Working my way through Ali Çehreli's rather amazing e-book, I've hit a snag where some code I've written is pretty crashy. I consistently get Segmentation fault: 11 (dmd 2.067.1, OSX). I can't figure out where things are going wrong,

Re: SIG11 crashing - can't figure it out

2015-05-15 Thread John Colvin via Digitalmars-d-learn
On Friday, 15 May 2015 at 11:44:32 UTC, John Colvin wrote: On Friday, 15 May 2015 at 11:08:06 UTC, Rob Pieké wrote: Working my way through Ali Çehreli's rather amazing e-book, I've hit a snag where some code I've written is pretty crashy. I consistently get Segmentation fault: 11 (dmd 2.067.1

Re: Linking to Dynamic Library on Mac OS X

2015-05-15 Thread John Colvin via Digitalmars-d-learn
On Friday, 15 May 2015 at 19:39:53 UTC, TJB wrote: Off the top of my head: does adding -L-L$(pwd) help? This is what I get: $ dmd main.d -L-L$(pwd) -lhello Error: unrecognized switch '-lhello' Sorry if this is completely elementary and I am being quite dumb. Thanks, TJB should be $ dmd

Re: problem with parallel foreach

2015-05-14 Thread John Colvin via Digitalmars-d-learn
On Thursday, 14 May 2015 at 10:46:53 UTC, Gerald Jansen wrote: John Colvin's improvements to my D program seem to have resolved the problem. (http://forum.dlang.org/post/ydgmzhlspvvvrbeem...@forum.dlang.org and http://dpaste.dzfl.pl/114d5a6086b7). I have rerun my tests and now the picture is a

Re: std.parallelism equivalents for posix fork and multi-machine processing

2015-05-14 Thread John Colvin via Digitalmars-d
On Wednesday, 13 May 2015 at 20:34:24 UTC, weaselcat wrote: On Wednesday, 13 May 2015 at 20:28:02 UTC, Laeeth Isharc wrote: Is there value to having equivalents to the std.parallelism approach that works with processes rather than threads, and makes it easy to manage tasks over multiple

Re: Accessing x86 Performance Counters

2015-05-13 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 13 May 2015 at 03:38:33 UTC, Maxime Chevalier-Boisvert wrote: I was wondering if anyone has written D code to access the x86 performance counters, to get information such as the number of cache misses and cycle count. It would probably be easiest to write some bindings to PAPI-C

Re: problem with parallel foreach

2015-05-13 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 12 May 2015 at 18:14:56 UTC, Gerald Jansen wrote: On Tuesday, 12 May 2015 at 16:35:23 UTC, Rikki Cattermole wrote: On 13/05/2015 4:20 a.m., Gerald Jansen wrote: At the risk of great embarassment ... here's my program: http://dekoppel.eu/tmp/pedupg.d Would it be possible to give

Re: problem with parallel foreach

2015-05-13 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 13 May 2015 at 11:33:55 UTC, John Colvin wrote: On Tuesday, 12 May 2015 at 18:14:56 UTC, Gerald Jansen wrote: On Tuesday, 12 May 2015 at 16:35:23 UTC, Rikki Cattermole wrote: On 13/05/2015 4:20 a.m., Gerald Jansen wrote: At the risk of great embarassment ... here's my program

Re: problem with parallel foreach

2015-05-13 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 13 May 2015 at 14:28:52 UTC, Gerald Jansen wrote: On Wednesday, 13 May 2015 at 13:40:33 UTC, John Colvin wrote: On Wednesday, 13 May 2015 at 11:33:55 UTC, John Colvin wrote: On Tuesday, 12 May 2015 at 18:14:56 UTC, Gerald Jansen wrote: On Tuesday, 12 May 2015 at 16:35:23 UTC

Re: Calypso: Direct and full interfacing to C++

2015-05-13 Thread John Colvin via Digitalmars-d-announce
On Tuesday, 12 May 2015 at 21:44:04 UTC, Kelly wrote: Well the first fully working example of a large library is finally working with Calypso. Elie has managed to get a Qt5 demo program to compile and run!! The demo is a D version of the Qt5 Widgets demo. This is a simple window with a

Re: problem with parallel foreach

2015-05-13 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 13 May 2015 at 14:43:50 UTC, John Colvin wrote: On Wednesday, 13 May 2015 at 14:28:52 UTC, Gerald Jansen wrote: On Wednesday, 13 May 2015 at 13:40:33 UTC, John Colvin wrote: On Wednesday, 13 May 2015 at 11:33:55 UTC, John Colvin wrote: On Tuesday, 12 May 2015 at 18:14:56 UTC

Re: Shouldn't assert declarations be seen in documentation?

2015-05-12 Thread John Colvin via Digitalmars-d
On Tuesday, 12 May 2015 at 10:40:48 UTC, tcak wrote: I am developing a web server - web application system, and it is going to be running on a small system that has 256MB memory at maximum. Hence, I tried to use every bit of memory without wasting, and used align(1) on a struct type. Because

Re: Run-time Indexing of a Compile-Time Tuple

2015-05-12 Thread John Colvin via Digitalmars-d-learn
On Monday, 11 May 2015 at 22:46:00 UTC, Per Nordlöw wrote: The pattern final switch (_index) { import std.range: empty, front; foreach (i, R; Rs) { case i:

Re: Run-time Indexing of a Compile-Time Tuple

2015-05-12 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 12 May 2015 at 09:26:07 UTC, John Colvin wrote: On Monday, 11 May 2015 at 22:46:00 UTC, Per Nordlöw wrote: The pattern final switch (_index) { import std.range: empty, front; foreach (i, R; Rs

Re: dmd build instructions from source don't work anymore

2015-05-12 Thread John Colvin via Digitalmars-d
On Tuesday, 12 May 2015 at 06:20:12 UTC, Ali Çehreli wrote: On 05/11/2015 10:23 AM, Timothee Cour via Digitalmars-d wrote: I notice CC is set to 'g++' in posix.mak which is untypical (instead of gcc for example) That is required because although all implementation files are C++, they have

Re: D looses in speed to Common Lisp

2015-05-12 Thread John Colvin via Digitalmars-d
On Monday, 11 May 2015 at 22:22:23 UTC, anonymous wrote: Optimization flags don't seem to matter much for this program. Most of the bigint work is probably happening in handwritten assembly code and the memory allocation code is compiled in to druntime, so the optimiser isn't really getting

Re: problem with parallel foreach

2015-05-12 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 12 May 2015 at 14:59:38 UTC, Gerald Jansen wrote: I am a data analyst trying to learn enough D to decide whether to use D for a new project rather than Python + Fortran. I have recoded a non-trivial Python program to do some simple parallel data processing (using the map function

Re: problem with parallel foreach

2015-05-12 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 12 May 2015 at 15:11:01 UTC, John Colvin wrote: On Tuesday, 12 May 2015 at 14:59:38 UTC, Gerald Jansen wrote: I am a data analyst trying to learn enough D to decide whether to use D for a new project rather than Python + Fortran. I have recoded a non-trivial Python program to do

Re: dmd build instructions from source don't work anymore

2015-05-11 Thread John Colvin via Digitalmars-d
On Monday, 11 May 2015 at 08:31:19 UTC, Timothee Cour wrote: git clone git://github.com/D-Programming-Language/dmd.git cd dmd make -f posix.mak MODEL=64 /Applications/Xcode.app/Contents/Developer/usr/bin/make -C src -f posix.mak no cpu specified, assuming X86 dmd idgen.d g++ -m64: No such

Re: D needs...

2015-05-11 Thread John Colvin via Digitalmars-d-announce
On Monday, 11 May 2015 at 11:59:02 UTC, Namespace wrote: Inspired by ponce idioms list for D I've set up something similar. There are some themes in D which come up regulary and are discussed to the vomit. If something is agreed, it gets forgotten sometimes and the theme disappears into

Re: dmd build instructions from source don't work anymore

2015-05-11 Thread John Colvin via Digitalmars-d
On Monday, 11 May 2015 at 12:25:27 UTC, Daniel Murphy wrote: John Colvin wrote in message news:jsnuhemrispqiwvwl...@forum.dlang.org... Do you 1) already have a version of dmd installed (relatively new requirement) Yeah, it's this. Which page is this that needs updating? I don't see

Wiki table for available compiler packages by platform/OS

2015-05-11 Thread John Colvin via Digitalmars-d-announce
I took the time to research the status quo in D compiler availability on a variety of OSs. http://wiki.dlang.org/Compilers#Package_and.2For_binary_availability.2C_by_platform_and_compiler The reason I am posting this in announce is that, for it to be worth having, it will need to be kept up

Re: D looses in speed to Common Lisp

2015-05-11 Thread John Colvin via Digitalmars-d
On Monday, 11 May 2015 at 21:15:33 UTC, Dzhon Smit wrote: Just in case you wonder, here's a comparison of the Fibonacci numbers. The D code was written by Dennis Ritchie (a user of this forum, not the guy who invented C). [code]import std.stdio, std.bigint; void main() { BigInt[] fib1,

Re: Tuple assignment

2015-05-10 Thread John Colvin via Digitalmars-d
On Sunday, 10 May 2015 at 08:07:38 UTC, Russel Winder wrote: On Sat, 2015-05-09 at 13:07 -0700, Walter Bright via Digitalmars-d wrote: […] It probably depends on the compiler. The way to find out is to look at the generated assembler. pedant-modeassembly language file, not assembler (which

Re: readf error bug?

2015-05-09 Thread John Colvin via Digitalmars-d
On Saturday, 9 May 2015 at 08:41:49 UTC, Dave Akers wrote: On Saturday, 9 May 2015 at 08:34:42 UTC, Dennis Ritchie wrote: On Saturday, 9 May 2015 at 08:30:31 UTC, Dave Akers wrote: The following... import std.stdio; void main() { write(How many students are there? ); int

Re: Lambda functions in D

2015-05-09 Thread John Colvin via Digitalmars-d-learn
On Saturday, 9 May 2015 at 14:47:21 UTC, Russel Winder wrote: On Sat, 2015-05-09 at 07:15 -0700, Ali Çehreli via Digitalmars-d-learn wrote: On 05/09/2015 04:59 AM, Dennis Ritchie wrote: On Saturday, 9 May 2015 at 11:49:48 UTC, Timon Gehr wrote: assert((function int(int

Re: a success story for D ! !!

2015-05-06 Thread John Colvin via Digitalmars-d
On Wednesday, 6 May 2015 at 07:43:28 UTC, d coder wrote: But, a fair chunk of code. Maybe there's little activity recently because they consider it done. I haven't committed to the majority of my github things for months, but I still stand by them. Greetings I am the lead developer of

Re: vibed: how to use pure HTML instead of template engine?

2015-05-06 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 6 May 2015 at 14:28:26 UTC, Adam D. Ruppe wrote: On Wednesday, 6 May 2015 at 14:23:27 UTC, Chris wrote: Especially this: http://vibed.org/templates/diet#embedded-code I think that's a misfeature... if I used vibe.d, I'd want to avoid the diet too. I quite like them. Obviously

Re: std.xml2 (collecting features)

2015-05-05 Thread John Colvin via Digitalmars-d
On Tuesday, 5 May 2015 at 10:41:37 UTC, Mario Kröplin wrote: On Monday, 4 May 2015 at 19:28:25 UTC, Jacob Carlborg wrote: On 2015-05-03 19:39, Robert burner Schadek wrote: Not much code yet, I'm currently building the performance test suite https://github.com/burner/std.xml2 I recommend

Re: How to reuse functions

2015-05-01 Thread John Colvin via Digitalmars-d-learn
On Friday, 1 May 2015 at 03:34:53 UTC, Luigi wrote: Hi everybody. I am tring to use a function where its parameter is another function, and at the same time are both already made - they cannot be modified - and the second one has to be conditioned before to be passed as argument. Let's say

Re: Quick Start with D: few examples and set of links.

2015-05-01 Thread John Colvin via Digitalmars-d-announce
On Friday, 1 May 2015 at 15:53:12 UTC, Ilya Yaroshenko wrote: Pipeline should be optimised (I am not sure about `tee`) by LDC, GDC and probably DMD so all examples are generaly equal. Yeah I wouldn't expect a big difference here. Even if things aren't well optimised, the various branches

Re: The amazing template which does nothing

2015-04-30 Thread John Colvin via Digitalmars-d
On Wednesday, 29 April 2015 at 14:18:49 UTC, Iain Buclaw wrote: On 29 April 2015 at 14:50, John Colvin via Digitalmars-d digitalmars-d@puremagic.com wrote: On Wednesday, 29 April 2015 at 12:07:58 UTC, Vladimir Panteleev wrote: On Wednesday, 29 April 2015 at 07:00:15 UTC, John Colvin wrote

Re: The amazing template which does nothing

2015-04-29 Thread John Colvin via Digitalmars-d
On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev wrote: On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote: Trying on d.godbolt.com it seems a lot of extra-code is generated for the first version. d.godbolt.com is dead, use asm.dlang.org d.godbolt.org (note .org

Re: The amazing template which does nothing

2015-04-29 Thread John Colvin via Digitalmars-d
On Wednesday, 29 April 2015 at 12:07:58 UTC, Vladimir Panteleev wrote: On Wednesday, 29 April 2015 at 07:00:15 UTC, John Colvin wrote: On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev wrote: On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote: Trying on d.godbolt.com

Re: The amazing template which does nothing

2015-04-29 Thread John Colvin via Digitalmars-d
On Wednesday, 29 April 2015 at 07:49:34 UTC, Iain Buclaw wrote: On 29 Apr 2015 09:05, John Colvin via Digitalmars-d digitalmars-d@puremagic.com wrote: On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev wrote: On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote

Re: D audio playing and analysis library?

2015-04-28 Thread John Colvin via Digitalmars-d
On Tuesday, 28 April 2015 at 13:43:02 UTC, Gan wrote: On Tuesday, 28 April 2015 at 11:28:42 UTC, Dragos Carp wrote: On Tuesday, 28 April 2015 at 11:18:14 UTC, Gan wrote: I found this: https://github.com/p0nce/dplug Which seems to be a good analysis library but I haven't found a library to

Re: The amazing template which does nothing

2015-04-28 Thread John Colvin via Digitalmars-d
On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote: On Tuesday, 28 April 2015 at 10:18:49 UTC, John Colvin wrote: On Tuesday, 28 April 2015 at 10:18:12 UTC, John Colvin wrote: On Tuesday, 28 April 2015 at 10:07:43 UTC, Andrea Fontana wrote: On Tuesday, 28 April 2015 at 09:23:53

Re: Possible to write a classic fizzbuzz example using a UFCS chain?

2015-04-28 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 28 April 2015 at 16:06:16 UTC, Andrea Fontana wrote: On Tuesday, 28 April 2015 at 13:59:48 UTC, Ivan Kazmenko wrote: On Tuesday, 28 April 2015 at 10:46:54 UTC, Gary Willoughby wrote: After reading the following thread:

Re: The amazing template which does nothing

2015-04-28 Thread John Colvin via Digitalmars-d
On Tuesday, 28 April 2015 at 10:18:12 UTC, John Colvin wrote: On Tuesday, 28 April 2015 at 10:07:43 UTC, Andrea Fontana wrote: On Tuesday, 28 April 2015 at 09:23:53 UTC, Chris wrote: And this has happened to me many times. The solution Break the UFCS chain and use a local temporary variable

Re: The amazing template which does nothing

2015-04-28 Thread John Colvin via Digitalmars-d
On Tuesday, 28 April 2015 at 10:07:43 UTC, Andrea Fontana wrote: On Tuesday, 28 April 2015 at 09:23:53 UTC, Chris wrote: And this has happened to me many times. The solution Break the UFCS chain and use a local temporary variable makes me angry, because by having to do so all the beauty of

Re: array operations and ranges

2015-04-27 Thread John Colvin via Digitalmars-d
On Monday, 27 April 2015 at 06:52:11 UTC, Manu wrote: On 27 April 2015 at 15:58, Vlad Levenfeld via Digitalmars-d digitalmars-d@puremagic.com wrote: Phobos containers already support the first line, and it would be a natural extension to make them support the second. Sure, it's not

Re: Cleaned up C++

2015-04-25 Thread John Colvin via Digitalmars-d
On Saturday, 25 April 2015 at 21:26:25 UTC, Andrei Alexandrescu wrote: On 4/22/15 1:36 PM, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are technically dead and 2) Modern compilers can't tell they are dead and elide them and 3) Doing

Re: Performance of loops

2015-04-24 Thread John Colvin via Digitalmars-d
On Friday, 24 April 2015 at 11:00:23 UTC, Chris wrote: I tested the performance of three types of loops (see code below). It turns out that the fastest loop is the plainLoop. Unless my examples are completely screwed up, the difference between plainLoop and the other two loops is gigantic

Re: Performance of map!()

2015-04-24 Thread John Colvin via Digitalmars-d
On Friday, 24 April 2015 at 10:22:05 UTC, Chris wrote: I replaced a range that was similar to map with map and the performance dropped by ~0.5 msec. The range I used previously is based on Adam's D Cookbook. It is consistently faster than map. private struct Transformer(alias agent, R) if

Re: [OT] compiler optimisations

2015-04-24 Thread John Colvin via Digitalmars-d
On Friday, 24 April 2015 at 06:29:55 UTC, deadalnix wrote: On Thursday, 23 April 2015 at 10:23:57 UTC, Andrea Fontana wrote: On Thursday, 23 April 2015 at 10:08:24 UTC, John Colvin wrote: asm.dlang.org and d.godbolt.org This isn't a D-specific question though, so gcc.godbolt.org would

Re: Performance of map!()

2015-04-24 Thread John Colvin via Digitalmars-d
On Friday, 24 April 2015 at 10:22:05 UTC, Chris wrote: I replaced a range that was similar to map with map and the performance dropped by ~0.5 msec. The range I used previously is based on Adam's D Cookbook. It is consistently faster than map. private struct Transformer(alias agent, R) if

Re: Cleaned up C++

2015-04-24 Thread John Colvin via Digitalmars-d
On Friday, 24 April 2015 at 12:34:19 UTC, ponce wrote: On Friday, 24 April 2015 at 08:16:40 UTC, Walter Bright wrote: On 4/24/2015 12:23 AM, John Colvin wrote: Except of course that alloca is a lot cheaper than malloc/free. That's not necessarily true. But in any case, go ahead and use

Re: Cleaned up C++

2015-04-24 Thread John Colvin via Digitalmars-d
On Friday, 24 April 2015 at 01:54:11 UTC, Walter Bright wrote: On 4/23/2015 3:11 PM, deadalnix wrote: For arbitrary large, you can always do something like : Item* itemPtr = (arbitrarylarge thresold) ? alloca(arbitrarylarge) : GC.alloc(arbitrarylarge); One extra check compared to a heap

Re: Cleaned up C++

2015-04-23 Thread John Colvin via Digitalmars-d
On Thursday, 23 April 2015 at 14:29:01 UTC, Ola Fosheim Grøstad wrote: Can you give a specific example where all 3 points are satisfied? Not sure why you would need it, plenty of cases where compilers will fail. E.g. queues between threads (like real time threads) where you allocate in one

Re: Cleaned up C++

2015-04-23 Thread John Colvin via Digitalmars-d
On Thursday, 23 April 2015 at 18:37:47 UTC, Walter Bright wrote: On 4/23/2015 1:10 AM, bearophile wrote: Walter Bright: On 4/22/2015 2:58 PM, bearophile wrote: D is less stack-friendly than Ada (and probably Rust too), ?? In Ada standard library you have safe fixed-size stack-allocated

Re: Cleaned up C++

2015-04-23 Thread John Colvin via Digitalmars-d
On Thursday, 23 April 2015 at 01:45:14 UTC, deadalnix wrote: On Wednesday, 22 April 2015 at 20:36:12 UTC, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are technically dead and 2) Modern compilers can't tell they are dead and elide them

[OT] compiler optimisations

2015-04-23 Thread John Colvin via Digitalmars-d
Why can no compiler I try optimise this toy example as I would expect? // uncomment if using a C compiler // typedef unsigned int uint; uint foo(uint a) { if (a 5) return (a * 3) / 3; else return 0; } So, I would expect the compiler to be able to see that it is equivalent to

Re: [OT] compiler optimisations

2015-04-23 Thread John Colvin via Digitalmars-d
On Thursday, 23 April 2015 at 08:56:38 UTC, rumbu wrote: On Thursday, 23 April 2015 at 08:33:56 UTC, John Colvin wrote: Why can no compiler I try optimise this toy example as I would expect? // uncomment if using a C compiler // typedef unsigned int uint; uint foo(uint a) { if (a 5

Re: Return data from different types of conditional operation

2015-04-23 Thread John Colvin via Digitalmars-d-learn
On Thursday, 23 April 2015 at 09:48:21 UTC, Dennis Ritchie wrote: Hi, Why the program can not return different types of data from the conditional operator? - import std.stdio; auto foo() { if (true) { return 0; } else return true; } void

Re: [OT] compiler optimisations

2015-04-23 Thread John Colvin via Digitalmars-d
On Thursday, 23 April 2015 at 10:04:47 UTC, Rikki Cattermole wrote: On 23/04/2015 10:02 p.m., Andrea Fontana wrote: On Thursday, 23 April 2015 at 08:33:56 UTC, John Colvin wrote: Why can no compiler I try optimise this toy example as I would expect? // uncomment if using a C compiler

Re: [OT] compiler optimisations

2015-04-23 Thread John Colvin via Digitalmars-d
On Thursday, 23 April 2015 at 12:37:12 UTC, Ola Fosheim Grøstad wrote: On Thursday, 23 April 2015 at 08:56:38 UTC, rumbu wrote: I think because of the potential overflow in a * 3 (if we ignore the a 5 condition). To optimize this, a compiler must figure out that there is no overflow for any a

Re: oversight with input ranges

2015-04-22 Thread John Colvin via Digitalmars-d
On Wednesday, 22 April 2015 at 16:02:51 UTC, Steven Schveighoffer wrote: On 4/21/15 7:31 PM, ketmar wrote: On Tue, 21 Apr 2015 18:57:50 -0400, Steven Schveighoffer wrote: On 4/21/15 3:53 PM, ketmar wrote: here's the interesting oversight for isInputRange:

Re: WTF: dmd 2.066 vs. dmd 2.067 really dangerous code breakage

2015-04-22 Thread John Colvin via Digitalmars-d
On Wednesday, 22 April 2015 at 14:13:01 UTC, Jonathan M Davis wrote: On Wednesday, April 22, 2015 11:28:43 Daniel Kozak via Digitalmars-d wrote: This code compile fine under both versions: dmd (2.066, -debug -d): OK dmd (2.067, -debug -d): core.exception.AssertError@main.d(24): Assertion

Re: SDC needs you -- redux

2015-04-22 Thread John Colvin via Digitalmars-d
On Wednesday, 22 April 2015 at 16:27:59 UTC, Wyatt wrote: On Wednesday, 22 April 2015 at 15:44:03 UTC, Dan Olson wrote: Super and Hyper keys A veteran of the Lisp machines! I've been hoping for someone to manufacture a modern keyboard with these for about a decade now. (Well, I'm pretty

Re: SDC needs you -- redux

2015-04-22 Thread John Colvin via Digitalmars-d
On Wednesday, 22 April 2015 at 17:52:25 UTC, Wyatt wrote: On Wednesday, 22 April 2015 at 17:31:47 UTC, John Colvin wrote: Most keyboards have some kind of Windows key, on macs it's called cmd. You can use that key for whatever you want, surely? No, I'm very sure neither my Model M nor my

Re: Cleaned up C++

2015-04-22 Thread John Colvin via Digitalmars-d
On Wednesday, 22 April 2015 at 20:29:49 UTC, Walter Bright wrote: On 4/22/2015 12:51 PM, ponce wrote: I didn't appreciate how important default initialization was before having to fix a non-deterministic, release-only, time-dependent bug in a video encoder some months ago. Just because of 2

Re: Cleaned up C++

2015-04-22 Thread John Colvin via Digitalmars-d
On Wednesday, 22 April 2015 at 21:59:48 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 22 April 2015 at 20:36:12 UTC, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are technically dead and 2) Modern compilers can't tell they are dead

Re: WTF: dmd 2.066 vs. dmd 2.067 really dangerous code breakage

2015-04-22 Thread John Colvin via Digitalmars-d
On Wednesday, 22 April 2015 at 11:28:44 UTC, Daniel Kozak wrote: This code compile fine under both versions: dmd (2.066, -debug -d): OK dmd (2.067, -debug -d): core.exception.AssertError@main.d(24): Assertion failure ./main() [0x46413f] ./main(_Dmain+0x86) [0x449996]

Re: WTF: dmd 2.066 vs. dmd 2.067 really dangerous code breakage

2015-04-22 Thread John Colvin via Digitalmars-d
On Wednesday, 22 April 2015 at 11:29:30 UTC, Daniel Kozak wrote: On Wednesday, 22 April 2015 at 11:28:44 UTC, Daniel Kozak wrote: static struct S { immutable FLAG_ON = 1; immutable FLAG_GPRS = 2; immutable FLAG_HIDDEN = 4; ubyte flags; ubyte value; bool

Re: Example for Documentation?

2015-04-21 Thread John Colvin via Digitalmars-d
On Tuesday, 21 April 2015 at 17:30:08 UTC, Steven Schveighoffer wrote: for example, RedBlackTree!(int, a b) is not compatible with RedBlackTree!(int, ab), even though they are identical. I'm pretty sure this can and should be fixed. Removing whitespace before creating the function would be

Re: how does isInputRange(T) actually work?

2015-04-21 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote: enum bool isInputRange = is(typeof( (inout int = 0) { R r = R.init; // can define a range object if (r.empty) {} // can test for empty r.popFront(); // can invoke popFront() auto h =

Re: Today's programming challenge - How's your Range-Fu ?

2015-04-21 Thread John Colvin via Digitalmars-d
On Tuesday, 21 April 2015 at 13:06:22 UTC, JohnnyK wrote: On Monday, 20 April 2015 at 19:24:01 UTC, Panke wrote: On Monday, 20 April 2015 at 18:03:50 UTC, John Colvin wrote: On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote: To measure the columns needed to print a string, you'll need

Re: Trial migration of Dsource bindings project to Github

2015-04-21 Thread John Colvin via Digitalmars-d-announce
On Monday, 20 April 2015 at 23:42:54 UTC, Vladimir Panteleev wrote: On Monday, 20 April 2015 at 22:57:51 UTC, Stewart Gordon wrote: I committed some updates the other day and they seem they have gone straight into the online repository. Committing is a local (non-network) operation in git, so

Re: Valgrind

2015-04-20 Thread John Colvin via Digitalmars-d-learn
On Monday, 20 April 2015 at 13:28:57 UTC, John Colvin wrote: On Monday, 20 April 2015 at 13:16:23 UTC, Robert M. Münch wrote: Hi, I just found quite old posts about Valgrind and D. Can someone give me a short update, what the state of support for D is and if there is anythings special to take

Re: Valgrind

2015-04-20 Thread John Colvin via Digitalmars-d-learn
On Monday, 20 April 2015 at 13:16:23 UTC, Robert M. Münch wrote: Hi, I just found quite old posts about Valgrind and D. Can someone give me a short update, what the state of support for D is and if there is anythings special to take into account. Thanks a lot. The only special thing to take

Re: Trial migration of Dsource bindings project to Github

2015-04-20 Thread John Colvin via Digitalmars-d-announce
On Sunday, 19 April 2015 at 23:37:58 UTC, Vladimir Panteleev wrote: On Sunday, 19 April 2015 at 23:14:13 UTC, Stewart Gordon wrote: For those of you who are still unfamiliar with GitHub, Stewart, I haven't seen an active D project that WASN'T hosted on GitHub for years now. There's a few

Re: CT-String as a Symbol

2015-04-20 Thread John Colvin via Digitalmars-d-learn
On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote: Is there a way to CT-query the arity of all opIndex and opSlice overloads? Ideally you don't want to have to do that. You'd have to consider alias this and inheritance.

Re: Converting Java code to D

2015-04-20 Thread John Colvin via Digitalmars-d-learn
On Monday, 20 April 2015 at 17:24:30 UTC, bearophile wrote: John Colvin: struct LineStyle { enum NONE = None; enum SOLID = Solid; enum DASH = Dash; enum DOT = Dot; enum DASHDOT = Dash Dot; enum DASHDOTDOT = Dash Dot Dot; string label; private this(string label

Re: Valgrind

2015-04-20 Thread John Colvin via Digitalmars-d-learn
On Monday, 20 April 2015 at 16:58:18 UTC, Robert M. Münch wrote: On 2015-04-20 13:29:57 +, John Colvin said: On Monday, 20 April 2015 at 13:28:57 UTC, John Colvin wrote: On Monday, 20 April 2015 at 13:16:23 UTC, Robert M. Münch wrote: Hi, I just found quite old posts about Valgrind and D

Re: Today's programming challenge - How's your Range-Fu ?

2015-04-20 Thread John Colvin via Digitalmars-d
On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote: To measure the columns needed to print a string, you'll need the number of graphemes. (d|)?string.length gives you the number of code units. Even that's not really true. In the end it's up to the font and layout engine to decide how much

Re: Converting Java code to D

2015-04-20 Thread John Colvin via Digitalmars-d-learn
On Monday, 20 April 2015 at 15:28:04 UTC, Mike James wrote: Here is a fragment of Java code from an SWT program... public enum LineStyle { NONE(None), SOLID(Solid), DASH(Dash), DOT(Dot), DASHDOT(Dash Dot), DASHDOTDOT(Dash Dot Dot); public final String label;

Re: Today's programming challenge - How's your Range-Fu ?

2015-04-19 Thread John Colvin via Digitalmars-d
On Saturday, 18 April 2015 at 16:01:20 UTC, Andrei Alexandrescu wrote: On 4/18/15 4:35 AM, Jacob Carlborg wrote: On 2015-04-18 12:27, Walter Bright wrote: That doesn't make sense to me, because the umlauts and the accented e all have Unicode code point assignments. This code snippet

Re: Today's programming challenge - How's your Range-Fu ?

2015-04-19 Thread John Colvin via Digitalmars-d
On Saturday, 18 April 2015 at 17:50:12 UTC, Walter Bright wrote: On 4/18/2015 4:35 AM, Jacob Carlborg wrote: \u0301 is the combining acute accent [1]. [1] http://www.fileformat.info/info/unicode/char/0301/index.htm I won't deny what the spec says, but it doesn't make any sense to have two

Re: [hackathon] One week left to the first D Hackathon!

2015-04-19 Thread John Colvin via Digitalmars-d-announce
On Sunday, 19 April 2015 at 13:03:22 UTC, ANtlord wrote: On Saturday, 18 April 2015 at 16:26:41 UTC, Andrei Alexandrescu wrote: Join us for one week starting Saturday April 25th for the first D Hackathon! The D Hackathon is one week of intense participation and collaboration on anything and

Re: [hackathon] One week left to the first D Hackathon!

2015-04-19 Thread John Colvin via Digitalmars-d
On Sunday, 19 April 2015 at 13:03:22 UTC, ANtlord wrote: On Saturday, 18 April 2015 at 16:26:41 UTC, Andrei Alexandrescu wrote: Join us for one week starting Saturday April 25th for the first D Hackathon! The D Hackathon is one week of intense participation and collaboration on anything and

Re: Today's programming challenge - How's your Range-Fu ?

2015-04-18 Thread John Colvin via Digitalmars-d
On Friday, 17 April 2015 at 18:41:59 UTC, Walter Bright wrote: On 4/17/2015 9:59 AM, H. S. Teoh via Digitalmars-d wrote: So either you have to throw out all pretenses of Unicode-correctness and just stick with ASCII-style per-character line-wrapping, or you have to live with byGrapheme with

Re: Linking C++ standard library works with GDC... but not DMD. (Linux)

2015-04-16 Thread John Colvin via Digitalmars-d-learn
On Thursday, 16 April 2015 at 08:51:15 UTC, TheGag96 wrote: Hi, I've got this project that requires me to link into a C++ backend. It works just fine when using GDC: gdc *.d [client libraries] However, this command using DMD does not work: dmd -L-lstdc++ *.d [client libraries] I still get

Re: How about appender.put() with var args?

2015-04-16 Thread John Colvin via Digitalmars-d
On Wednesday, 15 April 2015 at 20:59:25 UTC, Steven Schveighoffer wrote: On 4/15/15 4:51 PM, Messenger wrote: On Wednesday, 15 April 2015 at 19:09:42 UTC, Márcio Martins wrote: Hi! I use Appender a lot, and find it ugly to write this all the time to efficiently construct strings:

<    4   5   6   7   8   9   10   11   12   13   >