Re: Strange behavior std.range.takeNone

2015-04-07 Thread Andrea Fontana via Digitalmars-d-learn
Yes it is. takeNone() take a char from a string. So you are going to append a char (with code 5) on the next line. If you replace that line with: s ~= 65; it will print A. (65 is ascii code for letter 'A') On Tuesday, 7 April 2015 at 02:24:00 UTC, Dennis Ritchie wrote: Hi, Is it OK? -

Re: Static if to compare two types are the exact same

2015-04-07 Thread w0rp via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 06:37:50 UTC, Jonathan wrote: static if (is(T == V)) Are static ifs always checked outside of runtime? Is it possible for a static if condition to be undeterminable outside of runtime, or would such a condition throw a compiler error? 'static if' is always run

Re: getting started with std.csv

2015-04-07 Thread yazd via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 05:51:33 UTC, yazd wrote: On Tuesday, 7 April 2015 at 05:49:48 UTC, yazd wrote: I got this to work with: ``` import std.stdio, std.file, std.csv, std.range; void main() { std.file.write(test.csv, 0,1,abc\n2,3,def); scope(exit)

Re: Static if to compare two types are the exact same

2015-04-07 Thread Jonathan via Digitalmars-d-learn
static if (is(T == V)) Are static ifs always checked outside of runtime? Is it possible for a static if condition to be undeterminable outside of runtime, or would such a condition throw a compiler error?

Re: D1: Out of memory problems

2015-04-07 Thread Kagamin via Digitalmars-d-learn
Depends on how you fill aTUs.

Re: D1: Out of memory problems

2015-04-07 Thread Kagamin via Digitalmars-d-learn
For example if you slice the original string, it will be preserved in memory. That's why parsers keep parsed substrings by duplicating them - this can result in smaller memory footprint.

Re: Strange behavior std.range.takeNone

2015-04-07 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 08:49:58 UTC, Andrea Fontana wrote: Yes it is. takeNone() take a char from a string. So you are going to append a char (with code 5) on the next line. If you replace that line with: s ~= 65; it will print A. (65 is ascii code for letter 'A') Thanks. I am

Re: getting started with std.csv

2015-04-07 Thread gjansen via Digitalmars-d-learn
Many thanks for the feedback yazd! I've tested the approach with a large csv file and it works fine. Unfortunately csvReader seems very convenient but it is no speed daemon. To my dismay it was much slower (about 4x) than a simple approach I am using in Python, which is essentially equivalent

Re: getting started with std.csv

2015-04-07 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 09:44:11 UTC, gjansen wrote: Many thanks for the feedback yazd! I've tested the approach with a large csv file and it works fine. Unfortunately csvReader seems very convenient but it is no speed daemon. To my dismay it was much slower (about 4x) than a simple

[DerelictOrg] Forum down ?

2015-04-07 Thread ParticlePeter via Digitalmars-d-learn
Hi, I think I have a bug report for DerelictGL3, but cannot find the related Forum ( http://dblog.aldacron.net/forum/index.php ), is it still in the process of being moved ? Regards, ParticlePeter

Re: [DerelictOrg] Forum down ?

2015-04-07 Thread Namespace via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 10:48:38 UTC, ParticlePeter wrote: Hi, I think I have a bug report for DerelictGL3, but cannot find the related Forum ( http://dblog.aldacron.net/forum/index.php ), is it still in the process of being moved ? Regards, ParticlePeter Post it there:

Re: getting started with std.csv

2015-04-07 Thread gjansen via Digitalmars-d-learn
dmd -O (2.066.1) and gdc -O3 (4.9.2) But... as I tried to convey, I was comparing apples to oranges. I have now rewritten the D test simply using split(',') instead of csvReader, to be more similar to the python test, and it runs about 2x faster in D with dmd and about 4x faster with gdc

Re: UFCS and overloading

2015-04-07 Thread cym13 via Digitalmars-d-learn
EDIT: mis-formatted previous snippet import std.algorithm, std.stdio, std.range, std.conv; void main() { stdin .byLine .filter!(s = !s.empty s.front != '#’) // Filter with this lambda function .map!(s = s.to!double) // Map the strings to doubles .array //

Re: UFCS and overloading

2015-04-07 Thread cym13 via Digitalmars-d-learn
On Monday, 6 April 2015 at 18:00:46 UTC, Szymon Gatner wrote: Why is that? The use case is to provide a set of convenience extension methods to a basic interface. Say, given: This is not the only use case, another (maybe even more common) use is to allow pipeline programming. Example from

Re: getting started with std.csv

2015-04-07 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 11:36:54 UTC, gjansen wrote: dmd -O (2.066.1) and gdc -O3 (4.9.2) But... as I tried to convey, I was comparing apples to oranges. I have now rewritten the D test simply using split(',') instead of csvReader, to be more similar to the python test, and it runs about

Re: D1: Out of memory problems

2015-04-07 Thread jicman via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 09:03:19 UTC, Kagamin wrote: For example if you slice the original string, it will be preserved in memory. That's why parsers keep parsed substrings by duplicating them - this can result in smaller memory footprint. H... Will you be able to give me an example

Re: D1: Out of memory problems

2015-04-07 Thread jicman via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 08:58:31 UTC, Kagamin wrote: Depends on how you fill aTUs. Ok, I will bite... ;-) I have the wText string which could be 20 mgs or so, I start finding pieces of data like this, wText = wText[std.string.find(wText,/ut) + 5 .. $]; so, everything before /ut,

Re: Shall I use immutable or const while passing parameters to functions

2015-04-07 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 15:11:39 UTC, tcak wrote: I have data in memory, and I want a function to take a part of data for processing only. It will only read and won't change. char[] importantData; With Immutable, void dataProcessor( string giveMeAllYourData ){} dataProcessor( cast(

alias this of non-public member

2015-04-07 Thread via Digitalmars-d-learn
Hi! Excuse me if this is obvious, but I can't recall coming across anything similar and a quick search returns nothing relevant: struct Foo { } struct FooWrapper { alias x_ this; private Foo* x_; // doesn't work, as x_ is private } Basically, I want x_ to never be visible, except

Re: Shall I use immutable or const while passing parameters to functions

2015-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
If you're just looking at the data, use const. immutable becomes more important if it is shared across threads or stored for later. Functions that accept const will work with almost anything you pass to it.

Re: UFCS and overloading

2015-04-07 Thread Szymon Gatner via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 14:46:52 UTC, cym13 wrote: EDIT: mis-formatted previous snippet import std.algorithm, std.stdio, std.range, std.conv; void main() { stdin .byLine .filter!(s = !s.empty s.front != '#’) // Filter with this lambda function .map!(s =

Shall I use immutable or const while passing parameters to functions

2015-04-07 Thread tcak via Digitalmars-d-learn
I have data in memory, and I want a function to take a part of data for processing only. It will only read and won't change. char[] importantData; With Immutable, void dataProcessor( string giveMeAllYourData ){} dataProcessor( cast( immutable )( importantData[5 .. 14] ) ); With Const,

Re: Shall I use immutable or const while passing parameters to functions

2015-04-07 Thread bearophile via Digitalmars-d-learn
tcak: void dataProcessor( string giveMeAllYourData ){} dataProcessor( cast( immutable )( importantData[5 .. 14] ) ); With Const, void dataProcessor( in char[] giveMeAllYourData ){} dataProcessor( cast( const )( importantData[5 .. 14] ) ); Don't cast to const/immutable unless you have a

Re: [DerelictOrg] Forum down ?

2015-04-07 Thread ParticlePeter via Digitalmars-d-learn
Done On Tuesday, 7 April 2015 at 10:50:35 UTC, Namespace wrote: On Tuesday, 7 April 2015 at 10:48:38 UTC, ParticlePeter wrote: Hi, I think I have a bug report for DerelictGL3, but cannot find the related Forum ( http://dblog.aldacron.net/forum/index.php ), is it still in the process of being

Re: alias this of non-public member

2015-04-07 Thread Daniel Kozak via Digitalmars-d-learn
On Tue, 07 Apr 2015 16:40:29 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi! Excuse me if this is obvious, but I can't recall coming across anything similar and a quick search returns nothing relevant: struct Foo { } struct FooWrapper { alias x_ this;

Re: alias this of non-public member

2015-04-07 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 17:21:09 UTC, Daniel Kozak wrote: On Tue, 07 Apr 2015 16:40:29 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi! Excuse me if this is obvious, but I can't recall coming across anything similar and a quick search returns nothing

Re: alias this of non-public member

2015-04-07 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 17:43:08 UTC, Daniel Kozak wrote: On Tuesday, 7 April 2015 at 17:21:09 UTC, Daniel Kozak wrote: On Tue, 07 Apr 2015 16:40:29 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi! Excuse me if this is obvious, but I can't recall coming

Re: Shall I use immutable or const while passing parameters to functions

2015-04-07 Thread tcak via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 15:51:59 UTC, bearophile wrote: tcak: void dataProcessor( string giveMeAllYourData ){} dataProcessor( cast( immutable )( importantData[5 .. 14] ) ); With Const, void dataProcessor( in char[] giveMeAllYourData ){} dataProcessor( cast( const )( importantData[5

Re: alias this of non-public member

2015-04-07 Thread Dude via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 17:21:09 UTC, Daniel Kozak wrote: On Tue, 07 Apr 2015 16:40:29 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi! Excuse me if this is obvious, but I can't recall coming across anything similar and a quick search returns nothing

Re: alias this of non-public member

2015-04-07 Thread Namespace via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 17:21:09 UTC, Daniel Kozak wrote: On Tue, 07 Apr 2015 16:40:29 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi! Excuse me if this is obvious, but I can't recall coming across anything similar and a quick search returns nothing

Re: alias this of non-public member

2015-04-07 Thread via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 17:59:57 UTC, Daniel Kozak wrote: On Tuesday, 7 April 2015 at 17:43:08 UTC, Daniel Kozak wrote: On Tuesday, 7 April 2015 at 17:21:09 UTC, Daniel Kozak wrote: On Tue, 07 Apr 2015 16:40:29 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi!

Re: Creating a microcontroller startup file

2015-04-07 Thread Jens Bauer via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 1: How can a C subroutine be made optional, so it's called only if it linked ? Question 1 might be answered by the following thread: http://forum.dlang.org/thread/mg1bad$30uk$1...@digitalmars.com -So no need to answer

Creating a microcontroller startup file

2015-04-07 Thread Jens Bauer via Digitalmars-d-learn
I'm currently working on a startup file for Cortex-M. Thanks to Johannes, I'm now able to implement almost everything I need. While the most important part of the code code works, there are still a few things, that I would like added/changed. Here's a cut-down version of a start.d:

Re: Vibe.d json to csv

2015-04-07 Thread Sönke Ludwig via Digitalmars-d-learn
Am 05.04.2015 um 06:24 schrieb Sebastiaan Koppe: (...) I can probably use zip to get the quotes around the names, to avoid concatenation. But it works fine the way it is. The problem is, the following doesn't: ``` void csvRow(const Json jsonObject) { return

Re: using vibe.d to parse json

2015-04-07 Thread Sönke Ludwig via Digitalmars-d-learn
Am 26.03.2015 um 02:38 schrieb Laeeth Isharc: On Thursday, 26 March 2015 at 01:04:06 UTC, Jakob Ovrum wrote: On Thursday, 26 March 2015 at 00:41:50 UTC, Laeeth Isharc wrote: Yeah, it is not very intuitive. But it works. Thanks. Next question - how can I correctly deal with inconsiderately

Re: vibed - blocking file I/O via library?

2015-04-07 Thread Sönke Ludwig via Digitalmars-d-learn
Am 06.04.2015 um 17:45 schrieb Laeeth Isharc: So a very basic question about using vibed for a REST service. I am serving data using REST to another application. For the time being it is internal so it is not a disaster if the fiber blocks. But I wanted to understand what I should be doing -

Re: using vibe.d to parse json

2015-04-07 Thread Sönke Ludwig via Digitalmars-d-learn
Am 24.03.2015 um 06:36 schrieb Laeeth Isharc: On Tuesday, 24 March 2015 at 04:53:39 UTC, Laeeth Isharc wrote: Hi. struct RawGoogleResults { string version_; string status; string sig; string[string][][string] table; } enum json =

Re: Temple templates with vibe.d support and first D experiences

2015-04-07 Thread Sönke Ludwig via Digitalmars-d-learn
Am 20.03.2015 um 10:42 schrieb István Zólyomi: Still does not compile, thanks for the idea though. I think it's better to avoid Temple, compilation of Diet templates seems to be better anyway. E.g. temple seems to accept % var.nonexistingname % while diet gives a compile error for

Re: feature request for dlang.org library preview

2015-04-07 Thread Sönke Ludwig via Digitalmars-d-learn
Am 26.03.2015 um 21:36 schrieb Steven Schveighoffer: So I just noticed, when I click on source code button for a function in dlang.org library preview, it brings me to the source code as of that release, but to the file itself (on github). I'd like it to go to the specific line where that

Re: alias this of non-public member

2015-04-07 Thread Vlad Levenfeld via Digitalmars-d-learn
On Tuesday, 7 April 2015 at 19:17:41 UTC, Márcio Martins wrote: Proxy doesn't really help here :( Nothing will help you get around this. You have to expose a public member and alias to that. Try wrapping the access in a public zero-parameter member function.

Re: vibed - blocking file I/O via library?

2015-04-07 Thread Laeeth Isharc via Digitalmars-d-learn
You should start a worker thread for this and then use message passing (vibe.core.concurrency) to wait for the results (or alternatively a TaskCondition). I was thinking about including a generic thread proxy in vibe.d that I've used to encapsulate these details when working with libgit in a

Re: why does phobos use [0, 5, 8, 9][] instead of [0, 5, 8, 9] in examples?

2015-04-07 Thread Vladimir Panteleev via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 02:40:14 UTC, Timothee Cour wrote: Eg, code like this in std.algorithm: assert(equal(setSymmetricDifference(a, b), [0, 5, 8, 9][])); why not just: assert(equal(setSymmetricDifference(a, b), [0, 5, 8, 9])); ? It's historic. DMD 2.041 changed the type of array

why does phobos use [0, 5, 8, 9][] instead of [0, 5, 8, 9] in examples?

2015-04-07 Thread Timothee Cour via Digitalmars-d-learn
Eg, code like this in std.algorithm: assert(equal(setSymmetricDifference(a, b), [0, 5, 8, 9][])); why not just: assert(equal(setSymmetricDifference(a, b), [0, 5, 8, 9])); ?

Re: Creating a microcontroller startup file

2015-04-07 Thread Rikki Cattermole via Digitalmars-d-learn
On 8/04/2015 8:38 a.m., Jens Bauer wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: Question number 1: How can a C subroutine be made optional, so it's called only if it linked ? Question 1 might be answered by the following thread:

Re: why does phobos use [0, 5, 8, 9][] instead of [0, 5, 8, 9] in examples?

2015-04-07 Thread Ali Çehreli via Digitalmars-d-learn
On 04/07/2015 07:40 PM, Timothee Cour via Digitalmars-d-learn wrote: Eg, code like this in std.algorithm: assert(equal(setSymmetricDifference(a, b), [0, 5, 8, 9][])); why not just: assert(equal(setSymmetricDifference(a, b), [0, 5, 8, 9])); ? It must be a leftover from the time when the type