Re: std.concurrency.thisTid.send() feat. immutable(struct with several arrays)

2013-02-26 Thread Jonathan M Davis
On Wednesday, February 27, 2013 13:19:22 Alexandr Druzhinin wrote: > This code doesn't compiles http://dpaste.dzfl.pl/706a0d12 > But if you comment one of arrays it will do. I take a look at varaint.d > but can't understand why two arrays cause this error. > How can I send immutable struct that con

Re: std.concurrency.thisTid.send() feat. immutable(struct with several arrays)

2013-02-26 Thread Alexandr Druzhinin
27.02.2013 13:19, Alexandr Druzhinin пишет: This code doesn't compiles http://dpaste.dzfl.pl/706a0d12 But if you comment one of arrays it will do. I take a look at varaint.d but can't understand why two arrays cause this error. How can I send immutable struct that contains two or more arrays with

std.concurrency.thisTid.send() feat. immutable(struct with several arrays)

2013-02-26 Thread Alexandr Druzhinin
This code doesn't compiles http://dpaste.dzfl.pl/706a0d12 But if you comment one of arrays it will do. I take a look at varaint.d but can't understand why two arrays cause this error. How can I send immutable struct that contains two or more arrays without any serializing?

Re: Can D still compile html files? Seems not.

2013-02-26 Thread Dan Olson
Maybe you want Knuth's Literate Programming. http://en.wikipedia.org/wiki/Literate_programming Long ago it was only for pascal and C (web and cweb), but now I see there is noweb that works with any programming language. -- Dan

Re: scope(exit) & stack => double free or corruption (fasttop) ... help?

2013-02-26 Thread Ben Davis
On 26/02/2013 06:21, Charles Hixson wrote: On 02/24/2013 05:39 PM, H. S. Teoh wrote: On Sun, Feb 24, 2013 at 03:14:01PM -0800, Charles Hixson wrote: Given a struct with: ~this() { close();} voidclose() { if(currentKey !is null)currentKey=null; if(cursor is nu

Re: __FUNCTION__?

2013-02-26 Thread Rob T
On Monday, 25 February 2013 at 16:32:50 UTC, js.mdnq wrote: We have __FILE__ and __LINE__. Is there a __FUNCTION__ that gives the current function name? This helps with errors. As was previously stated there's a pending pull request that properly implements __FUNCTION__ and more. If you can'

Re: using this instead of typeof(this)

2013-02-26 Thread bearophile
Ben Davis: I suspect it doesn't matter actually. As usual benchmarks are our friends :-) Bye, bearophile

Re: using this instead of typeof(this)

2013-02-26 Thread Ben Davis
On 26/02/2013 18:41, bearophile wrote: Kenji Hara: auto return is a little different with others. To infer return type, the method body is aggressively analyzed in compilation. So that usage of "auto" sounds like something to avoid if you want D compiler to compile quickly a lot of code. I

Re: using this instead of typeof(this)

2013-02-26 Thread Ivan Kazmenko
On Tuesday, 26 February 2013 at 18:46:09 UTC, Maxim Fomin wrote: On Tuesday, 26 February 2013 at 18:22:03 UTC, Kenji Hara wrote: It is definitely a bug. I cannot believe that such horrible bug is still there. If you have a time, could you please file it in bugzilla? I can't believe you are no

Re: using this instead of typeof(this)

2013-02-26 Thread Maxim Fomin
On Tuesday, 26 February 2013 at 18:22:03 UTC, Kenji Hara wrote: It is definitely a bug. I cannot believe that such horrible bug is still there. If you have a time, could you please file it in bugzilla? http://d.puremagic.com/issues/ Kenji Hara I can't believe you are not aware of that. By the

Re: using this instead of typeof(this)

2013-02-26 Thread bearophile
Kenji Hara: auto return is a little different with others. To infer return type, the method body is aggressively analyzed in compilation. So that usage of "auto" sounds like something to avoid if you want D compiler to compile quickly a lot of code. Bye, bearophile

Re: using this instead of typeof(this)

2013-02-26 Thread monarch_dodra
On Tuesday, 26 February 2013 at 18:22:03 UTC, Kenji Hara wrote: Returning S, S!(...), and typeof(this) are identical... Kenji Hara Just note that if the function is const or immutable, then "typeof(this)" will be "immutable S!(...)", where as if you use an actual "S!(...)" as your return valu

Re: using this instead of typeof(this)

2013-02-26 Thread Kenji Hara
On Tuesday, 26 February 2013 at 16:28:59 UTC, Ivan Kazmenko wrote: Hi! I have recently experimented with ways to express the exact instantiated type of a generic struct, and found that I can in some cases use "this" as that type. Here is a sample program (DMD 2.062) demonstrating various use

Problem in a system of "uncollected' object

2013-02-26 Thread D-ratiseur
Hello, I'm learning D with a strong Delphi/O.Pascal background. As a test I try to implement a system of ownership which completelly bypasses the GC. For the "uncollected object" ancestor, I use the example provided in the documentation: class TUObject: Object { new(size_t sz) {

Re: using this instead of typeof(this)

2013-02-26 Thread Maxim Fomin
On Tuesday, 26 February 2013 at 16:28:59 UTC, Ivan Kazmenko wrote: Hi! I have recently experimented with ways to express the exact instantiated type of a generic struct, and found that I can in some cases use "this" as that type. 1) D allows omitting parameter names in function definitions

Re: using this instead of typeof(this)

2013-02-26 Thread Maxim Fomin
On Tuesday, 26 February 2013 at 16:57:50 UTC, monarch_dodra wrote: On Tuesday, 26 February 2013 at 16:28:59 UTC, Ivan Kazmenko wrote: Hi! I have recently experimented with ways to express the exact instantiated type of a generic struct, and found that I can in some cases use "this" as that ty

Re: using this instead of typeof(this)

2013-02-26 Thread Ivan Kazmenko
- this (ref this) // not a postblit constructor this (ref this, this f, typeof (this), this, ref this g) - There was a discussion about this recently (wasn't it with you?) and I believe the conclusion basically boiled down to "bug: accepts-wrong". Yeah, and the curios

Re: using this instead of typeof(this)

2013-02-26 Thread monarch_dodra
On Tuesday, 26 February 2013 at 16:28:59 UTC, Ivan Kazmenko wrote: Hi! I have recently experimented with ways to express the exact instantiated type of a generic struct, and found that I can in some cases use "this" as that type. - this (ref this) // not a postblit constructor

Re: using this instead of typeof(this)

2013-02-26 Thread bearophile
Ivan Kazmenko: (1) Should I refrain from using this as a type, is it a bug? Using typeof(this) is OK, and makes code more DRY. (2) A matter of style: what is the idiomatic way to take the exact type of a templated struct? For example, which method signature to return a typeof(this) value i

Re: inlining final functions

2013-02-26 Thread Jonathan M Davis
On Tuesday, February 26, 2013 10:20:21 n00b wrote: > Is the following correct : > > class X > { > void foo() { ... } > } > class Y : X > { > final override void foo() { ... } > } > > > Y y = new Y; > y.foo; //inlined > X x = y; > x.foo; //not inlined Y.foo can be made non-virtual by

using this instead of typeof(this)

2013-02-26 Thread Ivan Kazmenko
Hi! I have recently experimented with ways to express the exact instantiated type of a generic struct, and found that I can in some cases use "this" as that type. Here is a sample program (DMD 2.062) demonstrating various uses of "this" as a type: - import std.stdio; struct S {

Re: get size of class instance (not reference)?

2013-02-26 Thread Steven Schveighoffer
On Mon, 25 Feb 2013 20:09:05 -0500, Nick Sabalausky wrote: On Tue, 26 Feb 2013 01:54:44 +0100 "bearophile" wrote: Nick Sabalausky: > How can I get the size of a non-subclassed *instance*? Is this enough? http://dlang.org/traits.html#classInstanceSize Ahh, yes, of course. I had a feel

inlining final functions

2013-02-26 Thread n00b
Is the following correct : class X { void foo() { ... } } class Y : X { final override void foo() { ... } } Y y = new Y; y.foo; //inlined X x = y; x.foo; //not inlined

Re: A little of coordination for Rosettacode

2013-02-26 Thread Jos van Uden
On Tuesday, 26 February 2013 at 14:10:04 UTC, bearophile wrote: With functions like this my last version will become simpler, and it's equally statically type safe: bool xor(in bool[2] args) pure nothrow { return b[0] != b[1]; } This third version is much simpler and it seems good enough f

Re: A little of coordination for Rosettacode

2013-02-26 Thread bearophile
With functions like this my last version will become simpler, and it's equally statically type safe: bool xor(in bool[2] args) pure nothrow { return b[0] != b[1]; } This third version is much simpler and it seems good enough for Rosettacode: http://codepad.org/YJjb1t91 Bye, bearophile

Re: A little of coordination for Rosettacode

2013-02-26 Thread bearophile
But I couldn't figure out how to expand the boolean array to an argument list. With functions like this my last version will become simpler, and it's equally statically type safe: bool xor(in bool[2] args) pure nothrow { return b[0] != b[1]; } Bye, bearophile

Re: A little of coordination for Rosettacode

2013-02-26 Thread bearophile
Jos van Uden: But I couldn't figure out how to expand the boolean array to an argument list. I wrote a version, it's more statically type safe, but the code is quite hairy, and the foreach(i) generates too many templates if the predicate has many bool arguments: http://codepad.org/9Ar1pmMc

Re: D timer

2013-02-26 Thread bearophile
David: Not sure what you mean, but I have a pretty solid Timer implementation (Threaded) https://github.com/Dav1dde/BraLa/blob/master/brala/utils/thread.d The file has no dependencies, so copy it over and have fun. License of the whole application is GPLv3, but if you need it relicensed dro

Re: D timer

2013-02-26 Thread heromyth
On Sunday, 10 February 2013 at 14:49:15 UTC, SaltySugar wrote: Can i do my own timer in D console application? like in C# timer_Tick event. I have also created one. Please, see here: https://bitbucket.org/heromyth/dtoolkit/src/a8b5f8874e3d82373b71a2ca5c9f02a73362b56a/toolkit/System/Timer.d?at=