Re: general questions about static this() at module level

2016-10-30 Thread sarn via Digitalmars-d-learn
On Monday, 31 October 2016 at 04:35:35 UTC, WhatMeWorry wrote: First, are there any other languages that has this feature? The few I know, certainly don't. I've seen hacks to do the same thing in C++. They're not pretty, though. And how would you compare and contrast these this(s) with

general questions about static this() at module level

2016-10-30 Thread WhatMeWorry via Digitalmars-d-learn
I am fascinated with D's module static this. I have shamelessly stolen Ali's code directly from his book. module cat; static this() { // ... the initial operations of the module ... } static ~this() { // ... the final operations of the module ... } First, are there any other languages that

Re: strange -fPIC compilation error

2016-10-30 Thread Charles Hixson via Digitalmars-d-learn
On 10/30/2016 05:14 PM, Lodovico Giaretta via Digitalmars-d-learn wrote: On Monday, 31 October 2016 at 00:08:59 UTC, Charles Hixson wrote: So now I removed the repository version of dmd and dub, downloaded DMD64 D Compiler v2.072.0-b2, used dkpg to install it, and appear to get the same

Re: Parse a String given some delimiters

2016-10-30 Thread Alfred Newman via Digitalmars-d-learn
On Sunday, 30 October 2016 at 23:47:54 UTC, Ali Çehreli wrote: On 10/30/2016 01:50 PM, Alfred Newman wrote: [...] Here is something along the lines of what others have suggested: auto parse(R, S)(R range, S separators) { import std.algorithm : splitter, filter, canFind; import

Re: strange -fPIC compilation error

2016-10-30 Thread Lodovico Giaretta via Digitalmars-d-learn
On Monday, 31 October 2016 at 00:08:59 UTC, Charles Hixson wrote: So now I removed the repository version of dmd and dub, downloaded DMD64 D Compiler v2.072.0-b2, used dkpg to install it, and appear to get the same errors. (Well, actually I removed the commenting out of the code, but it

Re: strange -fPIC compilation error

2016-10-30 Thread Charles Hixson via Digitalmars-d-learn
So now I removed the repository version of dmd and dub, downloaded DMD64 D Compiler v2.072.0-b2, used dkpg to install it, and appear to get the same errors. (Well, actually I removed the commenting out of the code, but it compiles and runs properly with ldc2.) On 10/30/2016 11:02 AM,

splitter trouble

2016-10-30 Thread Ali Çehreli via Digitalmars-d-learn
While working on a solution for Alfred Newman's thread, I came up with the following interim solution, which compiled but failed: auto parse(R, S)(R range, S separators) { import std.algorithm : splitter, filter, canFind; import std.range : empty; static bool pred(E, S)(E e, S s) {

Re: strange -fPIC compilation error

2016-10-30 Thread Charles Hixson via Digitalmars-d-learn
Just as a test I tried it with ldc, and, as expected, there wasn't any problem. On 10/30/2016 11:02 AM, Charles Hixson via Digitalmars-d-learn wrote: dmd --version DMD64 D Compiler v2.071.2 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright on debian testing. dub is installed

Re: Parse a String given some delimiters

2016-10-30 Thread Ali Çehreli via Digitalmars-d-learn
On 10/30/2016 01:50 PM, Alfred Newman wrote: Hello, I'm migrating some Python code to D, but I stuck at a dead end... Sorry to provide some .py lines over here, but I got some doubts about the best (fastest) way to do that in D. Executing the function parsertoken("_My input.string", " _,.",

Re: strange -fPIC compilation error

2016-10-30 Thread Charles Hixson via Digitalmars-d-learn
On 10/30/2016 04:03 PM, Lodovico Giaretta via Digitalmars-d-learn wrote: On Sunday, 30 October 2016 at 18:02:28 UTC, Charles Hixson wrote: dmd --version DMD64 D Compiler v2.071.2 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright on debian testing. dub is installed via

Re: Parse a String given some delimiters

2016-10-30 Thread sarn via Digitalmars-d-learn
On Sunday, 30 October 2016 at 20:50:47 UTC, Alfred Newman wrote: Hello, I'm migrating some Python code to D, but I stuck at a dead end... Sorry to provide some .py lines over here, but I got some doubts about the best (fastest) way to do that in D. The "splitter" generic function sounds

Re: Parse a String given some delimiters

2016-10-30 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 30 October 2016 at 20:50:47 UTC, Alfred Newman wrote: Hello, I'm migrating some Python code to D, but I stuck at a dead end... Sorry to provide some .py lines over here, but I got some doubts about the best (fastest) way to do that in D. Executing the function parsertoken("_My

Re: strange -fPIC compilation error

2016-10-30 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 30 October 2016 at 18:02:28 UTC, Charles Hixson wrote: dmd --version DMD64 D Compiler v2.071.2 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright on debian testing. dub is installed via apt-get. Should I revert to an earlier version? Or what? The program: import

Parse a String given some delimiters

2016-10-30 Thread Alfred Newman via Digitalmars-d-learn
Hello, I'm migrating some Python code to D, but I stuck at a dead end... Sorry to provide some .py lines over here, but I got some doubts about the best (fastest) way to do that in D. Executing the function parsertoken("_My input.string", " _,.", 2) will result "input".

Re: Construct D Arrray with explicit capacity

2016-10-30 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 30 October 2016 at 18:26:54 UTC, arturg wrote: you cant mutate capacity directly because its only a getter but you could use arr.reserve(someVal); Thx!

Re: Construct D Arrray with explicit capacity

2016-10-30 Thread arturg via Digitalmars-d-learn
On Sunday, 30 October 2016 at 18:10:09 UTC, Nordlöw wrote: Is there a recommended way to create a builtin D array with a given capacity? I'm aware of the `.capacity` property. Is it ok to mutate it? you cant mutate capacity directly because its only a getter but you could use

Re: Construct D Arrray with explicit capacity

2016-10-30 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 30 October 2016 at 18:10:09 UTC, Nordlöw wrote: Is it ok to mutate it? I just checked. It is not.

Construct D Arrray with explicit capacity

2016-10-30 Thread Nordlöw via Digitalmars-d-learn
Is there a recommended way to create a builtin D array with a given capacity? I'm aware of the `.capacity` property. Is it ok to mutate it?

strange -fPIC compilation error

2016-10-30 Thread Charles Hixson via Digitalmars-d-learn
dmd --version DMD64 D Compiler v2.071.2 Copyright (c) 1999-2015 by Digital Mars written by Walter Bright on debian testing. dub is installed via apt-get. Should I revert to an earlier version? Or what? The program: importstd.stdio; voidmain() {//int[]t1; //t1~=

Re: test for equality of the content of two AA

2016-10-30 Thread Paolo Invernizzi via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 19:03:45 UTC, Ali Çehreli wrote: On 10/26/2016 08:03 AM, Paolo Invernizzi wrote: [...] If you mean D's AAs, then that is already implemented: void main() { auto a = [ "hello" : 1, "world" : 2 ]; auto b = [ "world" : 2, "hello" : 1 ]; assert(a ==