Re: chaining splitters

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 00:00:39 UTC, dnoob wrote: Hello, I am parsing some text and I have the following; string text = "some very long text"; foreach(line; splitter(text, [13, 10])) { foreach(record; splitter(line, '*')) { foreach(field; splitter(record

Re: is eC alot like D?

2015-03-10 Thread sclytrack via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 04:10:51 UTC, Taylor Hillegeist wrote: On Wednesday, 11 March 2015 at 03:55:21 UTC, Rikki Cattermole wrote: On 11/03/2015 4:16 p.m., Taylor Hillegeist wrote: So I found http://ec-lang.org/ it seems alot like D, But it has a company backing it. It just seems inter

boilerplate for constructor

2015-03-10 Thread Timothee Cour via Digitalmars-d-learn
I'm trying to define a boilerplate mixin for class constructor to generate code such as: this(T1 a1, T2 a2){this.a1=a1; this.a2=a2;} The following works, but fails if one field is from a superclass, with an error such as: template instance GenThis!(b, a) GenThis!(b, a) is nested in both B and A.

Re: is eC alot like D?

2015-03-10 Thread Taylor Hillegeist via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 03:55:21 UTC, Rikki Cattermole wrote: On 11/03/2015 4:16 p.m., Taylor Hillegeist wrote: So I found http://ec-lang.org/ it seems alot like D, But it has a company backing it. It just seems interesting. There is almost no meta programming support. Let alone CTFE.

Re: is eC alot like D?

2015-03-10 Thread Rikki Cattermole via Digitalmars-d-learn
On 11/03/2015 4:16 p.m., Taylor Hillegeist wrote: So I found http://ec-lang.org/ it seems alot like D, But it has a company backing it. It just seems interesting. There is almost no meta programming support. Let alone CTFE. And no generics in the form of e.g. Java's is not the same as D's meta

is eC alot like D?

2015-03-10 Thread Taylor Hillegeist via Digitalmars-d-learn
So I found http://ec-lang.org/ it seems alot like D, But it has a company backing it. It just seems interesting.

Re: New package behaviour in 2.067

2015-03-10 Thread Dicebot via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=14275

Re: New package behaviour in 2.067

2015-03-10 Thread Dicebot via Digitalmars-d-learn
Looks like bug, investigating.

Re: Parallelization of a large array

2015-03-10 Thread Meta via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:37:29 UTC, Ali Çehreli wrote: On 03/10/2015 03:16 PM, Meta wrote: > Just add a condition variable. > > import std.stdio; > import std.algorithm; > import std.parallelism; > > void main() { > > int b = 2; > > auto a = [1, 2, 2, 3]; > > if (find(a, b)

chaining splitters

2015-03-10 Thread dnoob via Digitalmars-d-learn
Hello, I am parsing some text and I have the following; string text = "some very long text"; foreach(line; splitter(text, [13, 10])) { foreach(record; splitter(line, '*')) { foreach(field; splitter(record, '=')) { foreach(v

Re: New package behaviour in 2.067

2015-03-10 Thread ketmar via Digitalmars-d-learn
On Tue, 10 Mar 2015 23:17:01 +, Namespace wrote: > Is this intended? i doubt so. `struct Foo` is definitely `public`, so there shouldn't be any problems with access rights. signature.asc Description: PGP signature

Re: How does laziness and UFCS interact?

2015-03-10 Thread via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 17:42:37 UTC, Ali Çehreli wrote: You are right again. :) However, putting the lazy-taking function "outside" the whole expression makes it visible right away, making easy for me to realize that the execution order may be different from common chains. "lazy" aka "n

New package behaviour in 2.067

2015-03-10 Thread Namespace via Digitalmars-d-learn
I'm unsure, but I think this code should work: module A.B.Foo; import core.stdc.stdio : printf; struct Foo { package(A) void foo() { printf("Hallo\n"); } } package(A) void bar() { printf("Hallo\n"); } and module A.C.Bar; import A.B.Foo; void main() { Foo f

Re: Parallelization of a large array

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:43:08 UTC, Ali Çehreli wrote: The following is the program that does NOT use taskPool.map. I am also changing the name of a variable because the local 'chunks' looked like std.range.chunks. import std.stdio; import std.algorithm; import std.parallelism; import s

Re: Parallelization of a large array

2015-03-10 Thread Ali Çehreli via Digitalmars-d-learn
On 03/10/2015 03:34 PM, Ali Çehreli wrote: > It is possible by accessing the actual range by chunks: Sorry, I posted a jumbled program that does not compile. The following is the program that does NOT use taskPool.map. I am also changing the name of a variable because the local 'chunks' looked

Re: Parallelization of a large array

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:34:34 UTC, Ali Çehreli wrote: It is possible by accessing the actual range by chunks: import std.stdio; import std.algorithm; import std.parallelism; import std.range; import std.conv; void main() { const size_t elementCount = 895640; int[] a = iota(elem

Re: Parallelization of a large array

2015-03-10 Thread Ali Çehreli via Digitalmars-d-learn
On 03/10/2015 03:16 PM, Meta wrote: > Just add a condition variable. > > import std.stdio; > import std.algorithm; > import std.parallelism; > > void main() { > > int b = 2; > > auto a = [1, 2, 2, 3]; > > if (find(a, b).length != 0) > writeln("Yes_"); > > auto found =

Re: Parallelization of a large array

2015-03-10 Thread Ali Çehreli via Digitalmars-d-learn
On 03/10/2015 01:41 PM, Dennis Ritchie wrote: Hi. How to parallelize a large array to check for the presence of an element matching the value with the data? std.stdio; std.algorithm; std.parallelism; void main() { int[] a = new int[100]; foreach (i, ref elem; a) elem =

Re: Parallelization of a large array

2015-03-10 Thread Meta via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:11:57 UTC, Dennis Ritchie wrote: On Tuesday, 10 March 2015 at 21:27:42 UTC, Dennis Ritchie wrote: Thanks. No, it does not suit me, because of the parallel array in a foreach loop there is no break. import std.stdio; import std.algorithm; import std.parallelis

Re: Parallelization of a large array

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:11:57 UTC, Dennis Ritchie wrote: No, it does not suit me, because of the parallel array in a foreach loop there is no break. I already understood everything: found = true;

Re: Parallelization of a large array

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 21:27:42 UTC, Dennis Ritchie wrote: Thanks. No, it does not suit me, because of the parallel array in a foreach loop there is no break. import std.stdio; import std.algorithm; import std.parallelism; void main() { int b = 2; auto a = [1, 2, 2,

Re: Purity not enforced for default arguments?

2015-03-10 Thread Xinok via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:00:29 UTC, safety0ff wrote: On Tuesday, 10 March 2015 at 21:56:39 UTC, Xinok wrote: I'm inclined to believe this is a bug. https://issues.dlang.org/show_bug.cgi?id=11048 Thanks for the link, and I didn't mean to post this in D.learn. >.<

Re: Purity not enforced for default arguments?

2015-03-10 Thread safety0ff via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 21:56:39 UTC, Xinok wrote: I'm inclined to believe this is a bug. https://issues.dlang.org/show_bug.cgi?id=11048

Purity not enforced for default arguments?

2015-03-10 Thread Xinok via Digitalmars-d-learn
The following code fails to compile because unpredictableSeed is impure: void main() { foreach(i; 0..10) writeln(pureRandom); } pure uint pureRandom() { auto r = Random(unpredictableSeed); return r.front; } However, make unpredictableSeed a defau

Re: expand variadic template parameters

2015-03-10 Thread Meta via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 19:11:22 UTC, André wrote: Hi, in this minified example I try to expand the variadic parmaters of foo to bar: import std.typecons; void foo(T ...)(T args) { bar(args.expand); } void bar(int i, string s){} void main() { foo(1, "a"); } I got the syn

Re: Parallelization of a large array

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 21:15:17 UTC, safety0ff wrote: On Tuesday, 10 March 2015 at 20:41:14 UTC, Dennis Ritchie wrote: Hi. How to parallelize a large array to check for the presence of an element matching the value with the data? Here's a simple method (warning: has pitfalls): import s

Re: Parallelization of a large array

2015-03-10 Thread safety0ff via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 20:41:14 UTC, Dennis Ritchie wrote: Hi. How to parallelize a large array to check for the presence of an element matching the value with the data? Here's a simple method (warning: has pitfalls): import std.stdio; import std.parallelism; void main() { int[] a

Re: Parallelization of a large array

2015-03-10 Thread anonymous via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 20:41:14 UTC, Dennis Ritchie wrote: Hi. How to parallelize a large array to check for the presence of an element matching the value with the data? std.stdio; std.algorithm; std.parallelism; You forgot a couple "import"s here. void main() { int[] a = n

Parallelization of a large array

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
Hi. How to parallelize a large array to check for the presence of an element matching the value with the data? std.stdio; std.algorithm; std.parallelism; void main() { int[] a = new int[100]; foreach (i, ref elem; a) elem = i; /*if (find(parallel(

Re: 2.067 Beta: Behavior of enum and ref changed

2015-03-10 Thread Ali Çehreli via Digitalmars-d-learn
On 03/10/2015 11:05 AM, Ali Çehreli wrote: In other words, the result of the implicit conversion is an rvalue Steven Schveighoffer says there is no rvalue in this case; "an enum is a derivative": https://issues.dlang.org/show_bug.cgi?id=14269#c14 Ali

Re: expand variadic template parameters

2015-03-10 Thread André
too many trees in front of my eyes. Thanks for the answers. Kind regards André On Tuesday, 10 March 2015 at 19:16:23 UTC, Adam D. Ruppe wrote: On Tuesday, 10 March 2015 at 19:11:22 UTC, André wrote: Is there a simple way to get it working? The simplest: just write `bar(args);` - the variadic

Re: expand variadic template parameters

2015-03-10 Thread ketmar via Digitalmars-d-learn
On Tue, 10 Mar 2015 19:11:21 +, André wrote: > Hi, > > in this minified example I try to expand the variadic parmaters of foo > to bar: > > import std.typecons; > > void foo(T ...)(T args) > { > bar(args.expand); > } > > void bar(int i, string s){} > > void main() > { > foo(1

Re: expand variadic template parameters

2015-03-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 19:11:22 UTC, André wrote: Is there a simple way to get it working? The simplest: just write `bar(args);` - the variadic arguments will automatically expand.

expand variadic template parameters

2015-03-10 Thread André
Hi, in this minified example I try to expand the variadic parmaters of foo to bar: import std.typecons; void foo(T ...)(T args) { bar(args.expand); } void bar(int i, string s){} void main() { foo(1, "a"); } I got the syntax error: no property 'expand' for type '(int, string)' I

Re: 2.067 Beta: Behavior of enum and ref changed

2015-03-10 Thread Ali Çehreli via Digitalmars-d-learn
On 03/10/2015 01:37 AM, Jonathan M Davis via Digitalmars-d-learn wrote: > However, the code in question still shouldn't compile because while a Bits > variable may be implicitly convertible to ulong, it _isn't_ a ulong, In other words, the result of the implicit conversion is an rvalue, creat

Re: How does laziness and UFCS interact?

2015-03-10 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 14:41:00 UTC, Logan Capaldo wrote: On Monday, 9 March 2015 at 22:15:43 UTC, Ali Çehreli wrote: You are right. I had the same observation at minute 11:27 below, where I warn against UFCS with assumeWontThrow: http://www.youtube.com/watch?feature=player_detailpage&v

Re: How does laziness and UFCS interact?

2015-03-10 Thread Logan Capaldo via Digitalmars-d-learn
On Monday, 9 March 2015 at 22:15:43 UTC, Ali Çehreli wrote: You are right. I had the same observation at minute 11:27 below, where I warn against UFCS with assumeWontThrow: http://www.youtube.com/watch?feature=player_detailpage&v=oF8K4-bieaw#t=687 Ali Sorry, which is right? I know ifThrown

Re: What's the rationale here? alias this and function arguments

2015-03-10 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 10:36:21 UTC, ketmar wrote: On Tue, 10 Mar 2015 10:27:13 +, John Colvin wrote: struct S { int a; this(T)(T v) { this = v; } void foo(T)(T v) { import std.conv : to; a = v.to!

Re: Derelict Assimp not loading mesh properly? (Maybe index buffer)

2015-03-10 Thread BennetD via Digitalmars-d-learn
On Monday, 9 March 2015 at 14:25:54 UTC, Michael Robertson wrote: On Friday, 6 March 2015 at 02:41:19 UTC, Bennet wrote: I wrote a custom OBJ file importer which worked fairly well however was not robust enough to support everything. I've decided to give AssImp a shot. I followed some tutorials

Re: What's the rationale here? alias this and function arguments

2015-03-10 Thread Baz via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 10:27:14 UTC, John Colvin wrote: struct S { int a; this(T)(T v) { this = v; } void foo(T)(T v) { import std.conv : to; a = v.to!int; } alias foo this; } vo

Re: What's the rationale here? alias this and function arguments

2015-03-10 Thread ketmar via Digitalmars-d-learn
On Tue, 10 Mar 2015 10:27:13 +, John Colvin wrote: > struct S { > int a; > this(T)(T v) > { > this = v; > } > void foo(T)(T v) { > import std.conv : to; > a = v.to!int; > } > alias foo this; > } > > void bar(S

What's the rationale here? alias this and function arguments

2015-03-10 Thread John Colvin via Digitalmars-d-learn
struct S { int a; this(T)(T v) { this = v; } void foo(T)(T v) { import std.conv : to; a = v.to!int; } alias foo this; } void bar(S s){} void main() { S s0; s0 = "3"; //

Re: 2.067 Beta: Behavior of enum and ref changed

2015-03-10 Thread Andre via Digitalmars-d-learn
Thanks a lot! Kind regards André On Tuesday, 10 March 2015 at 09:25:02 UTC, Meta wrote: On Tuesday, 10 March 2015 at 08:37:46 UTC, Jonathan M Davis wrote: It's the base type that isn't implicitly convertible to the enum type. Err, yes. I had that the wrong way around. Anyway, I filed an is

Re: How to use UFCS and std.algorithm.sort?

2015-03-10 Thread Andre via Digitalmars-d-learn
Thanks a lot! Kind regards André On Tuesday, 10 March 2015 at 08:40:28 UTC, Jonathan M Davis wrote: On Tuesday, March 10, 2015 07:24:52 Andre via Digitalmars-d-learn wrote: Hi, with the new beta I get the warning I should use std.algorithm.sort instead the .sort property. I thought the std.al

Re: 2.067 Beta: Behavior of enum and ref changed

2015-03-10 Thread Meta via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 08:37:46 UTC, Jonathan M Davis wrote: It's the base type that isn't implicitly convertible to the enum type. Err, yes. I had that the wrong way around. Anyway, I filed an issue. https://issues.dlang.org/show_bug.cgi?id=14269

Re: std.stdio.writeln

2015-03-10 Thread ketmar via Digitalmars-d-learn
On Tue, 10 Mar 2015 01:31:39 -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > it's the sort of thing that could easily be decided and then not > actually happen for ages (e.g. it was decided years ago that delete > would be deprecated, but it still isn't). sometimes i'm irritated by this,

Re: string-int[] array

2015-03-10 Thread Kagamin via Digitalmars-d-learn
On Sunday, 8 March 2015 at 21:41:44 UTC, FG wrote: Except that with this solution you will confuse empty strings with ints. The idea was to only make it memory-safe without union.

Re: How to use UFCS and std.algorithm.sort?

2015-03-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 10, 2015 07:24:52 Andre via Digitalmars-d-learn wrote: > Hi, > > with the new beta I get the warning I should use > std.algorithm.sort instead the .sort property. I thought the > std.algorithm.sort method is used in this example? > > void main() > { > import std.algorithm: sort,

Re: 2.067 Beta: Behavior of enum and ref changed

2015-03-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 10, 2015 08:19:27 Meta via Digitalmars-d-learn wrote: > On Tuesday, 10 March 2015 at 07:04:48 UTC, Andre wrote: > > Hi, > > > > following coding raises a compiler error with the beta of 2.067. > > Is this error intended or not? > > It is working if I change first line of main to:

Re: std.stdio.writeln

2015-03-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 09, 2015 22:29:23 Meta via Digitalmars-d-learn wrote: > On Monday, 9 March 2015 at 22:00:46 UTC, ketmar wrote: > > i remember that deprecation was rejected. maybe this is false > > memory, > > though. > > > > btw, there are legit uses of comma, in c-style `for`, for > > example. th

Re: 2.067 Beta: Behavior of enum and ref changed

2015-03-10 Thread Meta via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 07:04:48 UTC, Andre wrote: Hi, following coding raises a compiler error with the beta of 2.067. Is this error intended or not? It is working if I change first line of main to: ulong bits; enum Bits: ulong { none = 0 } bool hasBit(ref ulong rBits, ulong rBit

Re: How to use UFCS and std.algorithm.sort?

2015-03-10 Thread Tobias Pankrath via Digitalmars-d-learn
.array .sort buildin arrays have a .sort-property that is called.

How to use UFCS and std.algorithm.sort?

2015-03-10 Thread Andre via Digitalmars-d-learn
Hi, with the new beta I get the warning I should use std.algorithm.sort instead the .sort property. I thought the std.algorithm.sort method is used in this example? void main() { import std.algorithm: sort, uniq, map; import std.array: array; string[] a

2.067 Beta: Behavior of enum and ref changed

2015-03-10 Thread Andre via Digitalmars-d-learn
Hi, following coding raises a compiler error with the beta of 2.067. Is this error intended or not? It is working if I change first line of main to: ulong bits; enum Bits: ulong { none = 0 } bool hasBit(ref ulong rBits, ulong rBit) { return cast(bool)(rBits & rBit); } void main