Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-23 Thread ag0aep6g via Digitalmars-d-learn
On 05/24/2016 03:59 AM, Jack Stouffer wrote: parse!int(splitValue.front); [...] std.conv.parse(Target, Source)(ref Source s) if ( isSomeChar!(ElementType!Source) && isIntegral!Target && !is(Target == enum)) You're missing that `parse`'s parameter is `ref`. `splitValue.front` is

Re: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?

2016-05-23 Thread dan via Digitalmars-d-learn
On Monday, 23 May 2016 at 07:03:08 UTC, chmike wrote: On Saturday, 21 May 2016 at 17:32:47 UTC, dan wrote: (This effect could be simulated by making my_var into a function, but i don't want to do that.) May I ask why you don't want to do that ? In D you can call a function without args

std.conv.parse not accepting ByCodeUnitImpl

2016-05-23 Thread Jack Stouffer via Digitalmars-d-learn
Consider the following code - import std.range; import std.conv; import std.utf; import std.algorithm; auto test(R)(R s) { auto value = s.byCodeUnit; auto splitValue = value.splitter('.'); parse!int(splitValue.front); } void main() { test("1.8"); } - This fails

Re: Is NullableRef checked at compile time?

2016-05-23 Thread ag0aep6g via Digitalmars-d-learn
On 05/23/2016 08:10 PM, cy wrote: I was squinting at the std.typecons.NullableRef code and it _looks_ like isNull is only checked at runtime (and not checked at all in release mode!) but D has surprised me before in its ability to pre-calculate stuff during compilation. NullableRef is little

Struct literals and AA literals

2016-05-23 Thread Lodovico Giaretta via Digitalmars-d-learn
Hi, Today I stumbled upon this weird error: struct ConfigContainer { Config[string] configs; } struct Config { string foo; string bar; } enum ConfigContainer cc = { configs: [// error: not an associative array

Re: Is NullableRef checked at compile time?

2016-05-23 Thread Levi Maclean via Digitalmars-d-learn
On Monday, 23 May 2016 at 18:10:14 UTC, cy wrote: I was squinting at the std.typecons.NullableRef code and it _looks_ like isNull is only checked at runtime (and not checked at all in release mode!) but D has surprised me before in its ability to pre-calculate stuff during compilation. [...]

Re: missing data with parallel and stdin

2016-05-23 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 23 May 2016 at 15:53:23 UTC, moechofe wrote: On Monday, 23 May 2016 at 14:16:13 UTC, Jack Stouffer wrote: Sounds like a data race problem. Use a lock on the file write operation and see if that helps. That didn't solve anything. What I observe is: when the process is slower, more

Is NullableRef checked at compile time?

2016-05-23 Thread cy via Digitalmars-d-learn
I was squinting at the std.typecons.NullableRef code and it _looks_ like isNull is only checked at runtime (and not checked at all in release mode!) but D has surprised me before in its ability to pre-calculate stuff during compilation. I was thinking of using something like this:

Re: Speed up `dub`.

2016-05-23 Thread cy via Digitalmars-d-learn
On Thursday, 19 May 2016 at 17:50:44 UTC, ciechowoj wrote: dub build --nodeps I tried it, doesn't seem to do anything, maybe something is broken. Perhaps you didn't complete "dub build" without --nodeps beforehand? You have to do that once, and it's still as annoyingly inefficient as

Re: missing data with parallel and stdin

2016-05-23 Thread moechofe via Digitalmars-d-learn
On Monday, 23 May 2016 at 14:16:13 UTC, Jack Stouffer wrote: Sounds like a data race problem. Use a lock on the file write operation and see if that helps. Like this?: synchronized(mutex) copy(source,dest); That didn't solve anything. What I observe is: when the process is slower, more

Re: mutable keyword

2016-05-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 23, 2016 14:08:43 Jack Applegame via Digitalmars-d-learn wrote: > On Monday, 23 May 2016 at 11:05:34 UTC, Jonathan M Davis wrote: > > I don't know why you think that D violates its own rules > > frequently though. It's not perfect, but it usually does follow > > its own rules - and

Re: missing data with parallel and stdin

2016-05-23 Thread Jack Stouffer via Digitalmars-d-learn
On Monday, 23 May 2016 at 08:59:31 UTC, moechofe wrote: void delegate(string source,string dest) handler; if(use_symlink) handler = delegate(string s,string d){ symlink(s,d); }; else handler = delegate(string s,string d){ copy(s,d); }; Boy that's a confusing

Re: mutable keyword

2016-05-23 Thread Jack Applegame via Digitalmars-d-learn
On Monday, 23 May 2016 at 11:05:34 UTC, Jonathan M Davis wrote: I don't know why you think that D violates its own rules frequently though. It's not perfect, but it usually does follow its own rules - and when it doesn't, we fix it (though not always as quickly as would be ideal). The most

Re: Proper way to write benchmark code...

2016-05-23 Thread Seb via Digitalmars-d-learn
On Monday, 23 May 2016 at 04:11:31 UTC, Era Scarecrow wrote: Is there a good article written for this? Preferably for D specifically... [...] you might want to use __gshared data to avoid it being optimized away. Is it better to collect all the tests and output the results all at once?

Re: Is there a way to clear an OutBuffer?

2016-05-23 Thread Seb via Digitalmars-d-learn
On Monday, 23 May 2016 at 03:03:12 UTC, Jon Degenhardt wrote: On Sunday, 22 May 2016 at 23:01:07 UTC, Ali Çehreli wrote: On 05/22/2016 11:59 AM, Jon Degenhardt wrote: [...] Currently not possible. Enhancement request perhaps? Looking at the implementation, setting its 'offset' member seems

Re: Is there a 128-bit integer in D?

2016-05-23 Thread Seb via Digitalmars-d-learn
On Sunday, 22 May 2016 at 12:03:16 UTC, Guillaume Piolat wrote: On Sunday, 22 May 2016 at 09:47:54 UTC, Era Scarecrow wrote: On Sunday, 22 May 2016 at 09:39:45 UTC, Saurabh Das wrote: On Sunday, 22 May 2016 at 09:07:32 UTC, Guillaume Piolat wrote:

Re: mutable keyword

2016-05-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 23, 2016 08:19:52 Jack Applegame via Digitalmars-d-learn wrote: > On Sunday, 22 May 2016 at 13:08:19 UTC, Jonathan M Davis wrote: > > Given how const and immutable work in D, having any portion of > > them be treated as mutable, becomes highly problematic. It > > could theoretically

Re: Introspect alias name of an aliased type

2016-05-23 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 23 May 2016 at 10:45:49 UTC, ParticlePeter wrote: Is there a way to get the alias uint32_t instead ? Nope. For the compiler uint32_t and uint are the same thing, this is by design. Typedef can be used to create a separate type with the same semantics as the type it's based upon:

Introspect alias name of an aliased type

2016-05-23 Thread ParticlePeter via Digitalmars-d-learn
alias uint32_t = uint; struct Offset() { uint32_t x; uint32_t y; } // Introspect with: void printStructInfo( T )( T info ) { import std.stdio : writefln; foreach (memb; __traits(allMembers, T)) { writefln(typeof(__traits(getMember, info, memb)).stringof); } } // Result is uint

missing data with parallel and stdin

2016-05-23 Thread moechofe via Digitalmars-d-learn
Hi, I write a script that take a list of files from STDIN, compute some stuff, and copy files with a new names. I got 33k lines at input but got only 3k-5k in the destination folder. This is not append if I remove the .parallel() function. What did I do wrong? void delegate(string

Re: mutable keyword

2016-05-23 Thread Jack Applegame via Digitalmars-d-learn
On Sunday, 22 May 2016 at 13:08:19 UTC, Jonathan M Davis wrote: Given how const and immutable work in D, having any portion of them be treated as mutable, becomes highly problematic. It could theoretically be done by having to mark such variables with an attribute and mark such types with a

Re: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?

2016-05-23 Thread chmike via Digitalmars-d-learn
On Saturday, 21 May 2016 at 17:32:47 UTC, dan wrote: (This effect could be simulated by making my_var into a function, but i don't want to do that.) May I ask why you don't want to do that ? In D you can call a function without args without (). So if you write private int my_var_ = 4; //

Re: Generation of AST for semantic rule checking

2016-05-23 Thread thedeemon via Digitalmars-d-learn
On Sunday, 22 May 2016 at 04:33:44 UTC, Chris Katko wrote: Basically, I want compile-time enforcement of semantic rules. So the question is: Is there a way to get LDC2 to generate AST or similar, and if not, any other way to go about this? I think one popular approach to the task is to use