How do I do printf/writefln debugging in CTFE?

2012-05-12 Thread Chad J
Hi, It's been a while since I've used CTFE, and I was wondering if it has become possible to do something like this: void ctfeFunc(string arg) { pragma(msg, "arg is "~arg); } void main() { ctfeFunc("foo"); } That specific attempt gives me an error: test.d(3): Error: variable

Re: How do I do printf/writefln debugging in CTFE?

2012-05-13 Thread Chad J
On 05/13/2012 03:32 AM, Dmitry Olshansky wrote: On 13.05.2012 6:07, Chad J wrote: I want some way to print out the state of variables in a function being executed at compile time. Can it be done? Try pulling this guy (aka __ctfeWrite): https://github.com/D-Programming-Language/dmd/pull/692

Re: Segmentation fault hell in D

2012-06-09 Thread Chad J
On 06/08/2012 02:00 PM, Justin Whear wrote: On Fri, 08 Jun 2012 19:30:57 +0200, Jarl André wrote: Evry single time I encounter them I yawn. It means using the next frickin hour to comment away code, add more log statements and try to eleminate whats creating the hell of bugz, segmantation fault

phobos and splitting things... but not with whitespace.

2012-06-23 Thread Chad J
http://dlang.org/phobos/std_array.html#splitter The first thing I don't understand is why splitter is in /std.array/ and yet only works on /strings/. It is defined in terms of whitespace, and I don't understand how whitespace is well-defined for things besides text. Why wouldn't it be in std

Re: phobos and splitting things... but not with whitespace.

2012-06-23 Thread Chad J
I'm realizing that if I want to remove exactly one line from a string of text and make no assumptions about the type of newline ("\n" or "\r\n" or "\r") and without scanning the rest of the text then I'm not sure how to do this with a single call to phobos functions. I'd have to use indexOf an

Re: phobos and splitting things... but not with whitespace.

2012-06-23 Thread Chad J
On 06/23/2012 11:31 AM, simendsjo wrote: On Sat, 23 Jun 2012 17:19:59 +0200, Chad J wrote: http://dlang.org/phobos/std_array.html#splitter The first thing I don't understand is why splitter is in /std.array/ and yet only works on /strings/. It is defined > in terms of whitespac

Re: phobos and splitting things... but not with whitespace.

2012-06-23 Thread Chad J
On 06/23/2012 11:44 AM, simendsjo wrote: On Sat, 23 Jun 2012 17:39:55 +0200, Chad J wrote: On 06/23/2012 11:31 AM, simendsjo wrote: On Sat, 23 Jun 2012 17:19:59 +0200, Chad J wrote: http://dlang.org/phobos/std_array.html#splitter The first thing I don't understand is why splitter

Re: phobos and splitting things... but not with whitespace.

2012-06-23 Thread Chad J
On 06/23/2012 01:02 PM, simendsjo wrote: On Sat, 23 Jun 2012 18:56:24 +0200, simendsjo wrote: On Sat, 23 Jun 2012 18:50:05 +0200, Chad J wrote: Looking for findSplit? http://dlang.org/phobos/std_algorithm.html#findSplit Cool, that's what I want! Now if I could find the elegant w

Re: phobos and splitting things... but not with whitespace.

2012-06-23 Thread Chad J
On 06/23/2012 01:24 PM, Chad J wrote: On 06/23/2012 01:02 PM, simendsjo wrote: On Sat, 23 Jun 2012 18:56:24 +0200, simendsjo wrote: On Sat, 23 Jun 2012 18:50:05 +0200, Chad J wrote: Looking for findSplit? http://dlang.org/phobos/std_algorithm.html#findSplit Cool, that's what I want

Re: phobos and splitting things... but not with whitespace.

2012-06-23 Thread Chad J
On 06/23/2012 02:17 PM, simendsjo wrote: On Sat, 23 Jun 2012 19:52:32 +0200, Chad J wrote: As an additional note: I could probably do this easily if I had a function like findSplit where the predicate is used /instead/ of a delimiter. So like this: auto findSplit(alias pred = "a&q

Re: phobos and splitting things... but not with whitespace.

2012-06-23 Thread Chad J
On 06/23/2012 02:53 PM, simendsjo wrote: On Sat, 23 Jun 2012 20:41:29 +0200, Chad J wrote: Hey, thanks for doing all of that. I didn't expect you to write all of that. np Once I've established that the issue isn't just a lack of learning on my part, my subsequent objective

Re: phobos and splitting things... but not with whitespace.

2012-06-23 Thread Chad J
On 06/23/2012 03:41 PM, simendsjo wrote: On Sat, 23 Jun 2012 20:41:29 +0200, Chad J wrote: IMO the "take away a single line" thing should be accomplishable with a single concise expression This takes a range to match against, so much like startsWith: auto findSplitAny(Ran

Why are scope variables being deprecated?

2012-07-26 Thread Chad J
I keep hearing that scope variables are going away. I missed the discussion on it. Why is this happening? When I read about this, I have these in mind: void someFunc() { // foo is very likely to get stack allocated scope foo = new SomeClass(); foo.use(); // ~fo

Re: Why are scope variables being deprecated?

2012-07-26 Thread Chad J
On 07/26/2012 09:19 PM, Jonathan M Davis wrote: On Thursday, July 26, 2012 21:09:09 Chad J wrote: I keep hearing that scope variables are going away. I missed the discussion on it. Why is this happening? When I read about this, I have these in mind: void someFunc() { // foo is very

Differing levels of type-inference: Can D do this?

2012-07-27 Thread Chad J
Is there some way to do something similar to this right now? void main() { // Differing levels of type-inference: int[] r1 = [1,2,3]; // No type-inference. Range!(int) r2 = [1,2,3]; // Only range kind inferred. Range r3 = [1,2,3]; // Element type inferred. autor4 = [

Re: Differing levels of type-inference: Can D do this?

2012-07-28 Thread Chad J
On 07/28/2012 03:03 AM, Jonathan M Davis wrote: On Saturday, July 28, 2012 02:49:16 Chad J wrote: Is there some way to do something similar to this right now? void main() { // Differing levels of type-inference: int[] r1 = [1,2,3]; // No type-inference. That works just fine

Re: Differing levels of type-inference: Can D do this?

2012-07-28 Thread Chad J
On 07/28/2012 04:55 PM, Jonathan M Davis wrote: On Saturday, July 28, 2012 16:47:01 Chad J wrote: "range kind" is informal language. Maybe I mean "template instances", but that would somewhat miss the point. I don't know how to do this right now. AFAIK, it'

Re: Differing levels of type-inference: Can D do this?

2012-07-28 Thread Chad J
On 07/28/2012 05:55 PM, Jonathan M Davis wrote: On Saturday, July 28, 2012 17:48:21 Chad J wrote: I suppose that works, but it isn't very consistent with how type safety is normally done. Also it's extremely verbose. I'd need a lot of convincing to chose a language that makes

Re: Differing levels of type-inference: Can D do this?

2012-07-29 Thread Chad J
On 07/29/2012 08:32 AM, Simen Kjaeraas wrote: On Sat, 28 Jul 2012 22:47:01 +0200, Chad J wrote: isInputRange!___ r2 = [1,2,3].some.complex.expression(); It doesn't make sense. isInputRange!() isn't a type, so how do I constrain what type is returned from some arbitrary expressio

Re: Differing levels of type-inference: Can D do this?

2012-07-29 Thread Chad J
On 07/29/2012 11:54 AM, Ali Çehreli wrote: On 07/28/2012 01:47 PM, Chad J wrote: > What I want to do is constrain that the type of r3 is some kind of > range. I don't care what kind of range, it could be a range of integers, > a range of floats, an input range, a forward range

How do I set file attributes?

2012-07-29 Thread Chad J
std.file seems to have a getAttributes function, but I see no corresponding setAttributes function. What do I do if I want to copy the attributes from one file to another?

Re: How do I set file attributes?

2012-07-29 Thread Chad J
On 07/29/2012 04:55 PM, Jonathan M Davis wrote: On Sunday, July 29, 2012 16:47:50 Chad J wrote: std.file seems to have a getAttributes function, but I see no corresponding setAttributes function. What do I do if I want to copy the attributes from one file to another? std.file does not

Template mixins: Why is the decision to mixin made at the call site?

2009-08-20 Thread Chad J
Regarding template mixins, I'm curious, why is the decision to mixin a template made at the call site and not at the declaration of the template/mixin? In other words, why do we write template foo() { // etc.. } mixin foo!(); instead of m

Re: Template mixins: Why is the decision to mixin made at the call site?

2009-08-23 Thread Chad J
Bill Baxter wrote: > On Fri, Aug 21, 2009 at 10:36 AM, div0 wrote: >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> Not sure what the original choice was based on, but what you suggest >> looks wrong to me. You aren't necessarily using a template in order to >> mix it in somewhere. >> >> W

Re: What time is it?

2009-08-23 Thread Chad J
Max wrote: > Is there any way in Phobos to measure the current time with microsecond > accuracy? > > Max Might I suggest std.perf? I found it here some years ago: http://www.digitalmars.com/techtips/timing_code.html It even seems to have survived the transition from D1 to D2. Oddly enough, th

Re: DMD - Druntime - Phobos questions.

2009-11-29 Thread Chad J
Travis Boucher wrote: > ... > > --- > phobos - The standard library (at least one of them) > http://svn.dsource.org/projects/phobos/ > > ... > > It should even be possible to use both tango and phobos in the same > application (correct me if I am wrong here please). > In D2 you

How do I find the arity of an Expression? (dmd hacking)

2009-11-29 Thread Chad J
Given an Expression object in dmd, I'd like to know how many subexpressions it contains and, even better, iterate over them. I'd like to do this in a general way, without having to create cases for all of the different kinds of Expressions. Is there some way to do this that I've been missing? Th

Re: How do I find the arity of an Expression? (dmd hacking)

2009-11-30 Thread Chad J
Ellery Newcomer wrote: > On 11/30/2009 03:53 AM, Ary Borenszweig wrote: >> Chad J wrote: >>> Given an Expression object in dmd, I'd like to know how many >>> subexpressions it contains and, even better, iterate over them. I'd >>> like to do this in a g

Re: How do I find the arity of an Expression? (dmd hacking)

2009-11-30 Thread Chad J
I think I'll reply to both of you in one post since the thoughts are related. Ary Borenszweig wrote: > Ellery Newcomer wrote: >> >> Not that I know anything about DMD outside parse.c, but in >> expression.h, there be decls along the lines of >> >> struct UnaExp{ >> Expression* e1; >> } >> struct

Re: How do I find the arity of an Expression? (dmd hacking)

2009-12-01 Thread Chad J
Ellery Newcomer wrote: > On 11/30/2009 07:59 PM, Chad J wrote: >> >> This is about the property expression rewrite of course. I'd love to >> just use the current convention in dmd and write the rewrite as a >> non-recursive function that gets called at every point