Re: Multiple %s format specifiers with a single argument

2012-04-12 Thread Marco Leise
Am Thu, 12 Apr 2012 13:11:16 +1200 schrieb James Miller ja...@aatch.net: Its less using the email interface, and more people using braindead email clients. Gmail and Mutt (the two I use most) seem to handle replying well, setting the correct headers to indicate things. But I've seen some odd

Re: stdout redirect

2012-04-12 Thread Andrea Fontana
On Wednesday, 11 April 2012 at 15:25:56 UTC, Stefan wrote: On Wednesday, 11 April 2012 at 13:00:45 UTC, Andrea Fontana wrote: On Wednesday, 11 April 2012 at 12:46:30 UTC, Andrea Fontana wrote: How can I redirect stdout / stderr to file (from D not shell)? Self-reply: It works using std.c

Re: D Dll injection problem

2012-04-12 Thread maarten van damme
I tried again with a few other random C dll's stolen around my system and they all work perfectly. it's only the D dll that gives me trouble.

Re: Name of files causes error. Why?

2012-04-12 Thread Xan
On Wednesday, 11 April 2012 at 19:50:18 UTC, Steven Schveighoffer wrote: On Wed, 11 Apr 2012 15:33:56 -0400, Xan xancor...@gmail.com 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:

Re: Static Associative Arrays

2012-04-12 Thread Christophe
Jonathan M Davis , dans le message (digitalmars.D.learn:34332), a écrit : On Sunday, April 08, 2012 01:24:02 Caligo wrote: On Sat, Apr 7, 2012 at 11:01 PM, Jonathan M Davis jmdavisp...@gmx.com wrote: What do you mean my static associative arrays? Are you asking why you can't initialize

Re: Name of files causes error. Why?

2012-04-12 Thread Manfred Nowak
Xan wrote: But it's a messy limitation. On the contrary: it requires work to implement limitations. Therefore limitations are implemented only to shield users from mess. Not having descovered any benefit of a limitation might point to insufficient empirical knowledge. -manfred

Re: Name of files causes error. Why?

2012-04-12 Thread Steven Schveighoffer
On Thu, 12 Apr 2012 08:30:50 -0400, Xan xancor...@gmail.com wrote: On Wednesday, 11 April 2012 at 19:50:18 UTC, Steven Schveighoffer wrote: Now, you *can* possibly name the module differently using a module statement, but this is highly discouraged. If you do this, the only way another

Question Object.factory and namespaces.

2012-04-12 Thread dcoder
Hello. I am reading through TDPL by Andresscu. The book has the following example, which I am abbreviating: void main( string[] args) { Stat [] stats; foreach( arg; args[1..$]) { auto newStat = cast(Stat) Object.factory( statsinc04. ~ arg); enforce( newStat, Invalid

Re: D Dll injection problem

2012-04-12 Thread Kagamin
#include windows.h void main() { LPTHREAD_START_ROUTINE LoadLibAddy = (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle(kernel32.dll), LoadLibraryA); CreateThread(NULL,0,LoadLibAddy,mydll.dll,0,NULL); } ?

Re: D Dll injection problem

2012-04-12 Thread maarten van damme
works and GetLastError() returns 0 in both cases. Op 12 april 2012 16:13 schreef Kagamin s...@here.lot het volgende: #include windows.h void main() { LPTHREAD_START_ROUTINE LoadLibAddy = (LPTHREAD_START_ROUTINE)** GetProcAddress(**GetModuleHandle(kernel32.dll**), LoadLibraryA);

Sampling algorithms for D

2012-04-12 Thread Joseph Rushton Wakeling
Hello all, My programming experience is mostly in C with some C++, so much of the programming style of D is not familiar to me. With that in mind, I thought I'd set up a little pet project to try and learn good D programming style. What I thought I'd do is implement some clever algorithms

Re: Passing function as values and returning functions

2012-04-12 Thread James Miller
* Xan xancor...@gmail.com [2012-04-11 20:28:38 +0200]: On Wednesday, 11 April 2012 at 13:04:01 UTC, Steven Schveighoffer wrote: On Wed, 11 Apr 2012 08:53:00 -0400, Xan xancor...@gmail.com wrote: [snip] writeln(g(f)(1)); Unlike C, you *must* take the address of a function symbol to get

Re: Passing function as values and returning functions

2012-04-12 Thread James Miller
* James Miller ja...@aatch.net [2012-04-13 02:49:03 +1200]: Glad you got help Xan, but for future reference can you please keep questions to D.learn? It is somewhat frustrating to see the question How do I do that? on this list, since it is for discussion, and high-level questions, not for

Re: Passing function as values and returning functions

2012-04-12 Thread Steven Schveighoffer
On Thu, 12 Apr 2012 10:49:03 -0400, James Miller ja...@aatch.net wrote: Glad you got help Xan, but for future reference can you please keep questions to D.learn? It is somewhat frustrating to see the question How do I do that? on this list, since it is for discussion, and high-level questions,

Re: Question Object.factory and namespaces.

2012-04-12 Thread Justin Whear
On Thu, 12 Apr 2012 16:11:11 +0200, dcoder wrote: My question is, how do I change the code above so that it works even if I change the name of the file/module? I'm looking for clean solution something like a macro if one actually exists. Check out packageName, moduleName, and

Re: Sampling algorithms for D

2012-04-12 Thread Dmitry Olshansky
On 12.04.2012 18:45, Joseph Rushton Wakeling wrote: Hello all, Hello there, [snip] So, introduction away, here are the main questions I came up with in creating the code. (1) Effective handling of random numbers. The design concept was for the sampler classes to use a specified

Re: Question Object.factory and namespaces.

2012-04-12 Thread dcoder
On Thursday, 12 April 2012 at 15:36:25 UTC, Justin Whear wrote: On Thu, 12 Apr 2012 16:11:11 +0200, dcoder wrote: My question is, how do I change the code above so that it works even if I change the name of the file/module? I'm looking for clean solution something like a macro if one

Re: Question Object.factory and namespaces.

2012-04-12 Thread Justin Whear
Could it be my compiler version? Here's what I have: $ dmd DMD32 D Compiler v2.055 Yeah, I think those templates were added in the last release or two. The current version is 2.058 (and 2.059 is in beta).

Re: Sampling algorithms for D

2012-04-12 Thread James Miller
* Joseph Rushton Wakeling joseph.wakel...@webdrake.net [2012-04-12 16:45:34 +0200]: (3) Uniform random number on (0,1) The algorithms' specification explicitly refers to uniform random numbers on the open interval, which I take to mean (0,1) i.e. excluding zero. Phobos currently

Re: Sampling algorithms for D

2012-04-12 Thread Joseph Rushton Wakeling
On 12/04/12 18:26, James Miller wrote: There is support for fully all 4 types of intervals using std.random.uniform. You just specify the type of interval using a template parameter. The default is this: uniform!([))(a,b); And you want this: uniform!([])(a,b); You can also do () and (] to

Re: Sampling algorithms for D

2012-04-12 Thread Joseph Rushton Wakeling
On 12/04/12 16:45, Joseph Rushton Wakeling wrote: What I thought I'd do is implement some clever algorithms for random sampling which I've already done in a C based on the GNU Scientific Library. I noticed that there is already a randomSample class in std.random, which by the look of it is

Chaining std.algorithm functions

2012-04-12 Thread DH
Hi. I was wondering why the following works: filter!(a = a % 2 == 0)(map!(a = a + 1)([1,2,3,4,5])) but the following does not: [1,2,3,4,5] .map!(a = a + 1)() .filter!(a = a % 2 == 0)() ...giving me the error `Error: no property 'filter' for type 'Result'` The dot

Re: Chaining std.algorithm functions

2012-04-12 Thread Brad Anderson
On Thursday, 12 April 2012 at 17:00:37 UTC, DH wrote: Hi. I was wondering why the following works: filter!(a = a % 2 == 0)(map!(a = a + 1)([1,2,3,4,5])) but the following does not: [1,2,3,4,5] .map!(a = a + 1)() .filter!(a = a % 2 == 0)() ...giving me the error

Re: Chaining std.algorithm functions

2012-04-12 Thread H. S. Teoh
On Thu, Apr 12, 2012 at 07:00:35PM +0200, DH wrote: Hi. I was wondering why the following works: filter!(a = a % 2 == 0)(map!(a = a + 1)([1,2,3,4,5])) but the following does not: [1,2,3,4,5] .map!(a = a + 1)() .filter!(a = a % 2 == 0)() ...giving me the error

Re: Name of files causes error. Why?

2012-04-12 Thread Jonathan M Davis
On Thursday, April 12, 2012 14:30:50 Xan wrote: But it's a messy limitation. Why we should have it? For C++ compatibilities? Messy? How so? You can't put any characters in a module name which aren't valid identifiers. So what? Just name your module differently. Is your complaint that you

Trying to understand RandomSample struct in std.random

2012-04-12 Thread Joseph Rushton Wakeling
Hello all, I'm trying to understand the internal operations of the RandomSample struct in std.random. What gets output at the end is clearly an array containing a subset of the original input. But I can't understand how this is constructed. The constructor sets various initial values and

Re: Trying to understand RandomSample struct in std.random

2012-04-12 Thread Ali Çehreli
On 04/12/2012 11:30 AM, Joseph Rushton Wakeling wrote: What gets output at the end is clearly an array containing a subset of the original input. That's misleading. RandomSample is a lazy range. The output seems to be elements of an array only as you pull data out of this range. The

Re: Name of files causes error. Why?

2012-04-12 Thread bearophile
Manfred Nowak: On the contrary: it requires work to implement limitations. Therefore limitations are implemented only to shield users from mess. Also, removing limitations from a language is usually FAR simpler than introducing them later :-) Bye, bearophile

Re: Sampling algorithms for D

2012-04-12 Thread bearophile
Joseph Rushton Wakeling: https://github.com/WebDrake/SampleD Some comments on the details of your code: import std.c.time; In D there there is also the syntax: import std.c.time: foo, bar, baz; That tells the person that reads the code what names are used. --

Re: Trying to understand RandomSample struct in std.random

2012-04-12 Thread Joseph Rushton Wakeling
On 12/04/12 20:39, Ali Çehreli wrote: That's misleading. RandomSample is a lazy range. The output seems to be elements of an array only as you pull data out of this range. Ahhh, it's lazy evaluation. That would explain why you can set ret.gen = gen in the randomSample functions and have it

Re: Sampling algorithms for D

2012-04-12 Thread SomeDude
On Thursday, 12 April 2012 at 16:59:31 UTC, Joseph Rushton Wakeling wrote: On 12/04/12 16:45, Joseph Rushton Wakeling wrote: What I thought I'd do is implement some clever algorithms for random sampling which I've already done in a C based on the GNU Scientific Library. I noticed that there

Re: Trying to understand RandomSample struct in std.random

2012-04-12 Thread Ali Çehreli
On 04/12/2012 01:27 PM, Joseph Rushton Wakeling wrote: What I _still_ don't understand is the statement in the constructor: // we should skip some elements initially so we don't always // start with the first ... as it seems to me that doing so would bugger up the selection algorithm. The

Re: Sampling algorithms for D

2012-04-12 Thread Dmitry Olshansky
On 12.04.2012 20:59, Joseph Rushton Wakeling wrote: On 12/04/12 16:45, Joseph Rushton Wakeling wrote: What I thought I'd do is implement some clever algorithms for random sampling which I've already done in a C based on the GNU Scientific Library. I noticed that there is already a

Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.

2012-04-12 Thread vmars316
On Thursday, 12 April 2012 at 05:18:22 UTC, Andrej Mitrovic wrote: On 4/12/12, vmars316 vmars...@live.com wrote: What is looking for? *import* something? Remove the space between '-I' and the import path. Ah, Thank you very much, works perfectly. Ok, so that's Dmd with Dfl. The myForm.exe

Re: Sampling algorithms for D

2012-04-12 Thread Joseph Rushton Wakeling
On 12/04/12 21:54, bearophile wrote: Some comments on the details of your code: Thanks ever so much for the extensive review. import std.c.time; In D there there is also the syntax: import std.c.time: foo, bar, baz; That tells the person that reads the code what names are used. Is

Re: Sampling algorithms for D

2012-04-12 Thread Joseph Rushton Wakeling
On 12/04/12 21:54, bearophile wrote: sampling_test_simple!(VitterA!Random,Random)(100,5,urng); Currently your code doesn't work if you want to use a Xorshift generator. Ahhh, I see what you mean now -- the sampler classes are fine, but the way the main() function is written means you

Re: Sampling algorithms for D

2012-04-12 Thread bearophile
Joseph Rushton Wakeling: Thanks ever so much for the extensive review. They are shallow comments, mostly about syntax, etc. So writing them requires little time. Is this advised for all D modules, or just for stuff using the C standard library? I have said there is also the syntax

Re: Sampling algorithms for D

2012-04-12 Thread Joseph Rushton Wakeling
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 design a bit further before making any pull request

Re: Sampling algorithms for D

2012-04-12 Thread Joseph Rushton Wakeling
On 13/04/12 00:48, bearophile wrote: final size_t select(ref UniformRNG urng) { assert(_recordsRemaining 0); assert(_sampleRemaining 0); Probably it's better to move those asserts in preconditions/postconditions or in class/struct invariants. Those asserts are deliberately intended for the

Re: Sampling algorithms for D

2012-04-12 Thread bearophile
Joseph Rushton Wakeling: final size_t select(ref UniformRNG urng) { assert(_recordsRemaining 0); assert(_sampleRemaining 0); Probably it's better to move those asserts in preconditions/postconditions or in class/struct invariants. Those asserts are deliberately intended for

Library search path on Windows?

2012-04-12 Thread Alex Rønne Petersen
How do I pass a library search path to DMD on Windows? -- - Alex

Re: Library search path on Windows?

2012-04-12 Thread Alex Rønne Petersen
On 13-04-2012 03:10, Alex Rønne Petersen wrote: How do I pass a library search path to DMD on Windows? -L+path apparently... -- - Alex

Re: Library search path on Windows?

2012-04-12 Thread Jesse Phillips
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.

Re: Name of files causes error. Why?

2012-04-12 Thread Jesse Phillips
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 non-identifier characters in filename, use module declaration

FormatSpec struct

2012-04-12 Thread Paul D. Anderson
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 width = 9, precision = 6, using exponential notation. In std.format there is a FormatSpec struct