Re: ctfe bug?

2011-12-22 Thread Johannes Pfau
Johannes Pfau wrote: Has this bug already been filed? I could possibly circumvent it by making ragel use array indexing instead of pointers, but that'd be a performance issue for runtime code as well. OK, I found a workaround: If I use data[x] =

Re: ctfe bug?

2011-12-22 Thread Jacob Carlborg
On 2011-12-22 08:47, Johannes Pfau wrote: Hi, the following code is reduced from a parser generated with Ragel (http://www.complang.org/ragel/). That's also the reason why it's using pointers instead of array access, but Ragel guarantees that there won't be any out-of-bound reads. AFAIK

Re: test if object is instance of class at compile time

2011-12-22 Thread Elvis Maehren
Vladimir Panteleev wrote: I believe that's what __traits(compiles, ...) is for: __traits(compiles, cast(T) o) is true even if the cast blows up in CTFE, so that doesn't work.

Re: ctfe bug?

2011-12-22 Thread Johannes Pfau
Jacob Carlborg wrote: On 2011-12-22 08:47, Johannes Pfau wrote: Hi, the following code is reduced from a parser generated with Ragel (http://www.complang.org/ragel/). That's also the reason why it's using pointers instead of array access, but Ragel guarantees that there won't be any

onStartTag for root node in std.xml

2011-12-22 Thread Heromyth
In the test code, the onStartTag will not be called for the root node set. The onEndTag is OK, and the onStartTag is OK for sub nodes. Is this a bug, or just it is? Can anybody confirm it? Thanks. // test.d module main; import std.string; import std.stdio; import std.xml; int main(string[]

Re: test if object is instance of class at compile time

2011-12-22 Thread Timon Gehr
On 12/21/2011 09:15 PM, Elvis Maehren wrote: This works fine at runtime, but explodes in CTFE: --- bool isInstanceOf(T, O)(O o) { return (cast(T) o) !is null; } --- CTFE doesn't like !is null (cannot compare [...] at compile time). This will be fixed in the next release:

Re: ctfe bug?

2011-12-22 Thread Timon Gehr
On 12/22/2011 10:28 AM, Jacob Carlborg wrote: On 2011-12-22 08:47, Johannes Pfau wrote: Hi, the following code is reduced from a parser generated with Ragel (http://www.complang.org/ragel/). That's also the reason why it's using pointers instead of array access, but Ragel guarantees that there

Re: ctfe bug?

2011-12-22 Thread Jacob Carlborg
On 2011-12-22 14:39, Timon Gehr wrote: On 12/22/2011 10:28 AM, Jacob Carlborg wrote: On 2011-12-22 08:47, Johannes Pfau wrote: Hi, the following code is reduced from a parser generated with Ragel (http://www.complang.org/ragel/). That's also the reason why it's using pointers instead of array

Re: newbie question: Can D do this?

2011-12-22 Thread clk
Philippe, Thank you very much for your response. It looks similar to what I've done in javascript by wrapping all function arguments into a single object literal but the D alternative you propose is a little to convoluted for a beginner like me. Perhaps I'll understand it better after I'm

Re: newbie question: can D do this?

2011-12-22 Thread clk
Philippe, I don't understand the example below to simulate the list comprehension syntax. Are input1, input2 and input3 ranges? Where is the comp function defined? Thank you, -clk (Christian Keppenne) auto lc = comp!(tuple(a,b,c), a*a+b*b == c*c ab)(input1,input2, input3);

Re: newbie question: Can D do this?

2011-12-22 Thread Philippe Sigaud
On Thu, Dec 22, 2011 at 16:37, clk c...@clksoft.com wrote: Philippe, Thank you very much for your response.  It looks similar to what I've done in javascript by wrapping all function arguments into a single object literal but the D alternative you propose is a little to convoluted for a

Re: test if object is instance of class at compile time

2011-12-22 Thread Trass3r
I'd really like to have 'if (instance is ClassType)' syntax in D.

Re: newbie question: can D do this?

2011-12-22 Thread Philippe Sigaud
On Thu, Dec 22, 2011 at 16:45, clk c...@clksoft.com wrote: Philippe, I don't understand the example below to simulate the list comprehension syntax.  Are input1, input2 and input3 ranges? Yes, inputs are ranges. Sorry, I was perhaps a bit hasty in answering. The code is on github:

Re: test if object is instance of class at compile time

2011-12-22 Thread Andrew Wiley
On Thu, Dec 22, 2011 at 8:35 AM, Trass3r u...@known.com wrote: I'd really like to have 'if (instance is ClassType)' syntax in D. It couldn't use that syntax because 'is' means direct bitwise equality everywhere else. Changing it in this one situation would be awkward.

Re: ctfe bug?

2011-12-22 Thread Johannes Pfau
Jacob Carlborg wrote: On 2011-12-22 14:39, Timon Gehr wrote: On 12/22/2011 10:28 AM, Jacob Carlborg wrote: On 2011-12-22 08:47, Johannes Pfau wrote: Hi, the following code is reduced from a parser generated with Ragel (http://www.complang.org/ragel/). That's also the reason why it's using

Catching signals with D

2011-12-22 Thread Matej Nanut
Hello everyone, I've been fascinated by D lately and have been using it for all my school assignments (like simple ray casting and simulated annealing). What I can't find anywhere is how to do something like signal(SIGINT, myhandler) (I'm in a Linux environment). I need this to stop the

Re: Catching signals with D

2011-12-22 Thread Heywood Floyd
On 12/22/11 23:51 , Matej Nanut wrote: Hello everyone, I've been fascinated by D lately and have been using it for all my school assignments (like simple ray casting and simulated annealing). What I can't find anywhere is how to do something like signal(SIGINT, myhandler) (I'm in a Linux