Re: Constructor template -- bug?

2011-03-01 Thread Jacob Carlborg
On 2011-03-02 08:47, Jonathan M Davis wrote: On Tuesday 01 March 2011 23:43:27 Jonathan M Davis wrote: On Tuesday 01 March 2011 22:18:49 Bekenn wrote: Code: class MyException : Exception { this(string message, string file, size_t line, Throwable next =

Re: Constructor template -- bug?

2011-03-01 Thread Jonathan M Davis
On Tuesday 01 March 2011 23:43:27 Jonathan M Davis wrote: > On Tuesday 01 March 2011 22:18:49 Bekenn wrote: > > Code: > > class MyException : Exception > > { > > > > this(string message, string file, size_t line, Throwable next = > > null) > > { > >

Re: Constructor template -- bug?

2011-03-01 Thread Jonathan M Davis
On Tuesday 01 March 2011 22:18:49 Bekenn wrote: > Code: > > class MyException : Exception > { > this(string message, string file, size_t line, Throwable next = > null) > { > super(message, file, line, next); > } > >

Constructor template -- bug?

2011-03-01 Thread Bekenn
Code: class MyException : Exception { this(string message, string file, size_t line, Throwable next = null) { super(message, file, line, next); } this(string file = __FILE__, size_t line = __LINE__)(string

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread Bekenn
On 3/1/2011 4:12 PM, bearophile wrote: Bekenn: I'd remove those parens; you don't want people modifying TRUE or FALSE. Please, show me working code that implements your idea :-) Bye, bearophile Here you go; I only changed the one line. Compiles and works just fine in dmd 2.051.

Re: About const and C functions

2011-03-01 Thread Bekenn
On 3/1/2011 2:33 PM, bearophile wrote: Do you know why DMD doesn't give a compilation error here? import core.stdc.stdio: sscanf; immutable int value = 5; void main() { sscanf("10".ptr, "%d".ptr,&value); } Bye, bearophile I'm not sure that's checkable. I think this falls squarely into

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread Bekenn
On 3/1/11 5:31 PM, bearophile wrote: Bekenn: Touche. I'll have to test that out once I get back from work... Sorry for that answer of mine, we are here to learn and cooperate, not to fight :-) It's just I sometimes have problems with const things in D, and sometimes DMD has problems with c

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread bearophile
Bekenn: > Touche. I'll have to test that out once I get back from work... Sorry for that answer of mine, we are here to learn and cooperate, not to fight :-) It's just I sometimes have problems with const things in D, and sometimes DMD has problems with const things. Bye, bearophile

Can't figure out segfault

2011-03-01 Thread rm
I put together bindings for DevIL in D to use on a school assignment. The bindings (attached) work fine on Windows, but cause a segfault on Linux when I call ilInit. this can be demonstrated by a little test program " import graphics.bindings.devil; public void main(string[] args) { ilInit()

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread Bekenn
On 3/1/11 4:12 PM, bearophile wrote: Bekenn: I'd remove those parens; you don't want people modifying TRUE or FALSE. Please, show me working code that implements your idea :-) Touche. I'll have to test that out once I get back from work...

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread bearophile
Bekenn: > I'd remove those parens; you don't want people modifying TRUE or FALSE. Please, show me working code that implements your idea :-) Bye, bearophile

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread Bekenn
On 3/1/11 3:00 PM, bearophile wrote: const(Foo)* TRUE, FALSE; I'd remove those parens; you don't want people modifying TRUE or FALSE.

Re: Win7 64-bit

2011-03-01 Thread Dan McLeran
never mind, i got it. i had to pass the switches: -D -unittest -cov life is hard. it's even harder when you're dumb.

Win7 64-bit

2011-03-01 Thread Dan McLeran
I am running the dmd2 compiler on my Win7 64 bit machine and everything appears to work except the -cov switch. i cannot seem to generate a .lst file. any ideas? thanks dan mcleran

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread bearophile
http://d.puremagic.com/issues/show_bug.cgi?id=5678

Re: Doubt about Synchronized Code Clocks

2011-03-01 Thread Spacen Jasset
On 01/03/2011 22:52, Spacen Jasset wrote: On 01/03/2011 16:59, d coder wrote: > I'm afraid that I have no idea what would be "stale" about a shared variable. > sychronized uses a mutex, and if you want to avoid race conditions, you need to > use mutexes or something similar when dealing with sh

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread bearophile
This seems to work: import core.stdc.stdio: printf; struct Foo { bool b; this(bool b_) { this.b = b_; } } const(Foo)* TRUE, FALSE; static this() { TRUE = new const(Foo)(true); FALSE = new const(Foo)(false); } const(Foo)* not(const(Foo)* op) { return (op == TRUE) ? FALSE : TRUE;

Re: Doubt about Synchronized Code Clocks

2011-03-01 Thread Spacen Jasset
On 01/03/2011 16:59, d coder wrote: > I'm afraid that I have no idea what would be "stale" about a shared variable. > sychronized uses a mutex, and if you want to avoid race conditions, you need to > use mutexes or something similar when dealing with shared variables. But I don't > know what

Re: comparing pointers passed to and returned from funcs

2011-03-01 Thread bearophile
spir: > It seems to be the kind of stupid issue that will make you laugh about me. > But > I cannot grasp and want to move forward anyway; so, let us be bold and take > the > risk ;-) Be bold. Understanding things is much more important. I've being wrong hundreds of times on D newsgroups, bu

About const and C functions

2011-03-01 Thread bearophile
Do you know why DMD doesn't give a compilation error here? import core.stdc.stdio: sscanf; immutable int value = 5; void main() { sscanf("10".ptr, "%d".ptr, &value); } Bye, bearophile

Re: Some weird crashes

2011-03-01 Thread simendsjo
On 28.02.2011 20:24, Denis Koroskin wrote: On Mon, 28 Feb 2011 22:04:44 +0300, simendsjo wrote: On 28.02.2011 18:52, simendsjo wrote: // ERROR auto res = mysql_library_init(0, null, null); auto cn = mysql_init(null); auto oldcn = cn; writeln(mysql_errno(cn)); assert(cn == oldcn); // when t

Re: Mixins: to!string cannot be interpreted at compile time

2011-03-01 Thread Peter Lundgren
That worked, thanks. This is interesting because the example used in "The D Programming Language" on page 83 gets away with it just fine. I had no problem running this: result ~= to!string(bitsSet(b)) ~ ", ";

Re: Template argument deduction

2011-03-01 Thread Ali Çehreli
On 02/28/2011 07:39 PM, Tom wrote: > foo([[1,2],[3,4],[5,6]]); // ERROR [1] > bar([[1,2],[3,4],[5,6]]); // OK > foo!int([[1,2],[3,4],[5,6]]); // OK ... > void foo(T)(T[2][] t) { > writeln(typeid(t)); > } > > void bar(T)(T[][] t) { > writeln(typeid(t)); > } On 03/01/2011 04:30 AM, bearophile wr

comparing pointers passed to and returned from funcs

2011-03-01 Thread spir
Hello, It seems to be the kind of stupid issue that will make you laugh about me. But I cannot grasp and want to move forward anyway; so, let us be bold and take the risk ;-) I'm modeling a little dynamic language. Elements (values, objects) are pointers to structs (actually tagged unions) a

Re: Doubt about Synchronized Code Clocks

2011-03-01 Thread d coder
> I'm afraid that I have no idea what would be "stale" about a shared variable. > sychronized uses a mutex, and if you want to avoid race conditions, you need to > use mutexes or something similar when dealing with shared variables. But I don't > know what would be "stale" about a variable. > One

Re: Doubt about Synchronized Code Clocks

2011-03-01 Thread Jonathan M Davis
On Tuesday 01 March 2011 06:40:31 d coder wrote: > Greetings > > I have a doubt about synchronized code blocks. > > I learnt that in Java the synchronized keyword has two fold effect. > Firstly it locks the code to make sure that only a single thread gets > access to the code block at a given tim

Re: Problem with std.regex: *+? not allowed in atom

2011-03-01 Thread Jacob Carlborg
On 2011-03-01 16:54, Dmitry Olshansky wrote: On 27.02.2011 13:41, Jacob Carlborg wrote: On 2011-02-26 19:49, Dmitry Olshansky wrote: On 26.02.2011 19:52, Jacob Carlborg wrote: On 2011-02-26 12:29, Dmitry Olshansky wrote: On 26.02.2011 14:10, Jacob Carlborg wrote: I'm trying to use the std.re

Re: Is std.regex.match completely broken?

2011-03-01 Thread Jacob Carlborg
On 2011-03-01 14:03, Dmitry Olshansky wrote: On 28.02.2011 22:37, Jacob Carlborg wrote: The following code will result in an AssertError or RangeError when run. import std.regex; import std.stdio; void main () { auto m = "abc".match(`a(\w)b`); writeln(m.hit); // AssertError in regex.d:1795 wr

Re: Problem with std.regex: *+? not allowed in atom

2011-03-01 Thread Dmitry Olshansky
On 27.02.2011 13:41, Jacob Carlborg wrote: On 2011-02-26 19:49, Dmitry Olshansky wrote: On 26.02.2011 19:52, Jacob Carlborg wrote: On 2011-02-26 12:29, Dmitry Olshansky wrote: On 26.02.2011 14:10, Jacob Carlborg wrote: I'm trying to use the std.regex module but when I run my application I ge

Doubt about Synchronized Code Clocks

2011-03-01 Thread d coder
Greetings I have a doubt about synchronized code blocks. I learnt that in Java the synchronized keyword has two fold effect. Firstly it locks the code to make sure that only a single thread gets access to the code block at a given time. Secondly, it makes sure that the data elements accessed insi

Re: Is std.regex.match completely broken?

2011-03-01 Thread Dmitry Olshansky
On 28.02.2011 22:37, Jacob Carlborg wrote: The following code will result in an AssertError or RangeError when run. import std.regex; import std.stdio; void main () { auto m = "abc".match(`a(\w)b`); writeln(m.hit); // AssertError in regex.d:1795 writeln(m.captures); // RangeError i

Re: Mixins: to!string cannot be interpreted at compile time

2011-03-01 Thread bearophile
http://d.puremagic.com/issues/show_bug.cgi?id=5671

Re: Mixins: to!string cannot be interpreted at compile time

2011-03-01 Thread bearophile
David Nadlinger: > Maybe I missed something as well, but to me it seems to be a CTFE bug, > because if you split the offending line into two parts, it > > result ~= to!string(i); > result ~= ", "; > > Please consider filing this to Bugzilla. Wow. I was wrong, and you are right. It's not a prob

Re: Mixins: to!string cannot be interpreted at compile time

2011-03-01 Thread bearophile
Peter Lundgren: > I'm trying to use mixins to generate an array of numbers that are coprime to a > statically known value. I've tried the following, but I receive the error: > > Error: to(i) ~ ", " cannot be interpreted at compile time Currently to!() can't run at compile-time. Are you sure you

Re: Mixins: to!string cannot be interpreted at compile time

2011-03-01 Thread David Nadlinger
On 3/1/11 11:45 AM, spir wrote: makePossibleAValues() obviously returns a runtime value, so mixin() cannot evaluate it, I guess. Nope, that's not the problem due to CTFE (compile time function execution). David

Re: Mixins: to!string cannot be interpreted at compile time

2011-03-01 Thread David Nadlinger
On 3/1/11 7:58 AM, Peter Lundgren wrote: I'm trying to use mixins to generate an array of numbers that are coprime to a statically known value. I've tried the following, but I receive the error: Error: to(i) ~ ", " cannot be interpreted at compile time […] Maybe I missed something as well, but

Re: Template argument deduction

2011-03-01 Thread bearophile
Ali Çehreli: > That's because the type of literals like [1, 2] are slices (dynamic > arrays), not fixed-sized arrays. Then why is this accepted? foo!int([[1,2],[3,4],[5,6]]); // OK Bye, bearophile

Re: @property ref foo() { ...} won't work...?

2011-03-01 Thread Steven Schveighoffer
On Tue, 01 Mar 2011 07:19:21 -0500, Lars T. Kyllingstad wrote: On Tue, 01 Mar 2011 12:25:30 +0100, Magnus Lie Hetland wrote: 2. How can I make r.front = foo work, when I only have r.front(), returning a ref (which seems like it is used in actual code)? I think this is a bug, but I'm not e

Re: @property ref foo() { ...} won't work...?

2011-03-01 Thread Lars T. Kyllingstad
On Tue, 01 Mar 2011 12:25:30 +0100, Magnus Lie Hetland wrote: > In Andrei's book, as well as in the Phobos source, there are property > getters that return refs, as in... > > @property ref T front() { > return _payload[0]; > } > > ... and code that uses this with simple assignments, su

Re: string vs. w/char*

2011-03-01 Thread Tyro[a.c.edwards]
On 3/1/2011 7:18 PM, Bekenn wrote: On 3/1/2011 12:25 AM, Tyro[a.c.edwards] wrote: Nevertheless, execution haults at the very next line following/catch and Create() never returns. CreateWindow sends a few messages to your window proc; anything interesting happening there? Not sure how to chec

@property ref foo() { ...} won't work...?

2011-03-01 Thread Magnus Lie Hetland
In Andrei's book, as well as in the Phobos source, there are property getters that return refs, as in... @property ref T front() { return _payload[0]; } ... and code that uses this with simple assignments, such as: r.front = foo; For some reason, I can't get this to work in my code :-

Re: Mixins: to!string cannot be interpreted at compile time

2011-03-01 Thread spir
On 03/01/2011 07:58 AM, Peter Lundgren wrote: I'm trying to use mixins to generate an array of numbers that are coprime to a statically known value. I've tried the following, but I receive the error: Error: to(i) ~ ", " cannot be interpreted at compile time string makePossibleAValues(string na

Re: string vs. w/char*

2011-03-01 Thread Bekenn
On 3/1/2011 12:25 AM, Tyro[a.c.edwards] wrote: Nevertheless, execution haults at the very next line following/catch and Create() never returns. CreateWindow sends a few messages to your window proc; anything interesting happening there?

Re: string vs. w/char*

2011-03-01 Thread Tyro[a.c.edwards]
== Quote from Denis Koroskin (2kor...@gmail.com)'s article > On Tue, 01 Mar 2011 02:08:48 +0300, Tyro[a.c.edwards] > wrote: > > == Quote from Denis Koroskin (2kor...@gmail.com)'s article > >> On Mon, 28 Feb 2011 19:35:47 +0300, Tyro[a.c.edwards] > > > >> wrote: > >> > On 2/28/2011 11:08 PM, J Cha