Compile time regex matching

2014-07-13 Thread Jason den Dulk via Digitalmars-d-learn
Hi I am trying to write some code that uses and matches to regular expressions at compile time, but the compiler won't let me because matchFirst and matchAll make use of malloc(). Is there an alternative that I can use that can be run at compile time? Thanks in advance. Jason

Re: Compile time regex matching

2014-07-15 Thread Jason den Dulk via Digitalmars-d-learn
On Monday, 14 July 2014 at 11:43:01 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: You can try Pegged, a parser generator that works at compile-time (both the generator and the generated parser). I did, and I got it to work. Unfortunately, the code used to in the CTFE is left in the

Re: lazy construction of an immutable object

2014-07-15 Thread Jason den Dulk via Digitalmars-d-learn
On Tuesday, 15 July 2014 at 12:20:57 UTC, Puming wrote: @property immutable(T) freeze(T)(T obj) { return cast(immutable(T))(obj); } What is the idiomatic approach to do this in D? There is a Phobos function std.exception.assumeUnique which performs this for arrays. According to

Template instantiation and string vs const char[]

2014-09-02 Thread Jason den Dulk via Digitalmars-d-learn
I have this piece of code: template somet(R...) { static if (R.length) { string somet = [\n~R[0]~\n ~ somet!(R[1..R.length]) ~ ]\n; } else string somet = ; } void main() { writeln(somet!(name,tame)); writeln(somet!name); } When I compile it, it generates the error

setup problem wih dub

2015-01-07 Thread Jason den Dulk via Digitalmars-d-learn
Hi. Package in question: fpdf Dub version I'm using: 0.9.22 DMD version: 2.066.1 (64 bit) Platform: Fedora 19 (64-bit). I created the fpdf package, and it is dependant on the imageformats package, but it won't compile. When I place a copy of imageformats.d into the project source directory,

32/64 bit in Phobos

2015-03-07 Thread Jason den Dulk via Digitalmars-d-learn
Hi I noticed that in 32bit, many Phobos functions use int and uint, while in 64bit, they use long and ulong. As a result I am having some difficulty in writing code that works for both 32 bit and 64 bit. Is there an existing mechanism that allows writing code that will work in both 32 bit