CTFE of yl2x() and other intrinsics

2010-11-15 Thread Lars T. Kyllingstad
I thought that the compiler could evaluate all intrinsics at compile time, but this doesn't seem to be the case for std.math.yl2x(). Is my assumption wrong, or is this a bug that should be reported? -Lars

Re: CTFE of yl2x() and other intrinsics

2010-11-15 Thread div0
On 15/11/2010 11:00, Lars T. Kyllingstad wrote: I thought that the compiler could evaluate all intrinsics at compile time, but this doesn't seem to be the case for std.math.yl2x(). Is my assumption wrong, or is this a bug that should be reported? -Lars Looks like it's not implemented because

explore current scope, or other hack

2010-11-15 Thread spir
Hello, Is there a way to explore the current scope, meaning the set of currently defined symbols? (Equivalent of python's vars(), locals(), globals().) I have 2 use cases for this: 1. name objects automatically I need some objects to know their name (as field on themselves). the only solution

Re: CTFE of yl2x() and other intrinsics

2010-11-15 Thread div0
On 15/11/2010 12:12, div0 wrote: On 15/11/2010 11:00, Lars T. Kyllingstad wrote: I thought that the compiler could evaluate all intrinsics at compile time, but this doesn't seem to be the case for std.math.yl2x(). Is my assumption wrong, or is this a bug that should be reported? -Lars Looks l

Re: CTFE of yl2x() and other intrinsics

2010-11-15 Thread Lars T. Kyllingstad
On Mon, 15 Nov 2010 13:03:03 +, div0 wrote: > On 15/11/2010 12:12, div0 wrote: >> On 15/11/2010 11:00, Lars T. Kyllingstad wrote: >>> I thought that the compiler could evaluate all intrinsics at compile >>> time, but this doesn't seem to be the case for std.math.yl2x(). Is my >>> assumption wr

effect of a label on following block

2010-11-15 Thread Nick Voronin
Hello. Consider this code void main() { l: { int v; } v = 5; // ok, v is defined } As I understand from D's grammar this behaviour is not a bug as LabeledStatement: Identifier : NoScopeStatement and NoScopeStatement in turn takes BlockStatement without creating new scope. It

Re: segfault

2010-11-15 Thread Steven Schveighoffer
On Sat, 13 Nov 2010 15:57:50 -0500, spir wrote: On Fri, 12 Nov 2010 08:03:26 -0500 "Steven Schveighoffer" wrote: Essentially, if you change your line above to: this.patterns = patterns.dup; Works, but I don't understand why: isn't the duplicate also allocated on the stack? I mean, dup

Re: Is there a way to forward-declare interfaces to avoid module interdependencies?

2010-11-15 Thread Steven Schveighoffer
On Sun, 14 Nov 2010 05:28:29 -0500, Per Ångström wrote: On 2010-11-11 17:21, Steven Schveighoffer wrote: First, you can't forward-declare classes in one file that are defined in another file, instead of importing. The reason is because in D, the module is the namespace that the class is declar

Re: effect of a label on following block

2010-11-15 Thread Ellery Newcomer
My gut feeling is that the if statement's behavior is wrong and the while statement's is correct, but it could go either way. No need for a rationale for what can be adequately explained as a compiler bug (this is a downside of dmd - it trains you to think like this) It is curious, though, as

Re: effect of a label on following block

2010-11-15 Thread Ellery Newcomer
poking around a little more and I really don't know what's going on. fun piece of trivia though: while loops get rewritten to for loops, so for(;;) l1 { int v; } v = 4; exhibits the same behavior as the while loop. do loops seem to do the same thing as the if statement On 11/15/2010 10:34

Re: effect of a label on following block

2010-11-15 Thread bearophile
Ellery Newcomer: > No need for a rationale for what can be adequately explained as a > compiler bug (this is a downside of dmd - it trains you to think like > this) Or: Any sufficiently incomprehensible behaviour is indistinguishable from a DMD compiler bug :-) Bye, bearophile

Re: explore current scope, or other hack

2010-11-15 Thread bearophile
spir: > 1. name objects automatically > I need some objects to know their name (as field on themselves). the only > solution I can else imagine is for the user write: > x = ...; > x.name = "x"; What if you have two or more references to the same object? Regarding your generic questi

==, is

2010-11-15 Thread Ellery Newcomer
quick question: are the following rewrites always valid: e1 != e2 -> !(e1 == e2) e1 !is e2-> !(e1 is e2) e1 !in e2-> !(e1 in e2) ?

Re: ==, is

2010-11-15 Thread Steven Schveighoffer
On Mon, 15 Nov 2010 14:06:34 -0500, Ellery Newcomer wrote: quick question: are the following rewrites always valid: e1 != e2 -> !(e1 == e2) e1 !is e2-> !(e1 is e2) e1 !in e2-> !(e1 in e2) I believe this is in fact what the compiler does (rewriting). -Steve

Re: effect of a label on following block

2010-11-15 Thread div0
On 15/11/2010 16:45, Ellery Newcomer wrote: poking around a little more and I really don't know what's going on. fun piece of trivia though: while loops get rewritten to for loops, so for(;;) l1 { int v; } v = 4; exhibits the same behavior as the while loop. do loops seem to do the same thing

Re: ==, is

2010-11-15 Thread Ellery Newcomer
parser definitely does it for !in, but it doesn't for the other ones, and I didn't want to go digging all over the place for it. Also, spec says yes for !in, but is silent for the other ones On 11/15/2010 01:08 PM, Steven Schveighoffer wrote: On Mon, 15 Nov 2010 14:06:34 -0500, Ellery Newcomer

Re: ==, is

2010-11-15 Thread Steven Schveighoffer
On Mon, 15 Nov 2010 14:36:33 -0500, Ellery Newcomer wrote: parser definitely does it for !in, but it doesn't for the other ones, and I didn't want to go digging all over the place for it. Also, spec says yes for !in, but is silent for the other ones http://www.digitalmars.com/d/2.0/opera

Re: explore current scope, or other hack

2010-11-15 Thread spir
On Mon, 15 Nov 2010 12:44:24 -0500 bearophile wrote: > spir: > > > 1. name objects automatically > > I need some objects to know their name (as field on themselves). the only > > solution I can else imagine is for the user write: > > x = ...; > > x.name = "x"; > > What if you have two

Re: ==, is

2010-11-15 Thread Jonathan M Davis
On Monday 15 November 2010 11:47:11 Steven Schveighoffer wrote: > On Mon, 15 Nov 2010 14:36:33 -0500, Ellery Newcomer > > wrote: > > parser definitely does it for !in, but it doesn't for the other ones, > > and I didn't want to go digging all over the place for it. > > > > Also, spec says yes fo

Re: explore current scope, or other hack

2010-11-15 Thread Simen kjaeraas
spir wrote: On Mon, 15 Nov 2010 12:44:24 -0500 bearophile wrote: spir: > 1. name objects automatically > I need some objects to know their name (as field on themselves). the only solution I can else imagine is for the user write: >x = ...; >x.name = "x"; What if you have two or

Re: ==, is

2010-11-15 Thread Ellery Newcomer
a while ago, I assumed that e1 += e2 gets rewritten as e1 = e1 + e2 Yeah. It doesn't. It doesn't even behave the same wrt erroneously typed arguments On 11/15/2010 02:35 PM, Jonathan M Davis wrote: As far as is, it doesn't explicitly say that rewriting is done, but, it does spell out that

Re: ==, is

2010-11-15 Thread Jonathan M Davis
On Monday 15 November 2010 12:40:43 Ellery Newcomer wrote: > a while ago, I assumed that > > e1 += e2 > > gets rewritten as > > e1 = e1 + e2 > > Yeah. It doesn't. It doesn't even behave the same wrt erroneously typed > arguments Well, that would potentially be two different set of operator ove

Re: ==, is

2010-11-15 Thread Steven Schveighoffer
On Mon, 15 Nov 2010 15:40:43 -0500, Ellery Newcomer wrote: a while ago, I assumed that e1 += e2 gets rewritten as e1 = e1 + e2 Yeah. It doesn't. It doesn't even behave the same wrt erroneously typed arguments I understand the care taken, but the spec gives reasons to believe otherwi