Re: opAssign and references

2012-01-31 Thread Simen Kjærås
On Wed, 01 Feb 2012 01:14:38 +0100, Nicolas Silva wrote: Oh, my bad, sorry, when I tried the code i showed in the other mail, I had forgotten the parenthesis on the call to refA() (like if it was an attribute). Once fixed it works for me. f1.refA() = 24; //ok f1.refA = 24; //not ok, my mist

Re: opAssign and references

2012-01-31 Thread Nicolas Silva
Oh, my bad, sorry, when I tried the code i showed in the other mail, I had forgotten the parenthesis on the call to refA() (like if it was an attribute). Once fixed it works for me. f1.refA() = 24; //ok f1.refA = 24; //not ok, my mistake On Tue, Jan 31, 2012 at 11:43 PM, Trass3r wrote: >> I am

Re: opAssign and references

2012-01-31 Thread Trass3r
I am using DMD 2.057 on Ubuntu 64bit. Are you sure that it does not work? Can anyone reproduce the error? import std.variant; struct Foo { Variant a; ref Variant refA(){ return a; } } void main(){ Foo f1; f1.refA() = 24; } Compiles fine on Ubuntu x64 with git

Re: Class Initialization

2012-01-31 Thread Trass3r
*whispers gee dee c* windows binaries please... Seek and you shall find. https://bitbucket.org/goshawk/gdc/downloads

Re: opAssign and references

2012-01-31 Thread Timon Gehr
On 01/31/2012 06:15 PM, Nicolas Silva wrote: Hi, Works for me. Which version of the compiler are you using? Sorry, i forgot to mention: i'm using dmd 2.057 on ubuntu 32bit. I am using DMD 2.057 on Ubuntu 64bit. Are you sure that it does not work? Can anyone reproduce the error? import s

Re: Class Initialization

2012-01-31 Thread bls
On 01/31/2012 12:41 PM, Trass3r wrote: *whispers gee dee c* windows binaries please...

Formatted input specifiers not implemented

2012-01-31 Thread Ali Çehreli
What is the state of formatted input? There has been changes at some point. %x or %o don't work anymore: int i; int j; readf(" %o %x", &i, &j); phobos/std/format.d(2690): Parsing spec 'o' not implemented. Same error for '%x'. (Of course '%s' works but doesn't know octal or hexadec

Re: Class Initialization

2012-01-31 Thread Trass3r
I was reading the C++ Object Model book recently (well, I'm still reading) and was amazed at how many edge-cases there are in C++, and how lucky I am to be using D. Well, minus the Optlink that is. :) *whispers gee dee c*

Re: Class Initialization

2012-01-31 Thread H. S. Teoh
On Tue, Jan 31, 2012 at 08:49:25PM +0100, Andrej Mitrovic wrote: > On 1/31/12, Jonathan M Davis wrote: > > In D however, the _entire_ type is created and default > > initialized before the first constructor is called. > > I was reading the C++ Object Model book recently (well, I'm still > reading

Re: Class Initialization

2012-01-31 Thread Andrej Mitrovic
On 1/31/12, Jonathan M Davis wrote: > In D however, the _entire_ type is created and default > initialized before the first constructor is called. I was reading the C++ Object Model book recently (well, I'm still reading) and was amazed at how many edge-cases there are in C++, and how lucky I am

Re: Class Initialization

2012-01-31 Thread Jonathan M Davis
On Tuesday, January 31, 2012 12:07:16 Zachary Lund wrote: > In C++, they provide a mechanism to initialize class variables to a > passed value. > > class Test > { > int bob; > > public: > Test(int jessica) : bob(jessica) { } > }; > > The above basically says "int this.bob = jessica;" as opposed

Re: A tutorial on D templates

2012-01-31 Thread Philippe Sigaud
On Tue, Jan 31, 2012 at 09:12, Ali Çehreli wrote: > On 01/14/2012 07:49 AM, Philippe Sigaud wrote: > >> That's cool, because the D community is small enough and still >> dispersed enough that we should link one another to bring it all >> together. > > Thank you very much for your link! :) That's

Re: About to!int

2012-01-31 Thread Jonathan M Davis
On Tuesday, January 31, 2012 08:05:37 bearophile wrote: > Jonathan M Davis: > > I don't see std.conv.to changing. > > We'll see. As far as I recall, you're the only person to ever bring this up (though you have brought it up before). In general, I think that programmers are fine with how to!int

Class Initialization

2012-01-31 Thread Zachary Lund
In C++, they provide a mechanism to initialize class variables to a passed value. class Test { int bob; public: Test(int jessica) : bob(jessica) { } }; The above basically says "int this.bob = jessica;" as opposed to this: class Test { int bob; public: Test(int

Re: regex: force entire string to match

2012-01-31 Thread bearophile
NewName: > Hello all. > I want to write a regex to check if a whole string is a number. Also: import std.stdio, std.string, std.array; void main() { string s = "123"; assert(s.removechars("0-9").empty); } Bye, bearophile

Re: Partial classes

2012-01-31 Thread Mars
On Tuesday, 31 January 2012 at 12:33:22 UTC, bearophile wrote: Mars: Thanks everybody. I still hope support for partial classes may come some day, to make this cleaner, but I guess it works. Generally it's not wise to go too much against the style of a language. What do you need partial clas

Re: opAssign and references

2012-01-31 Thread Nicolas Silva
Hi, > Works for me. Which version of the compiler are you using? Sorry, i forgot to mention: i'm using dmd 2.057 on ubuntu 32bit. On Tue, Jan 31, 2012 at 5:31 PM, Timon Gehr wrote: > On 01/31/2012 03:03 PM, Nicolas Silva wrote: >> >> Hi, >> >> I'm playing with variants and I noticed that opAss

Re: regex: force entire string to match

2012-01-31 Thread NewName
> You want to match the beginning and end of the input as well: > "^[0-9]+$" Thanks.

Re: regex: force entire string to match

2012-01-31 Thread Justin Whear
On Tue, 31 Jan 2012 16:29:43 +, NewName wrote: > Hello all. > I want to write a regex to check if a whole string is a number. With my > current regex("[0-9]+") numbers will be carved out of things like > "aaa456" (hit: 456) and I circumvent this by checking the lengths for > inequality, which

Re: regex: force entire string to match

2012-01-31 Thread Trass3r
I want to write a regex to check if a whole string is a number. With my current regex("[0-9]+") numbers will be carved out of things like "aaa456" (hit: 456) and I circumvent this by checking the lengths for inequality, which is stupid. My regex is surely missing something? Try ^ and $ if applic

std.parallelism: TaskPool adjustment

2012-01-31 Thread Zachary Lund
I'm wanting to change the number of worker threads post creation of my TaskPool instance. I see nothing that allows me to do this. Isn't that abnormal for a thread pool?

Re: opAssign and references

2012-01-31 Thread Timon Gehr
On 01/31/2012 03:03 PM, Nicolas Silva wrote: Hi, I'm playing with variants and I noticed that opAssign is not invoked when an assignation is done on a reference. here is the test case: import std.variant; struct Foo { Variant a; Variant b; ref Variant refA() { ret

regex: force entire string to match

2012-01-31 Thread NewName
Hello all. I want to write a regex to check if a whole string is a number. With my current regex("[0-9]+") numbers will be carved out of things like "aaa456" (hit: 456) and I circumvent this by checking the lengths for inequality, which is stupid. My regex is surely missing something? Thank you fo

Re: Scoped Class Instance

2012-01-31 Thread Simen Kjærås
On Tue, 31 Jan 2012 16:42:52 +0100, Zachary Lund wrote: On Tuesday, 31 January 2012 at 15:19:00 UTC, Trass3r wrote: However, I cannot, by default, scope my custom allocations. Any ideas? std.typecons.scoped I looked into this and I'm unsure of its exact use. It says, "Allocates a class

Re: Scoped Class Instance

2012-01-31 Thread Zachary Lund
On Tuesday, 31 January 2012 at 15:19:00 UTC, Trass3r wrote: However, I cannot, by default, scope my custom allocations. Any ideas? std.typecons.scoped I looked into this and I'm unsure of its exact use. It says, "Allocates a class object right inside the current scope" which doesn't really

Re: Scoped Class Instance

2012-01-31 Thread Trass3r
However, I cannot, by default, scope my custom allocations. Any ideas? std.typecons.scoped

Re: RPC module for D ?

2012-01-31 Thread luis
El Tue, 31 Jan 2012 00:33:36 +0100, David Nadlinger escribió: > On 1/31/12 12:29 AM, Zardoz wrote: >> At least I can say that the Tutorial client& server works >> (async_client not compile) :) . For me it's enough . > > Because you don't have libevent installed (the tutorial makefile doesn't > h

Re: Clutter GObject bindings

2012-01-31 Thread Artur Skawina
On 01/30/12 00:30, Artur Skawina wrote: > On 01/29/12 23:51, Sparse Push wrote: >> >>> Done. Does the resulting clutter API look usable? >>> http://repo.or.cz/w/girtod.git/blob/refs/heads/gtk2:/gtk2/clutter.d >>> None of the new modules were tested - i still need code samples to port and >>> time

Re: Scoped Class Instance

2012-01-31 Thread Nicolas Silva
You can use structs for this kind of problems, somethin like struct Scoped(T) { ~this() { //handle deallocation here } T inst; } if you create a Scoped!MyClass in a scope, the struct's destructor will be invoked whenever the program leaves the scope, even if it is because

opAssign and references

2012-01-31 Thread Nicolas Silva
Hi, I'm playing with variants and I noticed that opAssign is not invoked when an assignation is done on a reference. here is the test case: import std.variant; struct Foo { Variant a; Variant b; ref Variant refA() { return a; } } void main() { Foo f1; f1.a =

Scoped Class Instance

2012-01-31 Thread Zachary Lund
I've been looking into (basic) memory management within D. Through IRC conversation and reading the article on memory management on dlang.org (which seems to be a bit out-of-date), I've concluded that using a global (or static member) function and emplace() in std.conv is a simple solution for

Re: About to!int

2012-01-31 Thread bearophile
Jonathan M Davis: > and it's the sort of thing that > he's likely to consider bikeshedding at this point - He isn't the only Phobos developer. It's a change able to improve my usage of conversions, so it's not a neutral change (as I think 'bikeshedding' implies). > particularly since he's >

Re: About to!int

2012-01-31 Thread bearophile
Zardoz: > Try parse!int(" 12\n"); > http://www.d-programming-language.org/phobos/std_conv.html#parse It doesn't work, because it accepts a ref string. So you have to write: string s = " 12\n"; int n = parse!int(s); But it doesn't work still, it chokes on the first space, so you have to remove i

Re: Partial classes

2012-01-31 Thread bearophile
Mars: > Thanks everybody. I still hope support for partial classes may > come some day, to make this cleaner, but I guess it works. Generally it's not wise to go too much against the style of a language. What do you need partial classes for? Bye, bearophile

Re: Structs and Classes

2012-01-31 Thread Mike Parker
On 1/31/2012 7:45 PM, Mars wrote: Hello everybody. I couldn't really think of a good title for this. It's just a little question, about this example code: http://pastie.org/private/4xqtze47dlx9fy9pn53sq Apperantly I get a copy of Bar, when I call bar(), and it doesn't modify the actual variable

Re: Partial classes

2012-01-31 Thread Jonathan M Davis
On Tuesday, January 31, 2012 11:37:24 Mars wrote: > On Monday, 30 January 2012 at 10:21:07 UTC, bls wrote: > > As already said template mixins are close to partial classes. > > A snippet. HTH > > Thanks everybody. I still hope support for partial classes may > come some day, to make this cleaner,

Structs and Classes

2012-01-31 Thread Mars
Hello everybody. I couldn't really think of a good title for this. It's just a little question, about this example code: http://pastie.org/private/4xqtze47dlx9fy9pn53sq Apperantly I get a copy of Bar, when I call bar(), and it doesn't modify the actual variable of the object. But if I define B

Re: Partial classes

2012-01-31 Thread Mars
On Monday, 30 January 2012 at 10:21:07 UTC, bls wrote: As already said template mixins are close to partial classes. A snippet. HTH Thanks everybody. I still hope support for partial classes may come some day, to make this cleaner, but I guess it works.

Re: About to!int

2012-01-31 Thread Jonathan M Davis
On Monday, January 30, 2012 21:01:38 bearophile wrote: > In Python int() and float() convert a string into a number even if it contains some whitespace before and after the number: > >>> s = " 12\n" > >>> int(s) > > 12 > > >>> float(s) > > 12.0 > > > In D to!int(" 12\n") gives a run-time er

Re: A tutorial on D templates

2012-01-31 Thread Ali Çehreli
On 01/14/2012 07:49 AM, Philippe Sigaud wrote: > That's cool, because the D community is small enough and still > dispersed enough that we should link one another to bring it all > together. Thank you very much for your link! :) And I've finally found time to create two links to your 'D Templat