Re: Why approxEqual not working for integers in dmd 2068-b2

2015-07-28 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 28 Jul 2015 02:16:56 + lobo swampl...@gmail.com wrote: Hi all, I have a bunch of unittests for template code taking any numeric type. Because I'm lazy I just use the approxEqual for both floating point and integer comparisons in these tests. In DMD 2067.1 everthing

Re: Why approxEqual not working for integers in dmd 2068-b2

2015-07-28 Thread lobo via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 07:42:32 UTC, Daniel Kozák wrote: Even if this will be considered as non compiler bug, it is a regression on phobos side and should be addressed. So please fill a bug report on http://issues.dlang.org done, thanks https://issues.dlang.org/show_bug.cgi?id=14842

Re: Why approxEqual not working for integers in dmd 2068-b2

2015-07-28 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 28 Jul 2015 08:50:53 +0200 Daniel Kozák ko...@dlang.cz wrote: On Tue, 28 Jul 2015 02:16:56 + lobo swampl...@gmail.com wrote: I would say it is a compiler bug. consider this: bool some(real x, real y) { return true; } bool some(float x, float y) { return

Re: Yes or No Options

2015-07-28 Thread wobbles via Digitalmars-d-learn
On Monday, 27 July 2015 at 18:23:57 UTC, Alex wrote: On Monday, 27 July 2015 at 17:31:08 UTC, Ali Çehreli wrote: On 07/27/2015 08:50 AM, Alex wrote: a book that I bought The program looks a lot like one of the exercises in this chapter: http://ddili.org/ders/d.en/if.html You didn't

Re: Why approxEqual not working for integers in dmd 2068-b2

2015-07-28 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 28 Jul 2015 02:16:56 + lobo swampl...@gmail.com wrote: Hi all, I have a bunch of unittests for template code taking any numeric type. Because I'm lazy I just use the approxEqual for both floating point and integer comparisons in these tests. In DMD 2067.1 everthing

Shouldn't __FUNCTION__ return function name?

2015-07-28 Thread Andrea Fontana via Digitalmars-d-learn
Check this code: http://dpaste.dzfl.pl/a76db2cde13d When __FUNCTION__ is called inside a foreach body, it appears to be: f212.myFunction.__foreachbody1 Rather than: f212.myFunction. Is it correct? How can I get the function name?

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
Here is what I'm trying to do : import std.stdio : readf, writef; void main() { int[2][] nam; int num; readf( %d, num); nam.length = num; foreach(nim; 0..num){ readf( %d %d, nam[0][num], nam[1][num]); } foreach(nim;

Re: Dynamic memory

2015-07-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 16:09:46 UTC, Binarydepth wrote: readf( %d %d, nam[0][num], nam[1][num]); } foreach(nim; 0..num){ writef( %d %d\n, nam[0][num], nam[1][num]); Those indexes are backwards. And you really shouldn't need on write.

Re: Shouldn't __FUNCTION__ return function name?

2015-07-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/28/15 11:05 AM, Andrea Fontana wrote: Check this code: http://dpaste.dzfl.pl/a76db2cde13d When __FUNCTION__ is called inside a foreach body, it appears to be: f212.myFunction.__foreachbody1 Rather than: f212.myFunction. Is it correct? Yes. How can I get the function name? Be

Re: Shouldn't __FUNCTION__ return function name?

2015-07-28 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 15:13:28 UTC, Steven Schveighoffer wrote: How can I get the function name? Be outside foreach. The way foreach works in many cases (including foreach over an associative array), is that the compiler constructs an internal function delegate, then passes it to a

Re: Yes or No Options

2015-07-28 Thread Alex via Digitalmars-d-learn
So I now combined a few of the options here and got this, which finally works: import std.stdio; import std.string; import std.random; void main() { while (true) { string yesno; int weiter; char[] uschi; write(Press ENTER to roll the dice!);

Re: Dynamic memory

2015-07-28 Thread anonymous via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 16:41:40 UTC, Binarydepth wrote: It works with 2 as input but shows error when number is 3 :( I can't reproduce that or I misunderstood something: $ cat a.d import std.stdio : readf, writef; void main(){ int[2][] nam; int num; readf(

Re: Dynamic memory

2015-07-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/28/15 12:59 PM, Binarydepth wrote: My confusion comes because I declare int[2][] and then I use it backwards This can definitely be confusing. The way array types work in D is that they are of the form Type[]. This means that the element of Type[] is Type. When Type is actually another

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 16:24:39 UTC, anonymous wrote: On Tuesday, 28 July 2015 at 16:09:46 UTC, Binarydepth wrote: Here is what I'm trying to do : import std.stdio : readf, writef; void main() { int[2][] nam; int num; readf( %d, num); nam.length = num;

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 17:07:47 UTC, Steven Schveighoffer wrote: On 7/28/15 12:59 PM, Binarydepth wrote: When indexing, it always goes out to in. So nam[0] is the first element of type int[2], and nam[0][0] is the first integer in that first element. -Steve I don't get what you

Re: Dynamic memory

2015-07-28 Thread anonymous via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 16:09:46 UTC, Binarydepth wrote: Here is what I'm trying to do : import std.stdio : readf, writef; void main() { int[2][] nam; int num; readf( %d, num); nam.length = num; foreach(nim; 0..num){ readf( %d

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 16:12:28 UTC, Adam D. Ruppe wrote: On Tuesday, 28 July 2015 at 16:09:46 UTC, Binarydepth wrote: readf( %d %d, nam[0][num], nam[1][num]); } foreach(nim; 0..num){ writef( %d %d\n, nam[0][num], nam[1][num]); Those

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 16:24:39 UTC, anonymous wrote: On Tuesday, 28 July 2015 at 16:09:46 UTC, Binarydepth wrote: Here is what I'm trying to do : import std.stdio : readf, writef; void main() { int[2][] nam; int num; readf( %d, num); nam.length = num;

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 16:53:35 UTC, anonymous wrote: On Tuesday, 28 July 2015 at 16:41:40 UTC, Binarydepth wrote: It works with 2 as input but shows error when number is 3 :( I can't reproduce that or I misunderstood something: $ cat a.d import std.stdio : readf, writef; void main()

Re: Dynamic memory

2015-07-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/28/15 1:26 PM, Binarydepth wrote: On Tuesday, 28 July 2015 at 17:07:47 UTC, Steven Schveighoffer wrote: On 7/28/15 12:59 PM, Binarydepth wrote: When indexing, it always goes out to in. So nam[0] is the first element of type int[2], and nam[0][0] is the first integer in that first

Re: Dynamic memory

2015-07-28 Thread Ali Çehreli via Digitalmars-d-learn
On 07/28/2015 10:26 AM, Binarydepth wrote: In general I understood that in D multidimensional arrays are a group of arrays. The confusion comes from the fact that D does not have multidimensional arrays. (Neither C and nor C++.) The array syntax is simple. Definition: Type[] name;

Re: Dynamic memory

2015-07-28 Thread CraigDillabaugh via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 17:26:39 UTC, Binarydepth wrote: On Tuesday, 28 July 2015 at 17:07:47 UTC, Steven Schveighoffer wrote: On 7/28/15 12:59 PM, Binarydepth wrote: When indexing, it always goes out to in. So nam[0] is the first element of type int[2], and nam[0][0] is the first

Re: Dynamic memory

2015-07-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/28/15 3:33 PM, CraigDillabaugh wrote: 6. (IMHO) Code is actually more readable. But then I find lots of brackets confusing ... so maybe its just me. Have you considered a wrapper that uses multi-dimensional access? i.e.: my2darray[row, col] = blah; -Steve

Select value from list, indexed by a type

2015-07-28 Thread Johan Engelen via Digitalmars-d-learn
Hi all, I am wondering if there is any Phobos functionality for indexing into a list using a type. What I mean is something like: assert( somethingie!(float, float, double, real)(1, 22, 333) == 1 ); assert( somethingie!(double, float, double, real)(1, 22, 333) == 22 ); assert(

Re: Where can i find examples of multi-threaded fibers?

2015-07-28 Thread Rob T via Digitalmars-d-learn
On Monday, 27 July 2015 at 18:30:06 UTC, Gary Willoughby wrote: Where is the discussion? This must be it http://forum.dlang.org/thread/pflkijjjuyyhextxv...@forum.dlang.org I'm interested in the same subject right now, and was wondering about the same question you asked.

forward range properties with alias this - how?

2015-07-28 Thread Ivan Kazmenko via Digitalmars-d-learn
Hello, I wrap an array into a struct. Then I use alias this to expose the array functionality. Sadly, range properties of the array are not forwarded, and so I can't use the struct as an array with functions from std.algorithm and std.range. - import std.range, std.stdio; struct S {

Re: Dynamic memory

2015-07-28 Thread Binarydepth via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 17:34:46 UTC, Steven Schveighoffer wrote: On 7/28/15 1:26 PM, Binarydepth wrote: On Tuesday, 28 July 2015 at 17:07:47 UTC, Steven Schveighoffer wrote: On 7/28/15 12:59 PM, Binarydepth wrote: When indexing, it always goes out to in. So nam[0] is the first element

Re: Dynamic memory

2015-07-28 Thread CraigDillabaugh via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 20:07:12 UTC, Steven Schveighoffer wrote: On 7/28/15 3:33 PM, CraigDillabaugh wrote: 6. (IMHO) Code is actually more readable. But then I find lots of brackets confusing ... so maybe its just me. Have you considered a wrapper that uses multi-dimensional access?

Re: Select value from list, indexed by a type

2015-07-28 Thread anonymous via Digitalmars-d-learn
On Tuesday, 28 July 2015 at 21:12:13 UTC, Johan Engelen wrote: Hi all, I am wondering if there is any Phobos functionality for indexing into a list using a type. What I mean is something like: assert( somethingie!(float, float, double, real)(1, 22, 333) == 1 ); assert(