Getting around the lack of foreach in CTFE

2014-03-28 Thread Colin Grogan
I'm interested to hear peoples methods for getting around the lack of foreach loops while using CTFE? Currently, I've been using a lot of recursive templates, but its beginning to give me a headache and I'd like to see if there's better ways around it. On a related note, is there plans to

Re: Getting around the lack of foreach in CTFE

2014-03-28 Thread Colin Grogan
On Friday, 28 March 2014 at 13:49:59 UTC, Dicebot wrote: On Friday, 28 March 2014 at 11:59:47 UTC, Colin Grogan wrote: I'm interested to hear peoples methods for getting around the lack of foreach loops while using CTFE? Currently, I've been using a lot of recursive templates, but its

Re: Getting around the lack of foreach in CTFE

2014-03-28 Thread Colin Grogan
On Friday, 28 March 2014 at 15:39:48 UTC, monarch_dodra wrote: On Friday, 28 March 2014 at 14:42:54 UTC, Colin Grogan wrote: Im trying to parse command line args and then build a struct that will, at run-time, hold the data the user passed in via command line args. Very similar to Pythons

Creating an array of C structs

2014-01-27 Thread Colin Grogan
Why wont the following code compile? import std.stdio; void main() { myStruct[] mystructs = { {1, 1.1f}, {2, 2.2f} }; } extern(C){ struct myStruct{ int x; float y; } } It fails with the (unhelpful imo) error message: source/app.d(7): Error: a

Re: Creating an array of C structs

2014-01-27 Thread Colin Grogan
On Monday, 27 January 2014 at 09:34:04 UTC, Namespace wrote: On Monday, 27 January 2014 at 09:06:17 UTC, Colin Grogan wrote: Why wont the following code compile? import std.stdio; void main() { myStruct[] mystructs = { {1, 1.1f}, {2, 2.2f} }; } extern(C){ struct

Re: Delegate function access to classes local variable

2013-11-10 Thread Colin Grogan
On Friday, 8 November 2013 at 13:19:05 UTC, Colin Grogan wrote: On Friday, 8 November 2013 at 13:14:33 UTC, Timon Gehr wrote: On 11/08/2013 01:43 PM, Colin Grogan wrote: Hi folks, I'm having some issue getting a delegate function access to a classes member variable. At object construct

Re: Delegate function access to classes local variable

2013-11-08 Thread Colin Grogan
On Friday, 8 November 2013 at 13:10:10 UTC, Dicebot wrote: On Friday, 8 November 2013 at 12:43:37 UTC, Colin Grogan wrote: import std.stdio; void main() { Column!string col1 = new Column!string( {return test; }, Hello, ); Column!string col2 = new Column!string( {return vars[0]; }, World

Re: Delegate function access to classes local variable

2013-11-08 Thread Colin Grogan
On Friday, 8 November 2013 at 13:14:33 UTC, Timon Gehr wrote: On 11/08/2013 01:43 PM, Colin Grogan wrote: Hi folks, I'm having some issue getting a delegate function access to a classes member variable. At object construct time, I'm passing in a delegate function, and a list of parameters

Re: Shipping the DMD compiler with code

2013-11-04 Thread Colin Grogan
On Saturday, 2 November 2013 at 11:40:59 UTC, Jacob Carlborg wrote: On 2013-11-01 16:47, Colin Grogan wrote: I have a project I may need to write that is pretty performance intensive, but also needs to be quite customiseable. We previously had this done with Perl, and the customising came

Re: Shipping the DMD compiler with code

2013-11-01 Thread Colin Grogan
On Friday, 1 November 2013 at 16:12:10 UTC, Joseph Rushton Wakeling wrote: On 01/11/13 17:01, bearophile wrote: I think you are not allowed to redistribute the DMD compiler. So you have to use GDC or LDC (where LDC = LDC2). Many things are possible if you get permission from the right

Re: Shipping the DMD compiler with code

2013-11-01 Thread Colin Grogan
On Friday, 1 November 2013 at 17:07:48 UTC, John Colvin wrote: On Friday, 1 November 2013 at 15:47:56 UTC, Colin Grogan wrote: I have a project I may need to write that is pretty performance intensive, but also needs to be quite customiseable. We previously had this done with Perl

Re: Spawning a pty in D

2013-10-22 Thread Colin Grogan
On Thursday, 17 October 2013 at 14:12:36 UTC, Adam D. Ruppe wrote: On Thursday, 17 October 2013 at 13:53:39 UTC, Colin Grogan wrote: Anyone have any experience with this? I actually have been writing a terminal emulator for the last few weeks https://github.com/adamdruppe/terminal-emulator

Spawning a pty in D

2013-10-17 Thread Colin Grogan
Im having an issue I can link to the C header file pty.h (http://man7.org/linux/man-pages/man3/openpty.3.html) and call forkpty like here: http://dpaste.dzfl.pl/c3b07855 You have to compile that by linking with the util library ( add libs-posix: [util] to dubs package.json ) For ease of

Re: std.process spawnShell/pipeShell dont capture output of the shell

2013-10-11 Thread Colin Grogan
On Thursday, 10 October 2013 at 01:24:03 UTC, Jesse Phillips wrote: On Wednesday, 9 October 2013 at 14:54:32 UTC, Colin Grogan wrote: is blocking. However, its not meant to be blocking is it not? That new /bin/bash process is meant to run in parallel to the main process? I'm not sure exactly

std.process spawnShell/pipeShell dont capture output of the shell

2013-10-09 Thread Colin Grogan
Hi folks, Is there anyway to make std.process.spawnShell or std.process.pipeShell capture the output of the shell interface? For example, the code: import std.stdio; import std.process; void main(string[] args){ writefln(Executing: %s, args[1]); auto processPipes =

Re: std.process spawnShell/pipeShell dont capture output of the shell

2013-10-09 Thread Colin Grogan
On Wednesday, 9 October 2013 at 14:27:30 UTC, Jesse Phillips wrote: On Wednesday, 9 October 2013 at 11:22:26 UTC, Colin Grogan wrote: ~/test$ ./mess ls Executing: ls STDOUT: mess STDOUT: text.txt Thats all fine, however, I'd expect it to print another ~/test$ at the end, as if its

Re: Creating a virtual stdin/stdout/stderr

2013-10-08 Thread Colin Grogan
On Tuesday, 8 October 2013 at 20:25:42 UTC, Colin Grogan wrote: Hi all, I want to create my own File in memory that I can pipe output to and read it in from another part of the program. I dont want to physically write data to disk, just store it in memory. I've been trawling

Creating a virtual stdin/stdout/stderr

2013-10-08 Thread Colin Grogan
Hi all, I want to create my own File in memory that I can pipe output to and read it in from another part of the program. I dont want to physically write data to disk, just store it in memory. I've been trawling the documentation for the past while and the closest I can find is

Re: Creating a virtual stdin/stdout/stderr

2013-10-08 Thread Colin Grogan
On Tuesday, 8 October 2013 at 20:38:56 UTC, Daniel Davidson wrote: On Tuesday, 8 October 2013 at 20:26:49 UTC, Colin Grogan wrote: On Tuesday, 8 October 2013 at 20:25:42 UTC, Colin Grogan wrote: Hi all, I want to create my own File in memory that I can pipe output to and read it in from

Re: object.Exception@std/stdio.d(1321): Enforcement failed - I must be doing something wrong?

2013-08-15 Thread Colin Grogan
. Thanks! On Thursday, 15 August 2013 at 17:33:11 UTC, Ali Çehreli wrote: On 08/15/2013 10:03 AM, Colin Grogan wrote: I've done this a million times (I thought!) but I'm getting a strange error I cant figure out. The code: void writeMsg(string msg){ logFile.writeln(msg); What

Re: object.Exception@std/stdio.d(1321): Enforcement failed - I must be doing something wrong?

2013-08-15 Thread Colin Grogan
() fails. This is why I'm thinking its locking but not releasing? On Thursday, 15 August 2013 at 17:41:00 UTC, Colin Grogan wrote: Hi Ali, Heres my full Logger class. module utils.log; import std.stdio; import std.string; import std.datetime; public enum LogLevel {Fatal=0, Severe=1, Info=2

Re: D slicing

2013-06-18 Thread Colin Grogan
On Monday, 17 June 2013 at 23:48:36 UTC, Ali Çehreli wrote: On 06/17/2013 04:34 PM, Colin Grogan wrote: Wondering what way I'd go about this, I want to slice an array into two arrays. First array containing every even index (i.e. 0,2,4,6,8..$) Second slice containing every odd index (i.e

D slicing

2013-06-17 Thread Colin Grogan
Hi all. Wondering what way I'd go about this, I want to slice an array into two arrays. First array containing every even index (i.e. 0,2,4,6,8..$) Second slice containing every odd index (i.e. 1,3,5,7,9..$) -- be some issue with using $ depending on if orig length is odd or even. Can work

Working with modules

2013-02-15 Thread Colin Grogan
Hi all, I have a question regarding how to lay out my code. I wish to have a project directory structure that resembles java projects (As I'm comfortable working in that sort of environment For example: $PROJHOME |-/src - Source code |-/lib - third party libraries |-/bin

Re: Working with modules

2013-02-15 Thread Colin Grogan
On Friday, 15 February 2013 at 10:01:35 UTC, Jonathan M Davis wrote: On Friday, February 15, 2013 10:51:00 Colin Grogan wrote: Does anyone here have any alternatives for me so that in my 'engine' or 'main' classes I can simply write: import utils; and still have my source files neatly

Re: Working with modules

2013-02-15 Thread Colin Grogan
On Friday, 15 February 2013 at 10:40:57 UTC, Dicebot wrote: On Friday, 15 February 2013 at 10:31:41 UTC, Colin Grogan wrote: Ah, ok. So, I have my structure like so: $PROJHOME |-src |-utils |- Logger.d // contains module utils.Logger |- Props.d // contains module

Re: Working with modules

2013-02-15 Thread Colin Grogan
Ok, I had a minute so I tested it out. I had the following: src/main.d: import utils._; void main(string[] args){ logger l = new logger(); props p = new props(); l.print(); p.print(); } src/utils/_.d module utils._; public import utils.props,