Can't get the tools suite to build using the posix.mak make file

2014-02-12 Thread Joseph Cassman
I created a straightforward script for x86_64 Linux which comes directly from the wiki: http://wiki.dlang.org/Building_DMD. The script is to automate pulling down a development snapshot of the ecosystem and build + install it. The build and test process for DMD, D runtime, and Phobos work fine.

Re: std.random.uniform for enums

2014-02-12 Thread Andrej Mitrovic
On 2/13/14, Anton wrote: > It would be useful if someone added this as an example to the > docs, so that beginners don't end up in the same situation as me > in the future. My mistake for not adding an example when implementing the function. Here we go: https://github.com/D-Programming-Language/

Re: std.random.uniform for enums

2014-02-12 Thread Anton
It would be useful if someone added this as an example to the docs, so that beginners don't end up in the same situation as me in the future.

Re: std.random.uniform for enums

2014-02-12 Thread Anton
On Thursday, 13 February 2014 at 02:59:01 UTC, Adam D. Ruppe wrote: On Thursday, 13 February 2014 at 02:52:44 UTC, Anton wrote: I guess I'm mostly confused because the description for one of the templates of std.random.uniform says "Returns a uniformly selected member of enum E. Oooh, I didn'

Re: std.random.uniform for enums

2014-02-12 Thread Meta
On Thursday, 13 February 2014 at 02:30:47 UTC, Frustrated wrote: On Thursday, 13 February 2014 at 02:14:02 UTC, Jakob Ovrum wrote: On Thursday, 13 February 2014 at 02:02:38 UTC, Anton wrote: I'm confused about how to use random.uniform to select a member of an enum. Say I have an enum like

Re: std.random.uniform for enums

2014-02-12 Thread Meta
On Thursday, 13 February 2014 at 02:52:44 UTC, Anton wrote: I guess I'm mostly confused because the description for one of the templates of std.random.uniform says "Returns a uniformly selected member of enum E. If no random number generator is passed, uses the default rndGen." So I was wonderi

Re: std.random.uniform for enums

2014-02-12 Thread Jakob Ovrum
On Thursday, 13 February 2014 at 03:04:06 UTC, Jakob Ovrum wrote: On Thursday, 13 February 2014 at 02:30:47 UTC, Frustrated wrote: Could you not simply select one at random by "name"? Even though the values of the enum may not be sequential the keys are. Yeah, and there is apparently already

Re: std.random.uniform for enums

2014-02-12 Thread Jakob Ovrum
On Thursday, 13 February 2014 at 02:30:47 UTC, Frustrated wrote: Could you not simply select one at random by "name"? Even though the values of the enum may not be sequential the keys are. Yeah, and there is apparently already an overload that does that. Regardless, I wrote a version that has

Re: std.random.uniform for enums

2014-02-12 Thread Adam D. Ruppe
On Thursday, 13 February 2014 at 02:52:44 UTC, Anton wrote: I guess I'm mostly confused because the description for one of the templates of std.random.uniform says "Returns a uniformly selected member of enum E. Oooh, I didn't know it had one of those, the documentation can be so hard to read

Re: std.random.uniform for enums

2014-02-12 Thread Anton
I guess I'm mostly confused because the description for one of the templates of std.random.uniform says "Returns a uniformly selected member of enum E. If no random number generator is passed, uses the default rndGen." So I was wondering why that functionality didn't seem to work as I thought i

Re: std.random.uniform for enums

2014-02-12 Thread Frustrated
On Thursday, 13 February 2014 at 02:14:02 UTC, Jakob Ovrum wrote: On Thursday, 13 February 2014 at 02:02:38 UTC, Anton wrote: I'm confused about how to use random.uniform to select a member of an enum. Say I have an enum like enum Animals { cat = 0, dog = 1, chimpanzee =

Re: std.random.uniform for enums

2014-02-12 Thread Adam D. Ruppe
On Thursday, 13 February 2014 at 02:02:38 UTC, Anton wrote: Am I misunderstanding how this function is meant to be used? Yeah, uniform takes two numerical arguments: a min and a max. It returns a value between the two, including the min, but not including the max. So int a = uniform(0, 10);

Re: std.random.uniform for enums

2014-02-12 Thread Jakob Ovrum
On Thursday, 13 February 2014 at 02:02:38 UTC, Anton wrote: I'm confused about how to use random.uniform to select a member of an enum. Say I have an enum like enum Animals { cat = 0, dog = 1, chimpanzee = 2 } I want to select a random animal. So far I've been t

std.random.uniform for enums

2014-02-12 Thread Anton
I'm confused about how to use random.uniform to select a member of an enum. Say I have an enum like enum Animals { cat = 0, dog = 1, chimpanzee = 2 } I want to select a random animal. So far I've been trying to do uniform(Animals), but every time I try to compil

Re: Custom default exception handler?

2014-02-12 Thread Sean Kelly
On Wednesday, 12 February 2014 at 22:42:45 UTC, Nick Sabalausky wrote: Hmm, that still isn't getting called for me either: void toString(scope void delegate(in char[]) sink) const { import std.stdio; writeln("In Fail.toString()"); sink("someapp: ERROR: "~msg); } Tried on both 2.064.2 and 2

Re: Custom default exception handler?

2014-02-12 Thread Nick Sabalausky
On 2/12/2014 4:14 PM, Sean Kelly wrote: It looks like this has changed, and the method that's called now is: void toString(scope void delegate(in char[]) sink) const; I suspect this has broken a lot of custom exception messages, since everything in core.exception still uses toString() for its

Re: Multiple-OS Header Access

2014-02-12 Thread Nick Sabalausky
On 2/12/2014 12:21 PM, Malkierian wrote: Alright, so I'm making a little utility, and it looks like I'm going to need to access OS-specific header functions on each operating system in order to make it work, because 1) I want to get a list of all active processes and their names and 2) I want to

Re: Multiple-OS Header Access

2014-02-12 Thread Adam D. Ruppe
On Wednesday, 12 February 2014 at 18:26:45 UTC, Jakob Ovrum wrote: I find POSIX much more palatable than the Windows API. POSIX is ok for what it does, but it doesn't actually do very much. The topics here, for example, are not standardized (I'm pretty sure anyway). Even de-facto standards li

Re: Custom default exception handler?

2014-02-12 Thread Sean Kelly
On Wednesday, 12 February 2014 at 03:31:38 UTC, Nick Sabalausky wrote: Hmm, my custom toString isn't being executed. Am I doing something wrong here? Same result if I inherit direct from Throwable instead of Exception. class Fail : Exception { private this() { super(null);

Re: Custom default exception handler?

2014-02-12 Thread Sean Kelly
On Wednesday, 12 February 2014 at 02:41:34 UTC, Nick Sabalausky wrote: On 2/11/2014 6:35 PM, Sean Kelly wrote: Throw a static exception (maybe even derived directly from Throwable), I assume then that throwing something directly derived from Throwable would still run cleanup code (like scope

Re: Ranges, constantly frustrating

2014-02-12 Thread Jesse Phillips
On Wednesday, 12 February 2014 at 10:52:13 UTC, Regan Heath wrote: On Tue, 11 Feb 2014 19:48:40 -, Jesse Phillips wrote: On Tuesday, 11 February 2014 at 10:10:27 UTC, Regan Heath wrote: Things like this should "just work".. File input ... auto range = input.byLine(); while(!range.empty

Re: Multiple-OS Header Access

2014-02-12 Thread Jakob Ovrum
On Wednesday, 12 February 2014 at 17:40:01 UTC, Adam D. Ruppe wrote: Linux is a pain in the ass to program for in any language... but if you can do it in C or C++, you can mostly just to the same thing in D. Might have to copy/paste function prototypes though. How so? I find POSIX much more p

Re: Multiple-OS Header Access

2014-02-12 Thread Adam D. Ruppe
Here's some more functions: version(linux) string getProcessCommandLine(long pid) { import std.file; import std.conv; return readText("/proc/" ~ to!string(pid) ~ "/cmdline"); } And for looking at windows, you'll want my simpledisplay.d and color.d from here: https://gi

Re: Minimal D executable on Windows x32

2014-02-12 Thread bearophile
RivenTheMage: Size of main.exe is 1068 bytes. I have tried it, and it works :-) Seems useful using the -betterC switch discussed in the main D newsgroup. Bye, bearophile

Re: Multiple-OS Header Access

2014-02-12 Thread Adam D. Ruppe
version(linux) void EnumProcessesLinux(void delegate(long) forEach) { import std.file; import std.algorithm; import std.ascii; import std.conv; foreach(string name; dirEntries("/proc/", SpanMode.shallow)) { name = name["/proc/".length .. $]

Re: Multiple-OS Header Access

2014-02-12 Thread Adam D. Ruppe
On Wednesday, 12 February 2014 at 17:21:52 UTC, Malkierian wrote: not to mention C++ specific on Windows They aren't really C++ specific, you can use them from a lot of languages, including C and D. So anyway, my question is, does D have the capability of interfacing with Linux and Mac such

Multiple-OS Header Access

2014-02-12 Thread Malkierian
Alright, so I'm making a little utility, and it looks like I'm going to need to access OS-specific header functions on each operating system in order to make it work, because 1) I want to get a list of all active processes and their names and 2) I want to periodically check which window current

Re: Thrift maintained..?

2014-02-12 Thread David Eagen
On Wednesday, 12 February 2014 at 07:53:44 UTC, simendsjo wrote: Well, that seems quite unprofessional.. Not fixing bugs that makes parts of their repository unusable.. To be fair he wasn't able to reproduce the problem. It built fine on his box. They list automake 1.9 as the requirement so p

Minimal D executable on Windows x32

2014-02-12 Thread RivenTheMage
Did it just for fun, maybe it will help someone :) Requires UniLink: ftp://ftp.styx.cabel.net/pub/UniLink main.d extern(C) void _acrtused_con() { mainFunc(); } extern(Windows) { int MessageBoxA(uint hWnd, char* lpText, char* lpCaption, uint uType); void ExitPro

Re: Ranges, constantly frustrating

2014-02-12 Thread Jakob Ovrum
On Wednesday, 12 February 2014 at 10:44:57 UTC, Regan Heath wrote: Ahh.. so this is a limitation of the range interface. Any plans to "fix" this? R Did my original reply not arrive? It is the first reply in the thread... Reproduced: See this pull request[1] and the linked enhancement re

Re: Ranges, constantly frustrating

2014-02-12 Thread Regan Heath
On Tue, 11 Feb 2014 19:48:40 -, Jesse Phillips wrote: On Tuesday, 11 February 2014 at 10:10:27 UTC, Regan Heath wrote: Things like this should "just work".. File input ... auto range = input.byLine(); while(!range.empty) { range.popFront(); foreach (i, line; range.take(4)) //Error

Re: Ranges, constantly frustrating

2014-02-12 Thread Regan Heath
On Tue, 11 Feb 2014 19:08:18 -, Jesse Phillips wrote: On Tuesday, 11 February 2014 at 13:00:19 UTC, Regan Heath wrote: import std.stdio; struct S1 { private int[] elements = [9,8,7]; int opApply (int delegate (ref uint, ref int) block) { foreach (uint i, int n ; this.elemen

Re: Ranges, constantly frustrating

2014-02-12 Thread Regan Heath
On Tue, 11 Feb 2014 19:16:31 -, Steven Schveighoffer wrote: On Tue, 11 Feb 2014 05:10:27 -0500, Regan Heath wrote: Things like this should "just work".. File input ... auto range = input.byLine(); while(!range.empty) { range.popFront(); foreach (i, line; range.take(4)) //Err

Re: Ranges, constantly frustrating

2014-02-12 Thread Regan Heath
On Tue, 11 Feb 2014 13:11:54 -, Tobias Pankrath wrote: On Tuesday, 11 February 2014 at 13:00:19 UTC, Regan Heath wrote: import std.stdio; struct S1 { private int[] elements = [9,8,7]; int opApply (int delegate (ref uint, ref int) block) { foreach (uint i, int n ; this.eleme

Re: Ranges, constantly frustrating

2014-02-12 Thread Regan Heath
On Tue, 11 Feb 2014 17:11:46 -, Ali Çehreli wrote: On 02/11/2014 06:25 AM, Rene Zwanenburg wrote: On Tuesday, 11 February 2014 at 10:10:27 UTC, Regan Heath wrote: foreach (i, line; range.take(4)) //Error: cannot infer argument types { ..etc.. } foreach (i, line; iota(siz

Re: Circular Buffer

2014-02-12 Thread Russel Winder
On Mon, 2014-02-10 at 11:33 +, bearophile wrote: > Russel Winder: > > >This really needs to get onto the D website somewhere. > > retro+cycle is very simple code, you can also combine them: > > alias retroCycle = compose!(cycle, retro); point-free composition. We like this :-) > Ranges and

Re: Circular Buffer

2014-02-12 Thread Russel Winder
On Mon, 2014-02-10 at 09:16 +, Gary Willoughby wrote: > On Monday, 10 February 2014 at 03:14:31 UTC, Jonathan Dunlap > wrote: > > (disclaimer: I'm new around here) > > Is it possible to cycle backwards? If not, what's the best > > approach? > > import std.algorithm; > import std.array; > imp