Re: Stop to! rounding?

2013-07-03 Thread Josh
On Wednesday, 3 July 2013 at 04:51:06 UTC, Jonathan M Davis wrote: On Wednesday, July 03, 2013 06:44:33 Josh wrote: On Wednesday, 3 July 2013 at 04:32:15 UTC, Jonathan M Davis wrote: On Wednesday, July 03, 2013 06:23:12 Josh wrote: writeln(to!double(151.42499));//prints 151.425 Is

Re: How to get warnings about unused imports ?

2013-07-03 Thread Namespace
On Tuesday, 2 July 2013 at 21:49:37 UTC, Gabi wrote: Hi, How to find unused imports ? It seems the compiler doesn't do it, but is there any other tool for that? This seems like small issue, but those unused imports pile up pretty quickly Regards, Gabi I'm working on something like that

Re: Stop to! rounding?

2013-07-03 Thread Jonathan M Davis
On Wednesday, July 03, 2013 08:11:50 Josh wrote: Jonathan, do you know of any fixed point D library? If not, would it be worth me making one for phobos? I am unaware of one, and I don't really know why anyone would really want fixed point rather than floating point, so I don't know what use

Re: Stop to! rounding?

2013-07-03 Thread Jonathan M Davis
On Tuesday, July 02, 2013 22:14:33 Ali Çehreli wrote: On 07/02/2013 10:09 PM, Jonathan M Davis wrote: On Wednesday, July 03, 2013 07:04:47 cal wrote: void main() { double d = 151.42499; assert(d == 151.42499); } The rounding occurs in writeln surely.

Re: Stop to! rounding?

2013-07-03 Thread Timon Gehr
On 07/03/2013 07:21 AM, H. S. Teoh wrote: On Tue, Jul 02, 2013 at 10:14:33PM -0700, Ali Çehreli wrote: [...] import std.stdio; import std.conv; void main() { auto a = to!double(151.42499); writefln(%.60f, a); } I wouldn't write it like that; IMO it's better to write:

Re: Stop to! rounding?

2013-07-03 Thread monarch_dodra
On Wednesday, 3 July 2013 at 06:18:28 UTC, Jonathan M Davis wrote: On Wednesday, July 03, 2013 08:11:50 Josh wrote: Jonathan, do you know of any fixed point D library? If not, would it be worth me making one for phobos? I am unaware of one, and I don't really know why anyone would really

Re: How to get warnings about unused imports ?

2013-07-03 Thread Gabi
On Wednesday, 3 July 2013 at 06:12:46 UTC, Namespace wrote: On Tuesday, 2 July 2013 at 21:49:37 UTC, Gabi wrote: Hi, How to find unused imports ? It seems the compiler doesn't do it, but is there any other tool for that? This seems like small issue, but those unused imports pile up pretty

Re: Stop to! rounding?

2013-07-03 Thread Maxim Fomin
On Wednesday, 3 July 2013 at 08:23:40 UTC, monarch_dodra wrote: My brother in law writes financial apps, and in that field, using floating points type is *legally* forbidden. Really? What kind of apps?

Re: Stop to! rounding?

2013-07-03 Thread monarch_dodra
On Wednesday, 3 July 2013 at 08:27:52 UTC, Maxim Fomin wrote: On Wednesday, 3 July 2013 at 08:23:40 UTC, monarch_dodra wrote: My brother in law writes financial apps, and in that field, using floating points type is *legally* forbidden. Really? What kind of apps? I meant apps as in

Re: Stop to! rounding?

2013-07-03 Thread bearophile
Josh: Is there any way I would be able to hold that number then? One way to do that is with a simple rationals library, represented as pairs of bigints. Bye, bearophile

Re: ref tuples

2013-07-03 Thread Artur Skawina
On 07/03/13 02:22, Brad Anderson wrote: C++11's std::tuple includes a function std::tie that takes references to the arguments and returns a tuple that maintains the references to the arguments. Along with the usual cases where you'd want reference semantics it also enables this

Re: ref tuples

2013-07-03 Thread Dicebot
On Wednesday, 3 July 2013 at 11:54:39 UTC, Artur Skawina wrote: Well, aliases can be used to get a similar effect. template tie(A...) { alias tie = A; } tie!(a, b) = tuple(1, 2); artur Which is actually already in Phobos: TypeTuple!(a, b) = tuple(1, 2);

Re: Stop to! rounding?

2013-07-03 Thread Jay Norwood
On Wednesday, 3 July 2013 at 08:23:40 UTC, monarch_dodra wrote: On Wednesday, 3 July 2013 at 06:18:28 UTC, Jonathan M Davis wrote: On Wednesday, July 03, 2013 08:11:50 Josh wrote: Long story short, I think both would be a great addition to phobos/D. I'd personally really want to play with

Re: Address of overloaded functions

2013-07-03 Thread Artur Skawina
On 07/03/13 16:52, John Colvin wrote: Is there any way to take the address of any of an overloaded set of functions? import std.stdio; void foo(int a){ writeln(overload int); } void foo(long b){ writeln(overload long); } void main() { auto b = foo; //ambiguous = error b(2);

Re: Address of overloaded functions

2013-07-03 Thread Artur Skawina
On 07/03/13 17:03, Artur Skawina wrote: On 07/03/13 16:52, John Colvin wrote: Is there any way to take the address of any of an overloaded set of functions? import std.stdio; void foo(int a){ writeln(overload int); } void foo(long b){ writeln(overload long); } void main() { auto b

Re: Address of overloaded functions

2013-07-03 Thread Dicebot
On Wednesday, 3 July 2013 at 14:52:32 UTC, John Colvin wrote: Is there any way to take the address of any of an overloaded set of functions? import std.stdio; void foo(int a){ writeln(overload int); } void foo(long b){ writeln(overload long); } void main() { auto b = foo; //ambiguous =

Re: Address of overloaded functions

2013-07-03 Thread John Colvin
On Wednesday, 3 July 2013 at 15:03:46 UTC, Artur Skawina wrote: On 07/03/13 16:52, John Colvin wrote: Is there any way to take the address of any of an overloaded set of functions? import std.stdio; void foo(int a){ writeln(overload int); } void foo(long b){ writeln(overload long); } void

Re: Address of overloaded functions

2013-07-03 Thread Artur Skawina
On 07/03/13 17:17, John Colvin wrote: On Wednesday, 3 July 2013 at 15:05:00 UTC, Dicebot wrote: On Wednesday, 3 July 2013 at 14:52:32 UTC, John Colvin wrote: Is there any way to take the address of any of an overloaded set of functions? import std.stdio; void foo(int a){ writeln(overload

Re: Address of overloaded functions

2013-07-03 Thread H. S. Teoh
On Wed, Jul 03, 2013 at 05:15:48PM +0200, John Colvin wrote: On Wednesday, 3 July 2013 at 15:03:46 UTC, Artur Skawina wrote: On 07/03/13 16:52, John Colvin wrote: Is there any way to take the address of any of an overloaded set of functions? import std.stdio; void foo(int a){

Re: Address of overloaded functions

2013-07-03 Thread Artur Skawina
On 07/03/13 17:27, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 05:15:48PM +0200, John Colvin wrote: On Wednesday, 3 July 2013 at 15:03:46 UTC, Artur Skawina wrote: On 07/03/13 16:52, John Colvin wrote: Is there any way to take the address of any of an overloaded set of functions? import

Re: Address of overloaded functions

2013-07-03 Thread H. S. Teoh
On Wed, Jul 03, 2013 at 05:41:25PM +0200, Artur Skawina wrote: On 07/03/13 17:27, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 05:15:48PM +0200, John Colvin wrote: On Wednesday, 3 July 2013 at 15:03:46 UTC, Artur Skawina wrote: On 07/03/13 16:52, John Colvin wrote: Is there any way to take

Re: Address of overloaded functions

2013-07-03 Thread Artur Skawina
On 07/03/13 17:43, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 05:41:25PM +0200, Artur Skawina wrote: On 07/03/13 17:27, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 05:15:48PM +0200, John Colvin wrote: On Wednesday, 3 July 2013 at 15:03:46 UTC, Artur Skawina wrote: On 07/03/13 16:52, John Colvin

Re: Address of overloaded functions

2013-07-03 Thread H. S. Teoh
On Wed, Jul 03, 2013 at 06:07:07PM +0200, Artur Skawina wrote: On 07/03/13 17:43, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 05:41:25PM +0200, Artur Skawina wrote: On 07/03/13 17:27, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 05:15:48PM +0200, John Colvin wrote: On Wednesday, 3 July 2013 at

Re: ref tuples

2013-07-03 Thread Artur Skawina
On 07/03/13 18:29, Brad Anderson wrote: On Wednesday, 3 July 2013 at 11:54:39 UTC, Artur Skawina wrote: On 07/03/13 02:22, Brad Anderson wrote: C++11's std::tuple includes a function std::tie that takes references to the arguments and returns a tuple that maintains the references to the

Re: Address of overloaded functions

2013-07-03 Thread Artur Skawina
On 07/03/13 18:24, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 06:07:07PM +0200, Artur Skawina wrote: The context dependence isn't ideal, but what's the alternative?... [...] Explicit syntax for specifying overloads? ;-) Not like that would happen in D, though. Real Programmers need no

Re: ref tuples

2013-07-03 Thread Brad Anderson
On Wednesday, 3 July 2013 at 16:35:18 UTC, Artur Skawina wrote: On 07/03/13 18:29, Brad Anderson wrote: On Wednesday, 3 July 2013 at 11:54:39 UTC, Artur Skawina wrote: On 07/03/13 02:22, Brad Anderson wrote: C++11's std::tuple includes a function std::tie that takes references to the

Re: Ping qznc: Re: A little of coordination for Rosettacode

2013-07-03 Thread Marco Leise
Am Sat, 22 Jun 2013 23:27:00 +0200 schrieb bearophile bearophileh...@lycos.com: Ali Çehreli: The code compiles under 32-bit (e.g. with the -m32 compiler switch) where size_t is an alias of uint. Oh, I see. I compile most of the code on a 32 bit system. I asked Walter to warn d

Re: How to get warnings about unused imports ?

2013-07-03 Thread Namespace
You have to parse the unnamed import files, list all their identifiers (global variables, public functions etc.) and search for them. ;) That could be a bit complicated. ;) Therefore I don't want to do it. Even with named imports you can get false positives. But if you like it, you could

Re: Stop to! rounding?

2013-07-03 Thread Marco Leise
Am Tue, 2 Jul 2013 22:21:52 -0700 schrieb H. S. Teoh hst...@quickfur.ath.cx: On Tue, Jul 02, 2013 at 10:14:33PM -0700, Ali Çehreli wrote: [...] import std.stdio; import std.conv; void main() { auto a = to!double(151.42499); writefln(%.60f, a); } I wouldn't write it

Re: ref tuples

2013-07-03 Thread Simen Kjaeraas
On 2013-07-03, 02:22, Brad Anderson wrote: C++11's std::tuple includes a function std::tie that takes references to the arguments and returns a tuple that maintains the references to the arguments. Along with the usual cases where you'd want reference semantics it also enables this

Re: Stop to! rounding?

2013-07-03 Thread H. S. Teoh
On Wed, Jul 03, 2013 at 07:56:28PM +0200, Marco Leise wrote: Am Tue, 2 Jul 2013 22:21:52 -0700 schrieb H. S. Teoh hst...@quickfur.ath.cx: On Tue, Jul 02, 2013 at 10:14:33PM -0700, Ali Çehreli wrote: [...] import std.stdio; import std.conv; void main() { auto a =

Re: Address of overloaded functions

2013-07-03 Thread H. S. Teoh
On Wed, Jul 03, 2013 at 06:52:56PM +0200, Artur Skawina wrote: On 07/03/13 18:24, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 06:07:07PM +0200, Artur Skawina wrote: The context dependence isn't ideal, but what's the alternative?... [...] Explicit syntax for specifying overloads? ;-) Not

Re: Error: this for method name needs to be type S not type MapResult!...

2013-07-03 Thread Michael
On Saturday, 29 June 2013 at 19:44:00 UTC, Peter Neubauer wrote: Please explain why this error happens in the following code: import std.algorithm; struct S { void foo () { int f1 (int a) { return conv(a); } int delegate (int) f2 = conv; int[] x = [1, 2, 3]; x.map!conv;

Re: ref tuples

2013-07-03 Thread Artur Skawina
On 07/03/13 19:10, Brad Anderson wrote: On Wednesday, 3 July 2013 at 16:35:18 UTC, Artur Skawina wrote: On 07/03/13 18:29, Brad Anderson wrote: On Wednesday, 3 July 2013 at 11:54:39 UTC, Artur Skawina wrote: On 07/03/13 02:22, Brad Anderson wrote: C++11's std::tuple includes a function

Re: Address of overloaded functions

2013-07-03 Thread Artur Skawina
On 07/03/13 21:02, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 06:52:56PM +0200, Artur Skawina wrote: void main() { auto b = pickOverload!(foo, long); Now *that's* what I call coolness. Self-documenting and convenient to use (though in this case it's arguable whether it's

reading a structure (eg header info) from file

2013-07-03 Thread captaindet
hi, whilst converting some of my C code into D i got stuck. in C: typedef struct { /* info */ } INFO; INFO info; size_t checkio; // read INFO from data file: pf_datafile = fopen(datafile,rb); checkio = fread((char *) info, sizeof(info), 1, pf_datafile); how do i do this in D? i'd like to

Re: Address of overloaded functions

2013-07-03 Thread H. S. Teoh
On Wed, Jul 03, 2013 at 10:10:08PM +0200, Artur Skawina wrote: On 07/03/13 21:02, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 06:52:56PM +0200, Artur Skawina wrote: void main() { auto b = pickOverload!(foo, long); Now *that's* what I call coolness. Self-documenting and

Re: Address of overloaded functions

2013-07-03 Thread Artur Skawina
On 07/03/13 22:44, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 10:10:08PM +0200, Artur Skawina wrote: On 07/03/13 21:02, H. S. Teoh wrote: On Wed, Jul 03, 2013 at 06:52:56PM +0200, Artur Skawina wrote: void main() { auto b = pickOverload!(foo, long); Now *that's* what I call

Re: Address of overloaded functions

2013-07-03 Thread Tyro[17]
On 7/3/13 12:52 PM, Artur Skawina wrote: import std.stdio; void foo(int a){ writeln(overload int); } void foo(long b){ writeln(overload long); } auto pickOverload(alias FP, A...)() @property { typeof(FP(A.init)) function(A) fp = FP; return fp;} void main() { auto

stdout in binary mode

2013-07-03 Thread bearophile
How do you open stdout in binary mode with D/Phobos? In C++ you use something like: setmode(fileno(stdout), O_BINARY); (I don't even know where to find O_BINARY in core.stdc). Bye and thank you, bearophile

Re: Can't print inout parameter

2013-07-03 Thread gerleim
inout(int) foo (inout int a) { writeln(a); return a; } I don't know if this is the official method, but writeln(cast(const)x); works. Trying to get answers at: http://stackoverflow.com/questions/17460065/how-to-print-inout-parameters

inverse of std.demangle?

2013-07-03 Thread Timothee Cour
I'd like to have a function: string mangle(string mangled_string); unittest{ void foo(int x){} assert(foo.mangleof.demangle.mangle == foo.mangleof); } is there such a functionality, even partially?

Re: reading a structure (eg header info) from file

2013-07-03 Thread Rikki Cattermole
On Wednesday, 3 July 2013 at 20:37:24 UTC, captaindet wrote: hi, whilst converting some of my C code into D i got stuck. in C: typedef struct { /* info */ } INFO; INFO info; size_t checkio; // read INFO from data file: pf_datafile = fopen(datafile,rb); checkio = fread((char *) info,

Re: reading a structure (eg header info) from file

2013-07-03 Thread Ali Çehreli
On 07/03/2013 01:37 PM, captaindet wrote: in C: typedef struct { /* info */ } INFO; INFO info; size_t checkio; // read INFO from data file: pf_datafile = fopen(datafile,rb); checkio = fread((char *) info, sizeof(info), 1, pf_datafile); Just a reminder: The operation above is not

Re: reading a structure (eg header info) from file

2013-07-03 Thread Jonathan M Davis
On Wednesday, July 03, 2013 15:37:28 captaindet wrote: hi, whilst converting some of my C code into D i got stuck. in C: typedef struct { /* info */ } INFO; INFO info; size_t checkio; // read INFO from data file: pf_datafile = fopen(datafile,rb); checkio = fread((char *) info,