Re: Linker error with dmd

2015-10-02 Thread John Colvin via Digitalmars-d-learn
On Friday, 2 October 2015 at 09:43:54 UTC, Chris wrote: Why do I get this error msg with dmd 2.067.1 and 2.068.0 in release mode: $ dub --build=release (.data._D65TypeInfo_xC3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ+0x10): undefined reference to `_D64TypeInfo_C3std5range

Re: Checking that a template parameter is an enum

2015-10-02 Thread John Colvin via Digitalmars-d-learn
On Friday, 2 October 2015 at 08:13:00 UTC, John Colvin wrote: On Thursday, 1 October 2015 at 22:26:39 UTC, Nordlöw wrote: On Thursday, 1 October 2015 at 02:06:48 UTC, Fusxfaranto wrote: [...] Thanks! BTW: Is there some way to turn the recursive definition of `allSame` template allSame(V..

Re: Checking that a template parameter is an enum

2015-10-02 Thread John Colvin via Digitalmars-d-learn
On Thursday, 1 October 2015 at 22:26:39 UTC, Nordlöw wrote: On Thursday, 1 October 2015 at 02:06:48 UTC, Fusxfaranto wrote: /** Returns: true iff all values $(D V) are the same. */ template allSame(V...) // TODO restrict to values only { static if (V.length <= 1) enum bool

Re: WTF does "Enforcement failed" actually mean?

2015-10-01 Thread John Colvin via Digitalmars-d-learn
On Thursday, 1 October 2015 at 07:08:00 UTC, Russel Winder wrote: On Wed, 2015-09-30 at 23:35 -0700, Ali Çehreli via Digitalmars-d-learn wrote: On 09/30/2015 10:46 PM, Russel Winder via Digitalmars-d-learn wrote: > [...] It's coming from the following no-message enforce(): enforc

Re: Get template parameter value

2015-09-29 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 09:53:39 UTC, Kagamin wrote: On Tuesday, 29 September 2015 at 09:11:15 UTC, John Colvin wrote: Welcome to the weird and wonderful work of http://dlang.org/expression.html#IsExpression No, use template pattern matching instead: struct A(int s){} template B(T:A

Re: enum to flags

2015-09-29 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 03:31:44 UTC, Nicholas Wilson wrote: so I have a bunch of enums (0 .. n) that i also want to represent as flags ( 1 << n foreach n ). Is there anyway to do this other than a string mixin? use like: enum blah { foo, bar, baz, } alias blahFlags = En

Re: Get template parameter value

2015-09-29 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 07:50:42 UTC, rumbu wrote: Having a template: struct SomeStruct(int size) { } Is there any language trait returning the value of size template parameter for the template instantiation SomeStruct!10? This should do it (untested): template SomeStructSize(T) {

Re: Parallel processing and further use of output

2015-09-28 Thread John Colvin via Digitalmars-d-learn
On Monday, 28 September 2015 at 12:18:28 UTC, Russel Winder wrote: As a single data point: == anonymous_fix.d == 5050 real0m0.168s user0m0.200s sys 0m0.380s == colvin_fix.d == 5050 real0m0.036s user0m

Re: Parallel processing and further use of output

2015-09-28 Thread John Colvin via Digitalmars-d-learn
On Monday, 28 September 2015 at 11:31:33 UTC, Russel Winder wrote: On Sat, 2015-09-26 at 14:33 +0200, anonymous via Digitalmars-d-learn wrote: […] I'm pretty sure atomicOp is faster, though. Rough and ready anecdotal evidence would indicate that this is a reasonable statement, by quite a long

Re: Reduce parameters [was pi program]

2015-09-28 Thread John Colvin via Digitalmars-d-learn
On Monday, 28 September 2015 at 11:04:56 UTC, Russel Winder wrote: On Sat, 2015-09-26 at 10:46 +, John Colvin via Digitalmars-d-learn wrote: […] I guess the summary is: it's a breaking change, so do it. No we can't do that it's a breaking change. Seems lame given all the

Re: Parallel processing and further use of output

2015-09-26 Thread John Colvin via Digitalmars-d-learn
On Saturday, 26 September 2015 at 17:20:34 UTC, Jay Norwood wrote: This is a work-around to get a ulong result without having the ulong as the range variable. ulong getTerm(int i) { return i; } auto sum4 = taskPool.reduce!"a + b"(std.algorithm.map!getTerm(iota(11))); or auto sum4

Re: Parallel processing and further use of output

2015-09-26 Thread John Colvin via Digitalmars-d-learn
On Saturday, 26 September 2015 at 12:18:16 UTC, Zoidberg wrote: I've run into an issue, which I guess could be resolved easily, if I knew how... [CODE] ulong i = 0; foreach (f; parallel(iota(1, 100+1))) { i += f; } thread_joinAll(); i.writeln; [/CODE] It's b

Re: Reduce parameters [was pi program]

2015-09-26 Thread John Colvin via Digitalmars-d-learn
On Saturday, 26 September 2015 at 06:28:22 UTC, Russel Winder wrote: On Fri, 2015-09-25 at 12:54 +, John Colvin via Digitalmars-d-learn wrote: […] I vastly prefer the UFCS version, but unfortunately reduce has its arguments the wrong way around for that if you use the version that takes

Re: ORM libraries for D

2015-09-25 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 September 2015 at 13:33:51 UTC, Rikki Cattermole wrote: On 25/09/15 1:30 AM, Edwin van Leeuwen wrote: On Thursday, 24 September 2015 at 13:24:14 UTC, Rikki Cattermole wrote: Dvorm is more or less feature complete :) I am the author of it, but unless issues come up I do not inte

Re: pi program

2015-09-25 Thread John Colvin via Digitalmars-d-learn
On Friday, 25 September 2015 at 12:51:17 UTC, Russel Winder wrote: On Fri, 2015-09-25 at 09:14 +, mzf via Digitalmars-d-learn wrote: [...] Aha, bingo, spot on. Thanks. Amended now to: double reduce_string_loop() { return reduce!"a + 1.0 / (b * b)"(iota(1, 100)); } d

Re: Unexpected behavior when casting away immutable

2015-09-23 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 14:34:07 UTC, bachmeier wrote: On Wednesday, 23 September 2015 at 05:24:05 UTC, John Colvin wrote: violating immutable is undefined behaviour, so the compiler is technically speaking free to assume it never happens. At the very least, neither snippet's resul

Re: Unexpected behavior when casting away immutable

2015-09-22 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 03:39:02 UTC, Mike Parker wrote: I have a situation where I would like to demonstrate violating the contract of immutable (as an example of what not to do), but do so without using structs or classes, just basic types and pointers. The following snippet works

Re: BidirectionalRange switching direction

2015-09-22 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 02:10:22 UTC, Tofu Ninja wrote: Trying to implement a bi directional range and it is slightly unclear what the semantics are supposed to be and just wanted some clarification. Are bidirectional ranges supposed to be able to support switching direction mid it

Re: Debugging D shared libraries

2015-09-22 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 22 September 2015 at 14:37:11 UTC, Russel Winder wrote: On Sun, 2015-09-20 at 17:47 +0200, Johannes Pfau via Digitalmars-d -learn wrote: [...] […] [...] Debian Jessie is far too out of date to be useful. I'm on Debian Sid (still quite old), and Fedora Rawhide (not quite so old)

Re: What difference between std.typecons.Tuple and std.meta.AliasSeq

2015-09-20 Thread John Colvin via Digitalmars-d-learn
On Sunday, 20 September 2015 at 18:28:13 UTC, Alex Parrill wrote: (though you can declare a variable using an AliasSeq containing only types; I think this acts like defining one variable for each type in the seq). This is what is used inside std.typecons.Tuple

Re: How do you handle OutOfMemoryError?

2015-09-20 Thread John Colvin via Digitalmars-d-learn
On Sunday, 20 September 2015 at 00:16:50 UTC, Enjoys Math wrote: Here's my code: https://drive.google.com/file/d/0B3LYxKGJ4ZI_MV91SkxPVVlSOW8/view?usp=sharing I don't have access to a debugger. Run the code for a few minutes and it tends to crash with a core OutOfMemoryError. Any suggestion

Re: Debugging D shared libraries

2015-09-19 Thread John Colvin via Digitalmars-d-learn
On Saturday, 19 September 2015 at 16:15:45 UTC, Russel Winder wrote: Sadly the: pragma(LDC_global_crt_ctor, 0) void initRuntime() { import core.runtime: Runtime; Runtime.initialize(); } will not compile under DMD :-( version(LDC){ /* ... */ } not that it helps make things

Re: Debugging D shared libraries

2015-09-19 Thread John Colvin via Digitalmars-d-learn
On Saturday, 19 September 2015 at 16:25:28 UTC, Laeeth Isharc wrote: On Saturday, 19 September 2015 at 12:21:02 UTC, ponce wrote: [...] What is the difference between shared static this and the global constructor ? Russell, if you use shared static this for dmd does it work ? Laeeth. IIR

Re: Debugging D shared libraries

2015-09-19 Thread John Colvin via Digitalmars-d-learn
On Saturday, 19 September 2015 at 10:45:22 UTC, Russel Winder wrote: Calling D from Python. I have two functions in D, compiled to a shared object on Linux using LDC (but I get same problem using DMD). [...] I heard it crashed during the talk. Bummer. I should really be there, seeing as I l

Re: Templated opIndex?

2015-09-19 Thread John Colvin via Digitalmars-d-learn
On Saturday, 19 September 2015 at 09:33:02 UTC, OlaOst wrote: Here is a class with a templated opIndex method, and an attempt to use it: class Test { int[] numbers = [1, 2, 3]; string[] texts = ["a", "b", "c"]; Type opIndex(Type)(int index) {

Re: Tried release build got ICE, does anyone have a clue what might cause this?

2015-09-19 Thread John Colvin via Digitalmars-d-learn
On Friday, 18 September 2015 at 22:54:43 UTC, Random D user wrote: So I tried to build my project in release for the first time in a long while. It takes like 25x longer to compile and finally the compiler crashes. It seems to go away if I disable the optimizer. I get: tym = x1d Internal erro

Re: "if sting in string"

2015-09-18 Thread John Colvin via Digitalmars-d-learn
On Friday, 18 September 2015 at 11:26:46 UTC, John Colvin wrote: On Friday, 18 September 2015 at 11:18:33 UTC, John Colvin wrote: On Friday, 18 September 2015 at 09:42:05 UTC, smadus wrote: Ok i have rewrite :) Now: http://dpaste.dzfl.pl/cf8bb54b1390 The Problem is: http://www.directupload.n

Re: "if sting in string"

2015-09-18 Thread John Colvin via Digitalmars-d-learn
On Friday, 18 September 2015 at 11:18:33 UTC, John Colvin wrote: On Friday, 18 September 2015 at 09:42:05 UTC, smadus wrote: Ok i have rewrite :) Now: http://dpaste.dzfl.pl/cf8bb54b1390 The Problem is: http://www.directupload.net/file/d/4114/9zryku49_png.htm but i dont understand this, becau

Re: "if sting in string"

2015-09-18 Thread John Colvin via Digitalmars-d-learn
On Friday, 18 September 2015 at 09:42:05 UTC, smadus wrote: Ok i have rewrite :) Now: http://dpaste.dzfl.pl/cf8bb54b1390 The Problem is: http://www.directupload.net/file/d/4114/9zryku49_png.htm but i dont understand this, because, the exception should be "Something wrong" ?!? But, thanks f

Re: Bloat with std.(string.)format?

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 13:42:15 UTC, Chris wrote: On Thursday, 17 September 2015 at 12:49:03 UTC, John Colvin wrote: [...] Thanks. That's up to date enough now. Is it stable, though? Reasonably so in my testing, but expect more bugs than in a full release. For version 2.067.1

Re: Reading Atributes (UDA) of overloaded functions

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 12:40:24 UTC, Ozan wrote: On Thursday, 17 September 2015 at 12:36:42 UTC, John Colvin wrote: On Thursday, 17 September 2015 at 11:47:40 UTC, Ozan wrote: ... use __traits(getAttributes, /*...*/) on each of the members of the result of __traits(getOverloads, /*.

Re: Bloat with std.(string.)format?

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 10:53:17 UTC, Chris wrote: On Thursday, 17 September 2015 at 10:33:44 UTC, John Colvin wrote: Some initial bloat is expected, format is pretty big (although twice as big is a lot, unless your original code was quite small?). It was in a test program. Only a

Re: Reading Atributes (UDA) of overloaded functions

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 11:47:40 UTC, Ozan wrote: Hi! Is it possible to read all attributes in case of overloading functions? Example: struct Att { string name; } struct Att2 { string name; } @Att void testUDA(string x) { writeln("test(string ",x,")"); } @Att2 void testUDA(int x) {

Re: Bloat with std.(string.)format?

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 09:54:07 UTC, Chris wrote: If I have code like this: auto builder = appender!string; builder ~= "Hello, World!"; builder ~= "I'm here!"; builder ~= "Now I'm there!"; the object file grows by 10-11 lines with each call to `builder ~=`. If I use this: builder

Re: "if sting in string"

2015-09-16 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 16 September 2015 at 12:55:13 UTC, smadus wrote: Hello Searching after hours, i give up and here is the question. ;) I will make a programm, this searching all txt files on the system or the path from user and searching a user tiped term in this file. http://dpaste.dzfl.pl/dec

Re: What kind of sorcery is that?

2015-09-16 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 16 September 2015 at 08:28:24 UTC, NX wrote: import std.stdio; void main() { Stuff!(Thing!float) s; writeln(typeid(s.var)); writeln(typeid(s.var.varling)); writeln(typeid(s)); } class Stuff(T) { T!int var; } class Thing(T) { T varling;

Re: Checking for Homogeneous Tuples

2015-09-15 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 16:54:22 UTC, Nordlöw wrote: How do I check that all the elements of a std.typecons.Tuple all fulfil a specific predicate, in my case all have a specific type: Something like import std.typecons : isTuple; enum isTupleOf(T, E) = isTuple!T && is(MAGIC(T

Re: Speeding up text file parser (BLAST tabular format)

2015-09-15 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 13:49:04 UTC, Fredrik Boulund wrote: On Tuesday, 15 September 2015 at 10:01:30 UTC, John Colvin wrote: [...] Nope, :( [...] Oh well, worth a try I guess.

Re: Speeding up text file parser (BLAST tabular format)

2015-09-15 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 13:01:06 UTC, Kagamin wrote: On Tuesday, 15 September 2015 at 09:19:29 UTC, John Colvin wrote: It provides you only one char at a time instead of a whole line. It will be quite constraining for your code if not mind-bending. http://dlang.org/phobos/std_string.

Re: Speeding up text file parser (BLAST tabular format)

2015-09-15 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 08:45:00 UTC, Fredrik Boulund wrote: On Monday, 14 September 2015 at 15:04:12 UTC, John Colvin wrote: [...] Thanks for the offer, but don't go out of your way for my sake. Maybe I'll just build this in a clean environment instead of on my work computer to get

Re: Speeding up text file parser (BLAST tabular format)

2015-09-15 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 09:09:00 UTC, Kagamin wrote: On Tuesday, 15 September 2015 at 08:53:37 UTC, Fredrik Boulund wrote: my favourite for streaming a file: enum chunkSize = 4096; File(fileName).byChunk(chunkSize).map!"cast(char[])a".joiner() Is this an efficient way of reading this

Re: Speeding up text file parser (BLAST tabular format)

2015-09-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 September 2015 at 17:51:43 UTC, CraigDillabaugh wrote: On Monday, 14 September 2015 at 12:30:21 UTC, Fredrik Boulund wrote: [...] I am going to go off the beaten path here. If you really want speed for a file like this one way of getting that is to read the file in as a single

Re: Speeding up text file parser (BLAST tabular format)

2015-09-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 September 2015 at 16:33:23 UTC, Rikki Cattermole wrote: On 15/09/15 12:30 AM, Fredrik Boulund wrote: [...] A lot of this hasn't been covered I believe. http://dpaste.dzfl.pl/f7ab2915c3e1 1) You don't need to convert char[] to string via to. No. Too much. Cast it. Not a good

Re: chaining chain Result and underlying object of chain

2015-09-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 September 2015 at 15:30:14 UTC, Ali Çehreli wrote: On 09/14/2015 08:01 AM, Laeeth Isharc wrote: > I was trying to use the same variable eg > >auto chain1 = chain("foo", "bar"); >chain1 = chain(chain1, "baz"); [...] > It may be that the type of chain1 > and chain2 don

Re: how do I check if a member of a T has a member ?

2015-09-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 September 2015 at 15:04:00 UTC, Laeeth Isharc wrote: On Monday, 14 September 2015 at 14:21:12 UTC, John Colvin wrote: On Monday, 14 September 2015 at 14:05:01 UTC, Laeeth Isharc wrote: On Sunday, 13 September 2015 at 17:34:11 UTC, BBasile wrote: On Sunday, 13 September 2015 at 17:

Re: Speeding up text file parser (BLAST tabular format)

2015-09-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 September 2015 at 14:35:26 UTC, Fredrik Boulund wrote: On Monday, 14 September 2015 at 14:28:41 UTC, John Colvin wrote: Yup, glibc is too old for those binaries. What does "ldd --version" say? It says "ldd (GNU libc) 2.12". Hmm... The most recent version in RHEL's repo is "2.12

Re: Speeding up text file parser (BLAST tabular format)

2015-09-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 September 2015 at 14:25:04 UTC, Fredrik Boulund wrote: On Monday, 14 September 2015 at 14:14:18 UTC, John Colvin wrote: what system are you on? What are the error messages you are getting? I really appreciate your will to try to help me out. This is what ldd shows on the latest

Re: chaining chain Result and underlying object of chain

2015-09-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 September 2015 at 14:17:51 UTC, Laeeth Isharc wrote: chain doesn't seem to compile if I try and chain a chain of two strings and another string. what should I use instead? Laeeth. Works for me: http://dpaste.dzfl.pl/a692281f7a80

Re: how do I check if a member of a T has a member ?

2015-09-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 September 2015 at 14:05:01 UTC, Laeeth Isharc wrote: On Sunday, 13 September 2015 at 17:34:11 UTC, BBasile wrote: On Sunday, 13 September 2015 at 17:24:20 UTC, Laeeth Isharc wrote: [...] can't you use 'hasMember' (either with __traits() or std.traits.hasMember)? It's more idiom

Re: Speeding up text file parser (BLAST tabular format)

2015-09-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 September 2015 at 13:58:33 UTC, Fredrik Boulund wrote: On Monday, 14 September 2015 at 13:37:18 UTC, John Colvin wrote: On Monday, 14 September 2015 at 13:05:32 UTC, Andrea Fontana wrote: On Monday, 14 September 2015 at 12:30:21 UTC, Fredrik Boulund wrote: [...] Also if problem

Re: Speeding up text file parser (BLAST tabular format)

2015-09-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 September 2015 at 13:50:22 UTC, Fredrik Boulund wrote: On Monday, 14 September 2015 at 13:05:32 UTC, Andrea Fontana wrote: [...] Thanks for the suggestions! I'm not too familiar with compiled languages like this, I've mainly written small programs in D and run them via `rdmd` i

Re: Speeding up text file parser (BLAST tabular format)

2015-09-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 September 2015 at 13:05:32 UTC, Andrea Fontana wrote: On Monday, 14 September 2015 at 12:30:21 UTC, Fredrik Boulund wrote: [...] Also if problem probabily is i/o related, have you tried with: -O -inline -release -noboundscheck ? -inline in particular is likely to have a strong

Re: best way to memoize a range?

2015-09-11 Thread John Colvin via Digitalmars-d-learn
On Friday, 11 September 2015 at 13:09:33 UTC, Laeeth Isharc wrote: obviously it's trivial to do with a little aa cache. and I know I can memoize a function, and turn the memoized version into an infinite range. but suppose I have a lazy function that returns a finite range, and its expensive

Re: Huge output size for simple programs

2015-09-11 Thread John Colvin via Digitalmars-d-learn
On Friday, 11 September 2015 at 11:15:33 UTC, NX wrote: I compile a simple hello world program in C and the results: hello_world.o -> 1.5 KB hello_world (linux executable) -> 8.5 KB Then I compile a simple hello world program in D (using DMD) and the results: hello_world.o -> 9.3 KB hello_w

Re: stuck on opDiv / opBinary

2015-08-30 Thread John Colvin via Digitalmars-d-learn
On Sunday, 30 August 2015 at 17:02:58 UTC, Spacen Jasset wrote: I have just added an opDiv to this class, but it doesn't seem to pick it up. math/vector.d(30): Error: 'this /= mag' is not a scalar, it is a Vector3 I can't see why that is, becuase my opMul works in the same place. Can anyone p

Re: Pointer to std.container.Array data for C library

2015-08-28 Thread John Colvin via Digitalmars-d-learn
On Friday, 28 August 2015 at 18:31:00 UTC, Oleg wrote: On Friday, 28 August 2015 at 18:21:04 UTC, John Colvin wrote: On Friday, 28 August 2015 at 17:45:21 UTC, Oleg wrote: Hello! Is it possible to get pointer to a data in std.container.Array like .ptr from an array? I need to pass a pointer t

Re: Pointer to std.container.Array data for C library

2015-08-28 Thread John Colvin via Digitalmars-d-learn
On Friday, 28 August 2015 at 17:45:21 UTC, Oleg wrote: Hello! Is it possible to get pointer to a data in std.container.Array like .ptr from an array? I need to pass a pointer to some C function (from DerelictGL3 binding) and avoid GC allocation. Thank you! I'm pretty sure you can just take t

Re: Digger 2.3 & verstr.h problem

2015-08-24 Thread John Colvin via Digitalmars-d-learn
On Monday, 24 August 2015 at 09:13:56 UTC, Robert M. Münch wrote: On 2015-08-23 16:23:57 +, John Colvin said: almost certainly a consequence of the recent switchover to the dmd frontend being written in D. Have you tried building the latest Digger git HEAD first? If that doesn't work I sug

order of declaration/definition

2015-08-23 Thread John Colvin via Digitalmars-d-learn
enum A = 1; enum B = C; //Error static if(A) enum C = 0; enum D = C; //OK Is order supposed to matter here?

Re: How to use ranges?

2015-08-23 Thread John Colvin via Digitalmars-d-learn
Generally, dynamic arrays / slices are random-access ranges. Narrow strings (string/wstring/char[]/wchar[]/...) are a notable exception to this. They are dynamic arrays of UTF-8/UTF-16 code units. But they're not random-access ranges of Unicode code units. Instead, they're _forward_ ranges of

Re: Digger 2.3 & verstr.h problem

2015-08-23 Thread John Colvin via Digitalmars-d-learn
On Sunday, 23 August 2015 at 11:27:32 UTC, Robert M. Münch wrote: Hi, just trying to build the latest DMD with Digger 2.3 and get this: uffer.d root/port.d root/response.d root/rmem.d root/rootobject.d root/speller.d root/stringtable.d newdelete.o glue.a backend.a globals.d(293): Error: file

Re: flush MessageBox

2015-08-21 Thread John Colvin via Digitalmars-d-learn
On Friday, 21 August 2015 at 14:35:53 UTC, Chris wrote: On Friday, 21 August 2015 at 12:59:09 UTC, John Colvin wrote: [...] Wouldn't it be easier to have a library function that can empty the mailbox immediately? It's a waste of time to have all items in the mailbox crash against a wall, bef

Re: flush MessageBox

2015-08-21 Thread John Colvin via Digitalmars-d-learn
On Friday, 21 August 2015 at 10:43:22 UTC, Chris wrote: On Thursday, 20 August 2015 at 15:57:47 UTC, John Colvin wrote: On Thursday, 20 August 2015 at 15:25:57 UTC, Chris wrote: Is there a way to flush a thread's message box other than aborting the thread? MailBox is private: https://github.c

Re: New to D - playing with Thread and false Sharing

2015-08-21 Thread John Colvin via Digitalmars-d-learn
On Friday, 21 August 2015 at 02:44:50 UTC, Rikki Cattermole wrote: On 8/21/2015 3:37 AM, Dejan Lekic wrote: Keep in mind that in D everything is thread-local by default! :) For shared resources use __gshared or shared (although I do not know for sure whether shared works or not). Note: share

Re: flush MessageBox

2015-08-20 Thread John Colvin via Digitalmars-d-learn
On Thursday, 20 August 2015 at 15:25:57 UTC, Chris wrote: Is there a way to flush a thread's message box other than aborting the thread? MailBox is private: https://github.com/D-Programming-Language/phobos/blob/master/std/concurrency.d#L1778 flush from inside the thread? You could call receiv

Re: ReturnType of lambda templates

2015-08-18 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 18 August 2015 at 14:25:34 UTC, Roland Hadinger wrote: Hi! Suppose I wanna do this (which already works, which is why D is pretty cool): import std.traits; import std.typecons : Nullable; // Retrofit Nullable to allow for monadic chaining // auto apply( alias

Re: Compiletime Vs Runtime bencmarks

2015-08-18 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 18 August 2015 at 07:16:32 UTC, D_Learner wrote: On Monday, 17 August 2015 at 22:01:32 UTC, John Colvin wrote: On Monday, 17 August 2015 at 17:48:22 UTC, D_Learner wrote: On Monday, 17 August 2015 at 14:52:18 UTC, Edwin van Leeuwen wrote: [...] The surprisingly, the D-profiler gi

Re: Compiletime Vs Runtime bencmarks

2015-08-17 Thread John Colvin via Digitalmars-d-learn
On Monday, 17 August 2015 at 17:48:22 UTC, D_Learner wrote: On Monday, 17 August 2015 at 14:52:18 UTC, Edwin van Leeuwen wrote: [...] The surprisingly, the D-profiler gives plausible results:- Algorithm1 2921 int rtime_pre.bm_rmatch (runtime ) 2122 int ctime_pre.bm_cmatch

Re: A couple questions about a simple project

2015-08-17 Thread John Colvin via Digitalmars-d-learn
On Monday, 17 August 2015 at 15:05:56 UTC, Andre Polykanine wrote: Hi everyone, I'm new to D (I'm learning it by reading the great online book by Ali Çehreli - thank you very much for it, sir!), and, more than that, programming is my hobby, so please bear with me if I'm asking stupid

Re: countUntil for SortedRange

2015-08-11 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 11 August 2015 at 19:30:02 UTC, Laeeth Isharc wrote: Hi. Basic question: suppose I have a SortedRange and want to find the index of the first entry of an array of structs matching a needle struct. What's the best way to do that? It's not clear that countUntil treats a SortedRan

Re: Find on sorted range slower?

2015-08-06 Thread John Colvin via Digitalmars-d-learn
On Friday, 7 August 2015 at 00:35:58 UTC, Tofu Ninja wrote: void main() { auto a = new int[100*1024*1024]; for(int i = 0; i < 100*1024*1024; i++) { a[i] = i; } enum f = 100*1024*1000; StopWatch sw; { sw.star

Re: Creating a Priority Queue: An Adventure

2015-08-06 Thread John Colvin via Digitalmars-d-learn
On Thursday, 6 August 2015 at 08:44:17 UTC, Per Nordlöw wrote: On Wednesday, 5 August 2015 at 18:20:41 UTC, John Colvin wrote: [...] I suggest you rehearse on how a binary heap works. A binary heap with array storage trades speed for memory compactness, a bit similar to how quick sort relate

Re: Creating a Priority Queue: An Adventure

2015-08-05 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 5 August 2015 at 15:29:39 UTC, Nordlöw wrote: On Wednesday, 5 August 2015 at 13:37:19 UTC, John Colvin wrote: On Wednesday, 5 August 2015 at 11:09:29 UTC, Per Nordlöw wrote: On Wednesday, 5 August 2015 at 09:04:54 UTC, Nordlöw wrote: This will however duplicate the underlying arra

Re: Creating a Priority Queue: An Adventure

2015-08-05 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 5 August 2015 at 11:09:29 UTC, Per Nordlöw wrote: On Wednesday, 5 August 2015 at 09:04:54 UTC, Nordlöw wrote: This will however duplicate the underlying array aswell, which is probably not what we want. How do we avoid this? Correction: the underlying storage array *must* be dupl

Re: Concurrency Confusion

2015-08-04 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 4 August 2015 at 08:03:54 UTC, 岩倉 澪 wrote: Hi all, I'm a bit confused today (as usual, haha). I have a pointer to a struct (let's call it Foo) allocated via a C library. I need to do some expensive computation with the Foo* to create a Bar[], but I would like to do that computation

Re: DUB linking to local library

2015-08-04 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 4 August 2015 at 03:20:38 UTC, Craig Dillabaugh wrote: I can now run it with: LD_LIBRARY_PATH=/home/craig2/code/gdal-2.0.0/lib64 ./gdaltest But it appears the LD_LIBRARY_PATH hack is causing havoc with other libraries, as I get errors loading other shared libraries when I do that.

Re: Calling Syntax (no, not UFCS)

2015-08-03 Thread John Colvin via Digitalmars-d-learn
On Monday, 3 August 2015 at 22:42:15 UTC, SirNickolas wrote: Hello! I'm new in D and it is amazing! Can you tell me please if it is discouraged or deprecated to call a function by just putting its name, without brackets? It's quite unusual for me (used C++ and Python before), but I can see th

Re: Array start index

2015-08-01 Thread John Colvin via Digitalmars-d-learn
On Saturday, 1 August 2015 at 09:35:53 UTC, DLearner wrote: Does the D language set in stone that the first element of an array _has_ to be index zero? For the builtin slice types? Yes, set in stone. Wouldn't starting array elements at one avoid the common 'off-by-one' logic error, it does s

Re: Struct that destroys its original handle on copy-by-value

2015-08-01 Thread John Colvin via Digitalmars-d-learn
On Saturday, 1 August 2015 at 12:10:43 UTC, Joseph Rushton Wakeling wrote: On 31/07/15 19:21, Ali Çehreli via Digitalmars-d-learn wrote: On 07/26/2015 04:29 AM, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: > is this design idea even feasible in principle, or just a bad > idea fro

Re: Can't Compile Global Semaphores?

2015-07-27 Thread John Colvin via Digitalmars-d-learn
On Monday, 27 July 2015 at 19:56:15 UTC, Steven Schveighoffer wrote: On 7/27/15 3:10 PM, Jack Stouffer wrote: Hi, I am currently working through a book on the fundamentals of computer concurrency and I wanted to do all of the exercises in D. But I ran into a problem when I tried to have a gl

Re: Getting "this" to work similar to "self" in Python

2015-07-23 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 22:52:22 UTC, John Colvin wrote: On Wednesday, 22 July 2015 at 22:22:02 UTC, nurfz wrote: [...] Fields of classes are not in any way polymorphic in D (this is the same as C++ and I think java too). Base class members can be accessed like so: class Vehicle {

Re: Getting "this" to work similar to "self" in Python

2015-07-22 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 22:22:02 UTC, nurfz wrote: How could I get this D code to work similar to this Python code? So, here is the D code: import std.stdio; class Vehicle { int speed; void printSpeed() { writeln(this.speed); } } class

Re: Thread pools

2015-07-22 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 15:51:23 UTC, Chris wrote: On Wednesday, 22 July 2015 at 15:41:06 UTC, Alex Parrill wrote: On Wednesday, 22 July 2015 at 14:28:48 UTC, Chris wrote: What would be the best way to manage different threads (spawned via std.concurrency), e.g. to tell them to stop at o

Re: Measuring Execution time

2015-07-22 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 09:23:36 UTC, Clayton wrote: How does one represent Duration in only Micro-seconds, or milliseconds. Trying to measure the execution time of an algorithm and I get "4 ms, 619 μs, and 8 hnsecs" , I want to sum all these and get total hnsecs or μs . I would also a

Re: GLU in DerelictOrg

2015-07-21 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 21 July 2015 at 12:26:30 UTC, Spacen Jasset wrote: It seems that Derelict3 contains GLUT whereas derelict2 containss GLU. It appears I need GLU but I am somewhat confused as to what the diffrence is. Whoops, yes you are right, my mistake. Isn't glu considered legacy these days?

Re: GLU in DerelictOrg

2015-07-21 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 21 July 2015 at 11:08:13 UTC, Spacen Jasset wrote: Hello, Can anyone tell me if the GLU functions, gluSpehere etc are availble in DerelictOrg or have they been removed. I can replace these with my own versions, but was hoping to do a quick port to DerelictOrg They are not availa

Re: std.algorithm each documentation terse

2015-07-20 Thread John Colvin via Digitalmars-d-learn
On Monday, 20 July 2015 at 14:40:59 UTC, jmh530 wrote: I have found the documentation for each in std.algorithm a bit terse. It seemed like it was an eager version of map, but it seems to be a bit more limited than that. In particular, the documentation says that if you can mutate the value i

Re: Wrapping a C-style Array (Pointer + Length) in a Range Interface

2015-07-07 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 7 July 2015 at 12:33:23 UTC, Per Nordlöw wrote: On Tuesday, 7 July 2015 at 12:29:04 UTC, Rikki Cattermole wrote: size_t count; AVStream* thePtr; AVStream[] array = thePtr[0 .. count]; That should work. Thanks. Will that reuse the existing allocate memory at `thePtr` for internal

Re: optimizing struct/class members

2015-07-06 Thread John Colvin via Digitalmars-d-learn
On Monday, 6 July 2015 at 23:24:00 UTC, lobo wrote: Hi, In C++ it's important to layout struct/class members correctly for performance reasons. Is the same true in D? Thanks, lobo Short answer: yes.

Re: turning an array of structs into a struct of arrays

2015-07-06 Thread John Colvin via Digitalmars-d-learn
On Monday, 6 July 2015 at 17:35:22 UTC, Vlad Levenfeld wrote: On Sunday, 5 July 2015 at 00:07:59 UTC, Laeeth Isharc wrote: Posted short write-up here. Please make it better... http://wiki.dlang.org/Transforming_slice_of_structs_into_struct_of_slices In John Colvin's solution, should al

Re: How to strip struct/class invariants?

2015-07-06 Thread John Colvin via Digitalmars-d-learn
On Sunday, 5 July 2015 at 15:39:50 UTC, Artem Tarasov wrote: On Sunday, 5 July 2015 at 14:44:30 UTC, John Colvin wrote: struct A { ubyte[B.sizeof] mem; @property ref B b() { return *cast(B*)(mem.ptr); } mixin std.typecons.Proxy!b; } Thanks, I followed your suggest

Re: How to strip struct/class invariants?

2015-07-05 Thread John Colvin via Digitalmars-d-learn
On Sunday, 5 July 2015 at 12:15:32 UTC, Artem Tarasov wrote: OK, so there was an old bug fixed in 2.067 (https://issues.dlang.org/show_bug.cgi?id=4421) so that now unions apparently can't contain a struct that has invariants. It kinda makes sense, although I don't see why the invariants can be

Re: turning an array of structs into a struct of arrays

2015-07-03 Thread John Colvin via Digitalmars-d-learn
On Friday, 3 July 2015 at 10:52:03 UTC, Laeeth Isharc wrote: I have an array of structs eg struct PriceBar { DateTime date; double open; double high; double low; double close; } (which fields are present in this particular struct will depend on template arguments). what is the best

Re: Casting MapResult

2015-06-23 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 23 June 2015 at 01:27:21 UTC, jmh530 wrote: On Tuesday, 16 June 2015 at 16:37:35 UTC, John Colvin wrote: If you want really fast exponentiation of an array though, you want to use SIMD. Something like http://www.yeppp.info would be easy to use from D. I've been looking into SIMD a

Re: best way to interface D code to Excel

2015-06-18 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 18:35:36 UTC, Laeeth Isharc wrote: Hi. Any thoughts on the best way to write D functions that I can call from Excel? I am completely unfamiliar with Windows programming and COM (last time I wrote this kind of thing was in the mid-90s I think using xloper and C).

Re: Embedding dll in a D project

2015-06-17 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 17:32:33 UTC, CallToDuty wrote: On Tuesday, 16 June 2015 at 16:57:52 UTC, John Colvin wrote: On Tuesday, 16 June 2015 at 16:42:31 UTC, CallToDuty wrote: Is it possible to embed a dll file within dub project? and if yes, how? Have you tried just putting it in the ro

Re: Embedding dll in a D project

2015-06-16 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 16:42:31 UTC, CallToDuty wrote: Is it possible to embed a dll file within dub project? and if yes, how? Have you tried just putting it in the root directory of the project and adding the relevant name to the "libs" setting in your dub.json ?

Re: Embedding dll in a D project

2015-06-16 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 16:42:31 UTC, CallToDuty wrote: Is it possible to embed a dll file within dub project? and if yes, how? Do you want to write the DLL in D or another language?

Re: Casting MapResult

2015-06-16 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 14:43:17 UTC, jmh530 wrote: On Tuesday, 16 June 2015 at 13:15:05 UTC, John Colvin wrote: *consistent as in different implementations performing very similarly instead of seeing big differences like you have here. That's a good point. I tried numpy's exp (which us

Re: Casting MapResult

2015-06-16 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 14:43:17 UTC, jmh530 wrote: On Tuesday, 16 June 2015 at 13:15:05 UTC, John Colvin wrote: *consistent as in different implementations performing very similarly instead of seeing big differences like you have here. That's a good point. I tried numpy's exp (which us

<    1   2   3   4   5   6   >