Re: FormatSpec struct

2012-04-13 Thread James Miller
* Paul D. Anderson paul.d.removethis.ander...@comcast.andthis.net [2012-04-13 07:50:31 +0200]: I'm trying to add formatted output to my decimal arithmetic module. Decimals should format like floating point, using 'E', 'F' and 'G', etc. I would expect a format string like %9.6e to parse as

Re: Sampling algorithms for D

2012-04-13 Thread Dmitry Olshansky
On 13.04.2012 1:48, Joseph Rushton Wakeling wrote: On 12/04/12 21:54, bearophile wrote: for( t=recordsRemaining-1; t=limit; --t) y2 *= top--/bottom--; Generally packing mutation of variables inside expressions is quite bad style. It makes code less easy to understand and translate, and

Re: Sampling algorithms for D

2012-04-13 Thread Dmitry Olshansky
On 13.04.2012 2:50, Joseph Rushton Wakeling wrote: On 12/04/12 23:34, Dmitry Olshansky wrote: Aye, and in general community does appreciate any enhancements via pull requests on github: https://github.com/D-Programming-Language OK, I'll see what I can do. I'd like to discuss and refine the

Re: FormatSpec struct

2012-04-13 Thread James Miller
* James Miller ja...@aatch.net [2012-04-13 19:16:48 +1200]: * Paul D. Anderson paul.d.removethis.ander...@comcast.andthis.net [2012-04-13 07:50:31 +0200]: I'm trying to add formatted output to my decimal arithmetic module. Decimals should format like floating point, using 'E', 'F' and 'G',

Re: Sampling algorithms for D

2012-04-13 Thread Joseph Rushton Wakeling
On 13/04/12 01:44, bearophile wrote: final size_t select(ref UniformRNG urng) in { assert(_recordsRemaining 0); assert(_sampleRemaining 0); } body { ... } OK. I'm confused by these asserts, because if I go beyond what is acceptable by calling select() even after I've

Re: Sampling algorithms for D

2012-04-13 Thread bearophile
Dmitry Olshansky: I believe it's something that reasonable people may disagree on. To me it's perfectly easy to see what return x++; does. I agree that return x++; is not too bad for a human reader, but code with mutation inside expressions (mostly written by other people) has caused me tons

Re: Sampling algorithms for D

2012-04-13 Thread bearophile
Joseph Rushton Wakeling: final size_t select(ref UniformRNG urng) in { assert(_recordsRemaining 0); assert(_sampleRemaining 0); } body { ... } OK. I'm confused by these asserts, What's confusing? I don't understand. It's contract-based programming, the code is

Re: Library search path on Windows?

2012-04-13 Thread Alex Rønne Petersen
On 13-04-2012 05:25, Jesse Phillips wrote: On Friday, 13 April 2012 at 01:10:40 UTC, Alex Rønne Petersen wrote: How do I pass a library search path to DMD on Windows? I would love to know too! Only place I found was to edit sc.ini sorry. It seems that -L+path does the trick... I only found

Re: Sampling algorithms for D

2012-04-13 Thread Joseph Rushton Wakeling
On 13/04/12 13:10, bearophile wrote: What's confusing? I don't understand. It's contract-based programming, the code is essentially the same as before: http://dlang.org/dbc.html No, I understand the principle; I just don't understand why the code is running without errors being displayed

Re: GUI library

2012-04-13 Thread Rizo Isrof
On Sunday, 25 March 2012 at 15:59:21 UTC, Jacob Carlborg wrote: On 2012-03-25 17:22, Kevin Cox wrote: I would reccomend Qt as well. You will get native cross-platform widgets with great performance. I am not sure how far QtD is but I know it once had a lot of development on it. I don't

Re: GUI library

2012-04-13 Thread Rizo Isrof
On Sunday, 25 March 2012 at 15:14:04 UTC, Jacob Carlborg wrote: It would also be possible to use Cocoa, as you do with Objective-C, but that wouldn't be very practically. There's also a DMD fork that directly supports interfacing with Objective-C: http://michelf.com/projects/d-objc/ Why do

Avoid compile time evaluation

2012-04-13 Thread Andrea Fontana
If I have something like: static int var = myFunction(); dmd will evaluate myFunction() at compile time. If it can't, it gives me a compile error, doesn't it? If I'm not wrong, static force this. If i don't use static, dmd will try to evaluate myfunction() at compile time, and if it can't,

Re: Avoid compile time evaluation

2012-04-13 Thread Simen Kjaeraas
On Fri, 13 Apr 2012 14:52:05 +0200, Andrea Fontana nos...@example.com wrote: If I have something like: static int var = myFunction(); dmd will evaluate myFunction() at compile time. If it can't, it gives me a compile error, doesn't it? If I'm not wrong, static force this. Indeed. If i

Re: GUI library

2012-04-13 Thread Piotr Szturmaj
Kevin Cox wrote: I would reccomend Qt as well. You will get native cross-platform widgets with great performance. I am not sure how far QtD is but I know it once had a lot of development on it. AFAIR, QtD is at the alpha stage. It's based on QtJambi, but there is another SMOKE generator,

D-Cocoa Port

2012-04-13 Thread Rizo Isrof
Hi, I am planning to use D for creating native applications on Mac OS X. For that, of course, D must interact with the Cocoa API. I have no knowledge of how this bindings could be done. I've already looked at Cocado[1] and do know the Michel Fortin's D-ObjC bridge[2], and would like to be

Re: GUI library

2012-04-13 Thread Jacob Carlborg
On 2012-04-13 14:47, Rizo Isrof wrote: On Sunday, 25 March 2012 at 15:59:21 UTC, Jacob Carlborg wrote: On 2012-03-25 17:22, Kevin Cox wrote: I would reccomend Qt as well. You will get native cross-platform widgets with great performance. I am not sure how far QtD is but I know it once had a

Re: GUI library

2012-04-13 Thread Jacob Carlborg
On 2012-04-13 14:51, Rizo Isrof wrote: On Sunday, 25 March 2012 at 15:14:04 UTC, Jacob Carlborg wrote: It would also be possible to use Cocoa, as you do with Objective-C, but that wouldn't be very practically. There's also a DMD fork that directly supports interfacing with Objective-C:

Re: Avoid compile time evaluation

2012-04-13 Thread Andrea Fontana
That's strange, so why writeln make it compile faster? :) I can't post the code, i'll try to reproduce it... On Friday, 13 April 2012 at 13:01:03 UTC, Simen Kjaeraas wrote: On Fri, 13 Apr 2012 14:52:05 +0200, Andrea Fontana nos...@example.com wrote: If I have something like: static int var

Re: D-Cocoa Port

2012-04-13 Thread Jacob Carlborg
On 2012-04-13 15:34, Rizo Isrof wrote: Hi, I am planning to use D for creating native applications on Mac OS X. For that, of course, D must interact with the Cocoa API. I have no knowledge of how this bindings could be done. I've already looked at Cocado[1] and do know the Michel Fortin's

Re: FormatSpec struct

2012-04-13 Thread Paul D. Anderson
On Friday, 13 April 2012 at 09:10:37 UTC, James Miller wrote: snip/ So I made the pull request, the documentation you need to read is here: https://github.com/Aatch/phobos/commit/cda3c079ee32d98a017f88949c10097840baa075 Hopefully it helps. -- James Miller Thanks. That did the trick. Paul

Creating a file in ~/.config (ubuntu)

2012-04-13 Thread Minas
I am trying to create a file in ~/.config My code is: [code] import std.stdio; void main() { auto f = File(~/.config/minas.txt, w); } [/code] However, an exception is thrown. std.exception.ErrnoException@std/stdio.d(288): Cannot open file `~/.config/minas.txt' in mode `w' (No such

Re: Creating a file in ~/.config (ubuntu)

2012-04-13 Thread Kevin Cox
Try using the $HOME environment variable.

Re: Creating a file in ~/.config (ubuntu)

2012-04-13 Thread Bystroushaak
Use std.path.expandTilde() - http://dlang.org/phobos/std_path.html#expandTilde On 13.4.2012 18:02, Minas wrote: I am trying to create a file in ~/.config My code is: [code] import std.stdio; void main() { auto f = File(~/.config/minas.txt, w); } [/code] However, an exception

Re: Sampling algorithms for D

2012-04-13 Thread Ali Çehreli
On 04/13/2012 02:41 AM, Joseph Rushton Wakeling wrote: On 13/04/12 01:44, bearophile wrote: final size_t select(ref UniformRNG urng) in { assert(_recordsRemaining 0); assert(_sampleRemaining 0); } body { ... } OK. I'm confused by these asserts, because if I go beyond what is acceptable

Re: Name of files causes error. Why?

2012-04-13 Thread Xan
On Friday, 13 April 2012 at 04:16:52 UTC, Jesse Phillips wrote: On Wednesday, 11 April 2012 at 19:33:58 UTC, Xan wrote: Hi, With helloworld program named with score or underscore, I receive the following __annoying__ error: $ gdmd-4.6 hola-temp.d hola-temp.d: Error: module hola-temp has

T : T*

2012-04-13 Thread Jonathan M Davis
I'd just like to verify that my understanding of T : T* in this template is correct: struct S(T : T*) { T t; } It's my understanding that it's requiring that the template argument be implicitly convertible to a pointer to that type. However, as this stackoverflow question shows:

Re: T : T*

2012-04-13 Thread Jonathan M Davis
On Friday, April 13, 2012 14:47:45 Jonathan M Davis wrote: I'd just like to verify that my understanding of T : T* in this template is correct: struct S(T : T*) { T t; } It's my understanding that it's requiring that the template argument be implicitly convertible to a pointer to that

Re: T : T*

2012-04-13 Thread Jakob Ovrum
On Friday, 13 April 2012 at 18:47:55 UTC, Jonathan M Davis wrote: I'd just like to verify that my understanding of T : T* in this template is correct: struct S(T : T*) { T t; } It's my understanding that it's requiring that the template argument be implicitly convertible to a pointer to

Re: T : T*

2012-04-13 Thread Jonathan M Davis
On Friday, April 13, 2012 21:04:07 Jakob Ovrum wrote: First, the argument type must match the form T*. The T can be any type; there is only one constraint here, the pointer head. So obviously, the argument type must be a pointer to anything to match T*, e.g. void*, shared(int)**,

Re: Creating a file in ~/.config (ubuntu)

2012-04-13 Thread Minas
On Friday, 13 April 2012 at 16:41:01 UTC, Bystroushaak wrote: Use std.path.expandTilde() - http://dlang.org/phobos/std_path.html#expandTilde Thank you very much! That did the trick! auto f = File(expandTilde(~/.config/test.txt,w));

Re: Sampling algorithms for D

2012-04-13 Thread Joseph Rushton Wakeling
On 13/04/12 19:49, Ali Çehreli wrote: This is a complicated issue that touches how in contracts are not inherited. I think your issue is because the interface does not define any in contracts, effectively allowing every call to select(). Please start reading here: :) You're absolutely right.

Contracts inheritance

2012-04-13 Thread Eyyub
Hai, After watching Walter's video at Lang.NEXT, I have wanted to know how contracts inheritance works. In the following code, I don't understand why foo.bar(2) works...but with the sames contracts in the foo function it doesn't work. http://paste.pocoo.org/show/3Ab5IiQk6hTiJ0jAFZWv/

Re: Contracts inheritance

2012-04-13 Thread Ali Çehreli
On 04/13/2012 03:07 PM, Eyyub wrote: Hai, After watching Walter's video at Lang.NEXT, I have wanted to know how contracts inheritance works. In the following code, I don't understand why foo.bar(2) works...but with the sames contracts in the foo function it doesn't work.

Re: Installing Modules

2012-04-13 Thread TJB
On Friday, 30 March 2012 at 00:20:16 UTC, TJB wrote: On Thursday, 29 March 2012 at 15:15:35 UTC, Jesse Phillips wrote: On Thursday, 29 March 2012 at 08:55:41 UTC, Johannes Pfau wrote: The command Jesse posted is missing a -L-lscid and you'll probably also need -L-L/usr/local/lib So the

Re: Installing Modules

2012-04-13 Thread Jesse Phillips
On Friday, 13 April 2012 at 23:06:38 UTC, TJB wrote: OK. I now can compile a simple program that imports a module from the SciD library. How do I do something a little more interesting like initialize a vector or matrix and do some linear algebra with it? Thanks so much for your help.

floats default to NaN... why?

2012-04-13 Thread F i L
From the FaQ: NaNs have the interesting property in that whenever a NaN is used as an operand in a computation, the result is a NaN. Therefore, NaNs will propagate and appear in the output whenever a computation made use of one. This implies that a NaN appearing in the output is an

Re: Library search path on Windows?

2012-04-13 Thread Mike Parker
On 4/13/2012 8:12 PM, Alex Rønne Petersen wrote: On 13-04-2012 05:25, Jesse Phillips wrote: On Friday, 13 April 2012 at 01:10:40 UTC, Alex Rønne Petersen wrote: How do I pass a library search path to DMD on Windows? I would love to know too! Only place I found was to edit sc.ini sorry. It

Re: floats default to NaN... why?

2012-04-13 Thread Jonathan M Davis
On Saturday, April 14, 2012 06:00:35 F i L wrote: From the FaQ: NaNs have the interesting property in that whenever a NaN is used as an operand in a computation, the result is a NaN. Therefore, NaNs will propagate and appear in the output whenever a computation made use of one. This

Re: floats default to NaN... why?

2012-04-13 Thread dennis luehring
Am 14.04.2012 06:00, schrieb F i L: struct Foo { int x, y;// ready for use. float z, w; // messes things up. float r = 0; // almost always... } how often in your code is 0 or 0.0 the real starting point? i can't think of any situation except counters or

Re: floats default to NaN... why?

2012-04-13 Thread F i L
So it's what I thought, the only reason is based on a faulty premise, IMO. Jonathan M Davis wrote: Types default to the closest thing that they have to an invalid value so that code blows up as soon as possible if you fail to initialize a variable to a proper value and so that it fails

Re: floats default to NaN... why?

2012-04-13 Thread F i L
On Saturday, 14 April 2012 at 05:19:38 UTC, dennis luehring wrote: Am 14.04.2012 06:00, schrieb F i L: struct Foo { int x, y;// ready for use. float z, w; // messes things up. float r = 0; // almost always... } how often in your code is 0 or 0.0 the real

Re: floats default to NaN... why?

2012-04-13 Thread Jonathan M Davis
On Saturday, April 14, 2012 07:41:33 F i L wrote: You're supposed to initialize them or assign them to appropriate values before using them. sure, but if they always default to _usable_ constants no expectations are lost and no bugs are created. No. You always have a bug if you don't