Re: How to detect a lambda expression get it is signature

2014-06-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 02/06/14 01:00, bioinfornatics wrote: Hi i am looking how to perform this action with traits. Below some code to show what it fail Regards CODE import std.traits : isDelegate, isSomeFunction, MemberFunctionsTuple, ParameterIdentifierTuple; struct section( alias start, alias

Re: Different random shuffles generated when compiled with gdc than with dmd

2014-06-02 Thread Chris Cain via Digitalmars-d-learn
On Sunday, 1 June 2014 at 14:22:31 UTC, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: I missed the debate at the time, but actually, I'm slightly more concerned over the remark in that discussion that the new uniform was ported from java.util.Random. Isn't OpenJDK GPL-licensed ... ?

delegate issue

2014-06-02 Thread captaindet via Digitalmars-d-learn
hi, i stumbled upon something weird - it looks like a bug to me but maybe it is a feature that is unclear to me. so i know i can declare function and delegate pointers at module level. for function pointers, i can initialize with a lambda. BUT for delegates i get an error - see below i found

port C++ to D - copy constness

2014-06-02 Thread dennis luehring via Digitalmars-d-learn
i want to port this C++ code to good/clean D and have no real idea how to start contains 2 templates - a slice like and a binary reader for an slice main idea was to copy the immutablity of the slice data to the reader http://pastebin.com/XX2yhm8D the example compiles fine with

Re: Interfacing to const T or const T* C++ code

2014-06-02 Thread Atila Neves via Digitalmars-d-learn
On Sunday, 1 June 2014 at 09:18:50 UTC, bearophile wrote: Atila Neves: D: struct Foo { int i; int j; } extern(C++) void useFoo(ref const(Foo) foo); C++: struct Foo { int i; int j; }; void useFoo(const Foo foo) { ... } This doesn't look very safe because D const is

Re: port C++ to D - copy constness

2014-06-02 Thread Timon Gehr via Digitalmars-d-learn
On 06/02/2014 09:06 AM, dennis luehring wrote: i want to port this C++ code to good/clean D and have no real idea how to start contains 2 templates - a slice like and a binary reader for an slice main idea was to copy the immutablity of the slice data to the reader http://pastebin.com/XX2yhm8D

Re: Different random shuffles generated when compiled with gdc than with dmd

2014-06-02 Thread Andrew Brown via Digitalmars-d-learn
Having read more of the debate, I think coverage is more important than reproducibility. From my point of view, I'm not sure if there's much point in giving reproducible wrong answers.

Re: port C++ to D - copy constness

2014-06-02 Thread dennis luehring via Digitalmars-d-learn
Am 02.06.2014 12:09, schrieb Timon Gehr: On 06/02/2014 09:06 AM, dennis luehring wrote: i want to port this C++ code to good/clean D and have no real idea how to start contains 2 templates - a slice like and a binary reader for an slice main idea was to copy the immutablity of the slice data

Re: Interfacing to const T or const T* C++ code

2014-06-02 Thread Kagamin via Digitalmars-d-learn
Try to report as a bug.

Re: Different random shuffles generated when compiled with gdc than with dmd

2014-06-02 Thread Kagamin via Digitalmars-d-learn
On Sunday, 1 June 2014 at 12:11:22 UTC, Ivan Kazmenko wrote: I second the thought that reproducibility across different versions is an important feature of any random generation library. Sadly, I didn't use a language yet which supported such a flavor of reproducibility for a significant

Re: delegate issue

2014-06-02 Thread MrSmith via Digitalmars-d-learn
On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote: hi, i stumbled upon something weird - it looks like a bug to me but maybe it is a feature that is unclear to me. so i know i can declare function and delegate pointers at module level. for function pointers, i can initialize with a

Re: Test if member is static variable

2014-06-02 Thread Temtaime via Digitalmars-d-learn
Also second question is what are better to use, current template recursion-based code or rewrite it to CTFE ?

Re: delegate issue

2014-06-02 Thread via Digitalmars-d-learn
On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote: hi, i stumbled upon something weird - it looks like a bug to me but maybe it is a feature that is unclear to me. so i know i can declare function and delegate pointers at module level. for function pointers, i can initialize with a

Re: delegate issue

2014-06-02 Thread captaindet via Digitalmars-d-learn
On 2014-06-02 08:08, Marc Schütz schue...@gmx.net wrote: On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote: hi, i stumbled upon something weird - it looks like a bug to me but maybe it is a feature that is unclear to me. so i know i can declare function and delegate pointers at module

Re: installing Mango with DMD instead of ldc

2014-06-02 Thread JJDuck via Digitalmars-d-learn
I tried to compile it with dmd and there are some problem with D1 code, so I will try to port it to D2. I will post the result if I can successfully port it.

Re: delegate issue

2014-06-02 Thread Timon Gehr via Digitalmars-d-learn
On 06/02/2014 04:30 PM, captaindet wrote: This doesn't work, because a delegate needs a context it can capture, which is available only inside of a function. so the real explanation is that a module as such has no context. much of the module design has the look and feel as if it were some

Re: delegate issue

2014-06-02 Thread captaindet via Digitalmars-d-learn
On 2014-06-02 08:03, MrSmith wrote: On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote: hi, i stumbled upon something weird - it looks like a bug to me but maybe it is a feature that is unclear to me. so i know i can declare function and delegate pointers at module level. for function

Re: delegate issue

2014-06-02 Thread captaindet via Digitalmars-d-learn
On 2014-06-02 08:08, Marc Schütz schue...@gmx.net wrote: On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote: hi, i stumbled upon something weird - it looks like a bug to me but maybe it is a feature that is unclear to me. so i know i can declare function and delegate pointers at module

Re: delegate issue

2014-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 02 Jun 2014 10:37:07 -0400, captaindet 2k...@gmx.net wrote: On 2014-06-02 08:03, MrSmith wrote: On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote: hi, i stumbled upon something weird - it looks like a bug to me but maybe it is a feature that is unclear to me. so i know i

Re: installing Mango with DMD instead of ldc

2014-06-02 Thread Dicebot via Digitalmars-d-learn
On Monday, 26 May 2014 at 15:42:56 UTC, JJDuck wrote: On Monday, 26 May 2014 at 15:41:03 UTC, bioinfornatics wrote: On Monday, 26 May 2014 at 15:33:45 UTC, JJDuck wrote: vibe.d is root an open-source project ? on about page is wrote is licensed under MIT which are an open source license.

how to port to COM+ server on windows

2014-06-02 Thread JJDuck via Digitalmars-d-learn
Hello all, Since D is COM compatible. How do I port my dll or lib or obj to Windows' COM+ Server? it will be great if it can be done. Thanks

Re: delegate issue

2014-06-02 Thread captaindet via Digitalmars-d-learn
On 2014-06-02 08:08, Marc Schütz schue...@gmx.net wrote: On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote: hi, i stumbled upon something weird - it looks like a bug to me but maybe it is a feature that is unclear to me. so i know i can declare function and delegate pointers at module

Re: floating point conversion

2014-06-02 Thread Gary Willoughby via Digitalmars-d-learn
I have a couple of functions that you may find useful for comparing floats. https://github.com/nomad-software/dunit/blob/master/source/dunit/toolkit.d#L42 https://github.com/nomad-software/dunit/blob/master/source/dunit/toolkit.d#L134

Re: Different random shuffles generated when compiled with gdc than with dmd

2014-06-02 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On 02/06/14 08:57, Chris Cain via Digitalmars-d-learn wrote: On Sunday, 1 June 2014 at 14:22:31 UTC, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: I missed the debate at the time, but actually, I'm slightly more concerned over the remark in that discussion that the new uniform was

Re: delegate issue

2014-06-02 Thread captaindet via Digitalmars-d-learn
On 2014-06-02 09:57, Steven Schveighoffer wrote: On Mon, 02 Jun 2014 10:37:07 -0400, captaindet 2k...@gmx.net wrote: On 2014-06-02 08:03, MrSmith wrote: On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote: hi, i stumbled upon something weird - it looks like a bug to me but maybe it is

for, foreach identifier allowed in c throws error in d

2014-06-02 Thread Logesh Pillay via Digitalmars-d-learn
It is common in a recursive function to amend a global array using the function parameter to refer to the element eg int[10]; void foo (int i) { foreach (x; 0 .. 9) { t[i] = x; foo (); C in a for loop allows use of t[i] directly as the iterating variable so you don't need the

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread Logesh Pillay via Digitalmars-d-learn
Of course, in the first line I meant to say int[10] t;

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 02 Jun 2014 15:21:06 -0400, Logesh Pillay lp.court.jes...@gmail.com wrote: It is common in a recursive function to amend a global array using the function parameter to refer to the element eg int[10]; void foo (int i) { foreach (x; 0 .. 9) { t[i] = x; foo (); C in

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread John Colvin via Digitalmars-d-learn
On Monday, 2 June 2014 at 19:21:07 UTC, Logesh Pillay wrote: It is common in a recursive function to amend a global array using the function parameter to refer to the element eg int[10]; void foo (int i) { foreach (x; 0 .. 9) { t[i] = x; foo (); C in a for loop allows use of t[i]

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread Logesh Pillay via Digitalmars-d-learn
Issue has nothing to do with recursion. That's only where I keep seeing it. eg a function to generate combinations. import std.stdio; int[3] t; void foo (int i) { if (i == 3) writef(%s\n, t); else foreach (x; 0 .. 3) { t[i] = x; foo(i+1); } } void main() { foo(0); } In

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 02 Jun 2014 15:47:02 -0400, Logesh Pillay lp.court.jes...@gmail.com wrote: Issue has nothing to do with recursion. That's only where I keep seeing it. eg a function to generate combinations. import std.stdio; int[3] t; void foo (int i) { if (i == 3) writef(%s\n, t);

Delegate, scope and associative array

2014-06-02 Thread Edwin van Leeuwen via Digitalmars-d-learn
I'm probably missing something basic, but I am confused by what is going on in the following code. unittest { size_t delegate()[size_t] events; foreach( i; 1..4 ) { events[i] = { return i; }; } writeln( events[1]() ); // This outputs 3 assert( events[1]() == 1 ); }

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread Logesh Pillay via Digitalmars-d-learn
Sorry, I am embarassed to say I've just tried the for equivalent and it works with t[i] as the iterating variable. import std.stdio; int[3] t; void foo (int i) { if (i == 3) writef(%s\n, t); else for (t[i] = 0; t[i] 3; t[i]++) foo(i+1); } void main() { foo(0); } Sorry, yet

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 02 Jun 2014 15:58:01 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: I'm trying to think of a way to do this without loops, but not sure. I'm surprised, I looked for some kind of apply function like map, but just calls some function with each element in the range.

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread John Colvin via Digitalmars-d-learn
On Monday, 2 June 2014 at 20:23:12 UTC, Steven Schveighoffer wrote: On Mon, 02 Jun 2014 15:58:01 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: I'm trying to think of a way to do this without loops, but not sure. I'm surprised, I looked for some kind of apply function like map,

How to assign a delegate to a var ?

2014-06-02 Thread bioinfornatics via Digitalmars-d-learn
Hi, I would like store the delegate to another var but when i try i get: testTraitsWithDelegate.d(13): Error: expression template __lambda2 is void and has no value I do not want to run it only to save the «function» somewhere. --- CODE import std.stdio; import

Re: How to assign a delegate to a var ?

2014-06-02 Thread Meta via Digitalmars-d-learn
On Monday, 2 June 2014 at 22:18:39 UTC, bioinfornatics wrote: Hi, I would like store the delegate to another var but when i try i get: testTraitsWithDelegate.d(13): Error: expression template __lambda2 is void and has no value I do not want to run it only to save the «function» somewhere.

Re: Delegate, scope and associative array

2014-06-02 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 2 June 2014 at 20:09:12 UTC, Edwin van Leeuwen wrote: I'm probably missing something basic, but I am confused by what is going on in the following code. unittest { size_t delegate()[size_t] events; foreach( i; 1..4 ) { events[i] = { return i; }; } writeln(

Re: Different random shuffles generated when compiled with gdc than with dmd

2014-06-02 Thread Chris Cain via Digitalmars-d-learn
On Monday, 2 June 2014 at 18:46:18 UTC, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: I'm really sorry, Chris, I was obviously mixing things up: on rereading, the person in the earlier forum discussion (not PR thread) who talks about porting from Java wasn't you. I'm very glad to be

Fighting compiler - experienced programmer but D novice

2014-06-02 Thread Charles Parker via Digitalmars-d-learn
./graph_structures.d(124): Error: class graph_structures.node(D, E) is used as a type I have no idea what this means:( Once we create a class, the textbook examples show its use as a type which I believe is what C++ Java allow. Here's some code: class node(D, E) { int nid; D data;

Re: Fighting compiler - experienced programmer but D novice

2014-06-02 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jun 03, 2014 at 03:17:09AM +, Charles Parker via Digitalmars-d-learn wrote: ./graph_structures.d(124): Error: class graph_structures.node(D, E) is used as a type I have no idea what this means:( It usually means you tried to use an uninstantiated template as a type. [...]

Re: Fighting compiler - experienced programmer but D novice

2014-06-02 Thread Chris Cain via Digitalmars-d-learn
On Tuesday, 3 June 2014 at 03:17:10 UTC, Charles Parker wrote: ... Thanx for any help - Charlie Well one thing is that you don't need the type parameters on the this function. You're basically creating a templated this inside the templated class which is not what you want. try this:

Re: Fighting compiler - experienced programmer but D novice

2014-06-02 Thread Charles Parker via Digitalmars-d-learn
On Tuesday, 3 June 2014 at 03:35:46 UTC, Chris Cain wrote: On Tuesday, 3 June 2014 at 03:17:10 UTC, Charles Parker wrote: ... Thanx for any help - Charlie Well one thing is that you don't need the type parameters on the this function. You're basically creating a templated this inside the

Re: Delegate, scope and associative array

2014-06-02 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 2 June 2014 at 23:44:01 UTC, Rene Zwanenburg wrote: On Monday, 2 June 2014 at 20:09:12 UTC, Edwin van Leeuwen wrote: As you may have guessed, a workaround is to copy the iteration variable yourself: unittest { size_t delegate()[size_t] events; foreach(_i; 1..4 ) {