Re: pointers, assignments, Garbage Collection Oh My?

2013-07-11 Thread Jacob Carlborg
On 2013-07-11 04:59, Maxim Fomin wrote: To be pedantic dynamic arrays are implemented in D simply as struct Array { size_t length; void* ptr; } and there is no type parametrization since such arrays handling is opaque for users (in druntime they are treated as void[]). Parametrizatio

Re: pointers, assignments, Garbage Collection Oh My?

2013-07-11 Thread Jacob Carlborg
On 2013-07-10 20:22, Ali Çehreli wrote: And to be pedantic, length comes first: struct Array (T) { size_t length; T* ptr; } I thought "ptr" came first, that's the reason you could cast to the pointer type. Not that one should do that. Perhaps there's some compiler/runtime magic in

Re: pointers, assignments, Garbage Collection Oh My?

2013-07-11 Thread Maxim Fomin
On Thursday, 11 July 2013 at 07:13:50 UTC, Jacob Carlborg wrote: On 2013-07-11 04:59, Maxim Fomin wrote: To be pedantic dynamic arrays are implemented in D simply as struct Array { size_t length; void* ptr; } and there is no type parametrization since such arrays handling is opaque

Re: Tuple indexing and slicing

2013-07-11 Thread Simen Kjaeraas
On 2013-07-11, 00:52, Timothee Cour wrote: Why not support Tuple indexing and slicing with [] syntax? (see below for a way to index/slice a tuple) void main(){ alias T=Tuple!(int,double); pragma(msg,T[0].stringof);//_expand_field_0 //pragma(msg,T[0..2].stringof); //Error: cannot slice ty

Re: Tuple indexing and slicing

2013-07-11 Thread Timothee Cour
On Thu, Jul 11, 2013 at 1:05 AM, Simen Kjaeraas wrote: > On 2013-07-11, 00:52, Timothee Cour wrote: > > Why not support Tuple indexing and slicing with [] syntax? >> (see below for a way to index/slice a tuple) >> >> void main(){ >> alias T=Tuple!(int,double); >> pragma(msg,T[0].stringof);//

Re: pointers, assignments, Garbage Collection Oh My?

2013-07-11 Thread Jacob Carlborg
On 2013-07-11 09:43, Maxim Fomin wrote: It's in the user side. In druntime it is void[] + typeinfo. I am not aware of any part in dmd/druntime where arrays are repsented as templates (or strongly typed) as depicted in this dicsussion. And current treatment can be barely called templatization as

Re: pointers, assignments, Garbage Collection Oh My?

2013-07-11 Thread Jacob Carlborg
On 2013-07-11 13:19, Jacob Carlborg wrote: Yes, but that is easier to type. All the above or: struct Array (T) { size_t length; T* ptr; } "that" should have been "what". -- /Jacob Carlborg

Can templated functions be used in interfaces?

2013-07-11 Thread Gary Willoughby
I have an interface like this: interface IAccessor { public ResultSet getCacheData(); public bool persist(T)(ref T[] collection); } Then i'm composing an object constraining via that interface: ... private IAccessor _accessor public void setAccessor(IAccessor accessor) { thi

Re: inverse of std.demangle?

2013-07-11 Thread Adam D. Ruppe
On Wed, Jul 10, 2013 at 06:30:57PM -0700, H. S. Teoh wrote: > I think this is a general problem of array and AA literals allocating at > runtime (and sometimes *every single time* the literal is used). Right, unless they are static immutable (which disqualifies them for CTFE I believe). This suck

Re: Can templated functions be used in interfaces?

2013-07-11 Thread Jakob Ovrum
On Thursday, 11 July 2013 at 11:56:16 UTC, Gary Willoughby wrote: Any idea what i'm doing wrong? Function templates cannot be virtual. You're allowed to declare non-virtual members of interfaces, but they must be defined. That means static functions, final functions and function templates ca

Re: Can templated functions be used in interfaces?

2013-07-11 Thread Gary Willoughby
Also i've noticed that the compiler doesn't complain if templated functions are not implemented in the classes that implement the interface, which is wrong!

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread Meta
On Thursday, 11 July 2013 at 04:03:19 UTC, Jesse Phillips wrote: On Thursday, 11 July 2013 at 03:06:39 UTC, Meta wrote: struct Option(T) { Algebraic!(Some!T, None) payload; alias payload this; } This is untested but it probably looks something like this: private alias MaybeType

Re: Can templated functions be used in interfaces?

2013-07-11 Thread Jakob Ovrum
On Thursday, 11 July 2013 at 12:00:20 UTC, Gary Willoughby wrote: Also i've noticed that the compiler doesn't complain if templated functions are not implemented in the classes that implement the interface, which is wrong! What you've done is declared a non-virtual member of the interface wit

Re: Can templated functions be used in interfaces?

2013-07-11 Thread Maxim Fomin
On Thursday, 11 July 2013 at 12:03:10 UTC, Jakob Ovrum wrote: However, in my opinion, it's a bug that you're allowed to declare a function template (when using the shortcut syntax) without defining it, whether in an interface or not. This is a rather natural bug though, due to the nature of fun

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread bearophile
Meta: I don't know whether to laugh or cry. Algebraic has several problems, but your code has other problems. I suggest to take a look at Nullable, especially the version that makes a constant value the "null". Also try to almost never use cast() in your code, unless you _really_ know wha

Re: inverse of std.demangle?

2013-07-11 Thread Adam D. Ruppe
On Thursday, 11 July 2013 at 01:32:33 UTC, H. S. Teoh wrote: I think this is a general problem of array and AA literals allocating at runtime (and sometimes *every single time* the literal is used). Aye, it is. Even here it was doing it on every single loop iteration. Disgusting. I was hoping

DLLs: Cleaning up

2013-07-11 Thread Chris
I have a DLL written in D I load into a Python application via ctypes like so: lib = CDLL("mydll") The DLL loads and can be used no problem. However, once the DLL is discarded of by the program, the program either doesn't react or crashes. I still haven't worked out how to clean up the DLL c

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread bearophile
Nullable!(int, 0) unreliable2(in int val) pure nothrow { if (val == 0) { return typeof(return)(); } else { return typeof(return)(val); } } Sorry, I meant: import std.typecons; Nullable!int unreliable1(in int val) pure nothrow { if (val == 0) { return typ

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread bearophile
Some example code: import std.typecons; Nullable!int unreliable1(in int val) pure nothrow { if (val == 0) { return typeof(return)(); } else { return typeof(return)(val); } } Nullable!(int, 0) unreliable2(in int val) pure nothrow { if (val == 0) { return t

Curl Module Error

2013-07-11 Thread Ali
I get an error message when trying to curl Error output: root@02x110:~/Desktop# gdc a.d -o a a.d:2: Error: module curl is in file 'std/net/curl.d' which cannot be read import path[0] = /usr/include/d2/4.6/i486-linux-gnu import path[1] = /usr/include/d2/4.6 My Code: import std.net.curl; impor

Re: Curl Module Error

2013-07-11 Thread Johannes Pfau
Am Thu, 11 Jul 2013 15:29:09 +0200 schrieb "Ali" : > /usr/include/d2/4.6 This looks like you're using a very old gdc version. std.net.curl was added in 2.058.

Re: Curl Module Error

2013-07-11 Thread Ali
On Thursday, 11 July 2013 at 13:46:48 UTC, Johannes Pfau wrote: Am Thu, 11 Jul 2013 15:29:09 +0200 schrieb "Ali" : /usr/include/d2/4.6 This looks like you're using a very old gdc version. std.net.curl was added in 2.058. How do I update? Searched, but could not find it. Because English i

Re: Curl Module Error

2013-07-11 Thread H. S. Teoh
On Thu, Jul 11, 2013 at 04:36:42PM +0200, Ali wrote: > On Thursday, 11 July 2013 at 13:46:48 UTC, Johannes Pfau wrote: > >Am Thu, 11 Jul 2013 15:29:09 +0200 > >schrieb "Ali" : > > > >>/usr/include/d2/4.6 > > > >This looks like you're using a very old gdc version. std.net.curl was > >added in 2.058.

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread Meta
On Thursday, 11 July 2013 at 12:30:17 UTC, bearophile wrote: Algebraic has several problems, but your code has other problems. Oh, no doubt. This isn't meant to be serious, industrial strength code. I suggest to take a look at Nullable, especially the version that makes a constant value the

A purity change

2013-07-11 Thread bearophile
This used to compile (probably dmd 2.060): struct Foo { immutable int y; void bar(TF)(TF f) pure { f(1); } void spam() pure { bar((int x) => y); } } void main() {} But now it gives: test.d(4): Error: pure function 'test.Foo.bar!(immutable(int) delegate(int

Re: Curl Module Error

2013-07-11 Thread Ali
On Thursday, 11 July 2013 at 14:44:23 UTC, H. S. Teoh wrote: On Thu, Jul 11, 2013 at 04:36:42PM +0200, Ali wrote: On Thursday, 11 July 2013 at 13:46:48 UTC, Johannes Pfau wrote: >Am Thu, 11 Jul 2013 15:29:09 +0200 >schrieb "Ali" : > >>/usr/include/d2/4.6 > >This looks like you're using a very ol

Re: A purity change

2013-07-11 Thread H. S. Teoh
On Thu, Jul 11, 2013 at 05:25:09PM +0200, bearophile wrote: > This used to compile (probably dmd 2.060): > > > struct Foo { > immutable int y; > void bar(TF)(TF f) pure { > f(1); > } > void spam() pure { > bar((int x) => y); > } > } > void main() {} > > > But

Re: A purity change

2013-07-11 Thread Meta
On Thursday, 11 July 2013 at 16:14:13 UTC, H. S. Teoh wrote: On Thu, Jul 11, 2013 at 05:25:09PM +0200, bearophile wrote: Hmm. This seems to be a tricky corner case. The delegate itself is impure, as it accesses y which is outside of its definition and isn't part of its arguments; however, in th

Re: inverse of std.demangle?

2013-07-11 Thread Jacob Carlborg
On 2013-07-11 14:39, Adam D. Ruppe wrote: Aye, it is. Even here it was doing it on every single loop iteration. Disgusting. I was hoping setting it as an enum would ctfe it and just be static data, but nope. Have you tried: enum string[23] _primitives = [ ... ]; static immutable primitives =

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread bearophile
Meta: Nullable will work in this case, but it doesn't solve the general problem with Algebraic. Then is this an acceptable solution? import std.variant; struct None {} template Option(T) { alias Option = Algebraic!(T, None); } Option!int unreliable(int val) pure nothrow { if (val

Re: A purity change

2013-07-11 Thread H. S. Teoh
On Thu, Jul 11, 2013 at 06:31:13PM +0200, Meta wrote: > On Thursday, 11 July 2013 at 16:14:13 UTC, H. S. Teoh wrote: > >On Thu, Jul 11, 2013 at 05:25:09PM +0200, bearophile wrote: > >Hmm. This seems to be a tricky corner case. The delegate itself is > >impure, as it accesses y which is outside of i

Re: inverse of std.demangle?

2013-07-11 Thread Adam D. Ruppe
On Thursday, 11 July 2013 at 16:38:48 UTC, Jacob Carlborg wrote: enum string[23] _primitives = [ ... ]; static immutable primitives = _primitives; Cool, a variant of that did work. Thanks! Now it is 100% heap allocation free.

Re: A purity change

2013-07-11 Thread Maxim Fomin
On Thursday, 11 July 2013 at 15:25:10 UTC, bearophile wrote: This used to compile (probably dmd 2.060): struct Foo { immutable int y; void bar(TF)(TF f) pure { f(1); } void spam() pure { bar((int x) => y); } } void main() {} But now it gives: test.d(4): Er

Re: inverse of std.demangle?

2013-07-11 Thread Adam D. Ruppe
BTW if you guys are wondering how I found the allocations, it was pretty simple: dmd mangle.d -debug -gc gdb ./mangle break gc_malloc break gc_qalloc r Then when it breaks, do "where" and see what called the gc alloc. Then hit "c" to continue and repeat until you've found and fixed them (or

Re: inverse of std.demangle?

2013-07-11 Thread Sean Kelly
On Jul 11, 2013, at 9:56 AM, Adam D. Ruppe wrote: > On Thursday, 11 July 2013 at 16:38:48 UTC, Jacob Carlborg wrote: >> enum string[23] _primitives = [ ... ]; >> static immutable primitives = _primitives; > > Cool, a variant of that did work. Thanks! > > Now it is 100% heap allocation free. Sw

Re: inverse of std.demangle?

2013-07-11 Thread Sean Kelly
On Jul 11, 2013, at 10:00 AM, "Adam D. Ruppe" wrote: > BTW if you guys are wondering how I found the allocations, it was pretty > simple: > > dmd mangle.d -debug -gc > gdb ./mangle > > break gc_malloc > break gc_qalloc > r > > > Then when it breaks, do "where" and see what called the gc allo

Re: pointers, assignments, Garbage Collection Oh My?

2013-07-11 Thread Ali Çehreli
On 07/11/2013 12:23 AM, Jacob Carlborg wrote: > On 2013-07-10 20:22, Ali Çehreli wrote: > >> And to be pedantic, length comes first: >> >> struct Array (T) >> { >> size_t length; >> T* ptr; >> } > > I thought "ptr" came first, that's the reason you could cast to the > pointer type. Not

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread Meta
On Thursday, 11 July 2013 at 16:48:00 UTC, bearophile wrote: Meta: Nullable will work in this case, but it doesn't solve the general problem with Algebraic. Then is this an acceptable solution? ... That is a bit better, yes. Still somewhat clunky, but workable. It'd still be nice if it was

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread Meta
On Thursday, 11 July 2013 at 17:11:05 UTC, Meta wrote: On Thursday, 11 July 2013 at 16:48:00 UTC, bearophile wrote: That is a bit better, yes. Still somewhat clunky, but workable. It'd still be nice if it wasn't necessary. Why does it break when I use Some!int instead of just a bare int? Oh,

Re: pointers, assignments, Garbage Collection Oh My?

2013-07-11 Thread Maxim Fomin
On Thursday, 11 July 2013 at 17:07:18 UTC, Ali Çehreli wrote: On 07/11/2013 12:23 AM, Jacob Carlborg wrote: > On 2013-07-10 20:22, Ali Çehreli wrote: > >> And to be pedantic, length comes first: >> >> struct Array (T) >> { >> size_t length; >> T* ptr; >> } > > I thought "ptr" came firs

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread bearophile
Meta: That is a bit better, yes. Still somewhat clunky, but workable. Recently Walter has proposed a small improvement able to reduce the size of that template. I don't know where Walter proposal has gone in the meantime, as people have suggested a better and more general design. It'd s

Re: pointers, assignments, Garbage Collection Oh My?

2013-07-11 Thread Ali Çehreli
On 07/11/2013 10:20 AM, Maxim Fomin wrote: > On Thursday, 11 July 2013 at 17:07:18 UTC, Ali Çehreli wrote: >> that magic should be the same as >> getting the .ptr property. Yes. > In context of slices cast(int*)arr is essentially s.ptr. And yes. :) Ali

Re: A purity change

2013-07-11 Thread bearophile
Maxim Fomin: My guess is that before 2.063 immutable int y was implicitly static, but now it is per instance data which requires context pointer which is deduced to be impure - that why compilation fails (try placing static attribute). In other words, before 2.063 this was a function and now

Re: A purity change

2013-07-11 Thread bearophile
Maxim Fomin: My guess is that before 2.063 immutable int y was implicitly static, Yet, in the code I used to initialize y in the normal constructor of Foo. If now I tag y as static, that's not possible any more (Error: can only initialize static const member scale inside static constructor)

Re: A purity change

2013-07-11 Thread Maxim Fomin
On Thursday, 11 July 2013 at 17:59:22 UTC, bearophile wrote: Maxim Fomin: My guess is that before 2.063 immutable int y was implicitly static, but now it is per instance data which requires context pointer which is deduced to be impure - that why compilation fails (try placing static attribut

Style question

2013-07-11 Thread Namespace
I have a style question, because a friend of mine has a similar problem currently and I have no good advice for him. Let's assume we have this classes: class MyClass { public: enum A { Foo = 0, Bar = 1 } private: A _a; public:

Re: A purity change

2013-07-11 Thread Maxim Fomin
On Thursday, 11 July 2013 at 18:03:14 UTC, bearophile wrote: Maxim Fomin: My guess is that before 2.063 immutable int y was implicitly static, Yet, in the code I used to initialize y in the normal constructor of Foo. If now I tag y as static, that's not possible any more (Error: can only in

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread Jesse Phillips
On Thursday, 11 July 2013 at 12:05:49 UTC, Meta wrote: On Thursday, 11 July 2013 at 04:03:19 UTC, Jesse Phillips wrote: On Thursday, 11 July 2013 at 03:06:39 UTC, Meta wrote: struct Option(T) { Algebraic!(Some!T, None) payload; alias payload this; } This is untested but it probabl

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread bearophile
Jesse Phillips: I forgot to mention that most of the casting you were doing doesn't do what you think it would. That's why I have suggested the OP to avoid to use cast() unless he/she knows well what she/he is doing. Bye, bearophile

Re: Style question

2013-07-11 Thread Simen Kjaeraas
On 2013-07-11, 20:22, Namespace wrote: What should he do? As far as I can see he has 3 options: 1. An external file with the enum information. Both classes would import it and could use the same enum. But he cannot change the API, so this is no real option. 2. Change test1 into this:

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread Meta
On Thursday, 11 July 2013 at 18:31:50 UTC, Jesse Phillips wrote: I forgot to mention that most of the casting you were doing doesn't do what you think it would. ... This doesn't make an Option!int castable to a Maybe!int, they are still distinct types: ... struct Test1 { int n; } s

Re: Difficulties with std.variant.Algebraic

2013-07-11 Thread Meta
On Thursday, 11 July 2013 at 18:49:27 UTC, Meta wrote: It seems you're right. That's disappointing. TDPL talks about alias this in terms of subtyping, but doesn't the above code show that this is not true subtyping? Actually, scratch that, I'm an idiot. I was thinking completely backwards.

Re: Style question

2013-07-11 Thread Namespace
It seems to me that MyClass has access to MyStaticClass, and thus should also have access to B. If this is the case, why is MyClass using an A instead of a B? No, they are sadly not part of the same file / module. The // should symbolize that. :D One option might be to use alias A = B; T

Re: Style question

2013-07-11 Thread Simen Kjaeraas
On 2013-07-11, 21:05, Namespace wrote: It seems to me that MyClass has access to MyStaticClass, and thus should also have access to B. If this is the case, why is MyClass using an A instead of a B? No, they are sadly not part of the same file / module. The // should symbolize that. :D I

Re: DLLs: Cleaning up

2013-07-11 Thread dnewbie
On Thursday, 11 July 2013 at 12:58:42 UTC, Chris wrote: I have a DLL written in D I load into a Python application via ctypes like so: lib = CDLL("mydll") The DLL loads and can be used no problem. However, once the DLL is discarded of by the program, the program either doesn't react or crash

Re: Style question

2013-07-11 Thread Maxim Fomin
On Thursday, 11 July 2013 at 18:22:11 UTC, Namespace wrote: I have a style question, because a friend of mine has a similar problem currently and I have no good advice for him. Let's assume we have this classes: The whole situation looks strange. If you can change both files, than it is uncl

Re: A range analysis question

2013-07-11 Thread bearophile
Ali Çehreli: I don't think we are there yet. :) Thinking some more about this topic I have created a small test example: uint i = 100; void main(in string[] args) { auto j = args.length; ubyte x1 = (i ^^ 2) % 256; // OK ubyte x2 = (i ^^ 3) % 256; // OK ubyte[] arr = [(i ^^

Re: A range analysis question

2013-07-11 Thread bearophile
I think this (the line with y) is worth an enhancement request. http://d.puremagic.com/issues/show_bug.cgi?id=10615 Bye, bearophile

Re: Style question

2013-07-11 Thread Namespace
The whole situation looks strange. If you can change both files, than it is unclear what made you to write such inconsistent code. If you can change only one of them, then it should be adjusted to another (meaning importing external file and using that enum instead of trying to define different

Re: A purity change

2013-07-11 Thread monarch_dodra
On Thursday, 11 July 2013 at 16:53:30 UTC, H. S. Teoh wrote: On Thu, Jul 11, 2013 at 06:31:13PM +0200, Meta wrote: On Thursday, 11 July 2013 at 16:14:13 UTC, H. S. Teoh wrote: >On Thu, Jul 11, 2013 at 05:25:09PM +0200, bearophile wrote: >Hmm. This seems to be a tricky corner case. The delegate

Re: A purity change

2013-07-11 Thread monarch_dodra
On Thursday, 11 July 2013 at 18:28:19 UTC, Maxim Fomin wrote: The reason it worked in normal constructor prior the change was probably the same bug. This docs covers the issue - http://dlang.org/changelog.html#staticfields Daym. Who thought it was a good idea to make immutable static by defau

how to profile compilation steps?

2013-07-11 Thread Timothee Cour
I'd like to at least get timestamps for the various steps appearing the the dmd -v output. Is there an easy way to modify dmd to output that? That could be fed to a D function that parses it and generates a nice profile report (ie the compiler would do not much more than just adding timestamps, lea

how to determine if type is final/abstract

2013-07-11 Thread JS
I have some code that needs to determine if a type isFinalFunction or isAbstractFunction but they don't seem to work: foreach(k, t; TargetMembers) { alias TypeTuple!(t.type)[0] type; if (isFinalFunction!(t)) { ... } } the if statement never gets executed. I've tried

Re: how to determine if type is final/abstract

2013-07-11 Thread JS
On Thursday, 11 July 2013 at 22:45:47 UTC, JS wrote: I have some code that needs to determine if a type isFinalFunction or isAbstractFunction but they don't seem to work: foreach(k, t; TargetMembers) { alias TypeTuple!(t.type)[0] type; if (isFinalFunction!(t)) { ... }

Re: how to determine if type is final/abstract

2013-07-11 Thread JS
On Thursday, 11 July 2013 at 23:04:20 UTC, JS wrote: On Thursday, 11 July 2013 at 22:45:47 UTC, JS wrote: I have some code that needs to determine if a type isFinalFunction or isAbstractFunction but they don't seem to work: foreach(k, t; TargetMembers) { alias TypeTuple!(t.type)[

Template unique IDs per type

2013-07-11 Thread Roderick Gibson
I was recently looking up how to assign a unique ID based on each different implementation of a templated type (NOT per instance, but per unique type). For example: class MyTemplate(T) { //the ? where the actual number would go const int type_id = ?; } void main() { auto a = new M

Re: Template unique IDs per type

2013-07-11 Thread JS
On Friday, 12 July 2013 at 03:15:46 UTC, Roderick Gibson wrote: I was recently looking up how to assign a unique ID based on each different implementation of a templated type (NOT per instance, but per unique type). For example: class MyTemplate(T) { //the ? where the actual number would g

Re: Template unique IDs per type

2013-07-11 Thread Roderick Gibson
On Friday, 12 July 2013 at 03:56:50 UTC, JS wrote: sure, each type name is unique. All you have to do is convert them to an int... use a hash or some other method or just use the string names. If you need the id's to be continuous try to use an set(array) of the type names. Not sure if the last

Re: Curl Module Error

2013-07-11 Thread H. S. Teoh
On Thu, Jul 11, 2013 at 05:38:16PM +0200, Ali wrote: > On Thursday, 11 July 2013 at 14:44:23 UTC, H. S. Teoh wrote: [...] > >gdc-4.8 is now available in Debian and a few other distros. You > >should be able to just update it if you use one of these distros; if > >not, try compiling from source (see

Re: Template unique IDs per type

2013-07-11 Thread Jonathan M Davis
On Friday, July 12, 2013 05:15:43 Roderick Gibson wrote: > I was recently looking up how to assign a unique ID based on each > different implementation of a templated type (NOT per instance, > but per unique type). For example: > > class MyTemplate(T) { > //the ? where the actual number woul

Re: Template unique IDs per type

2013-07-11 Thread Roderick Gibson
On Friday, 12 July 2013 at 04:42:28 UTC, Jonathan M Davis wrote: On Friday, July 12, 2013 05:15:43 Roderick Gibson wrote: I was recently looking up how to assign a unique ID based on each different implementation of a templated type (NOT per instance, but per unique type). For example: class M

Re: Template unique IDs per type

2013-07-11 Thread Roderick Gibson
On Friday, 12 July 2013 at 04:42:28 UTC, Jonathan M Davis wrote: Now, it's probably possible to use static constructors to use global mutable state to intialize all of those IDs when the program starts up, which would initialize the IDs to incrementing values, so they could be immutable if you

Final class

2013-07-11 Thread Daniel Kozak
Are all methods in final class non-virtual or must be explicity marked as a final too?

Re: Final class

2013-07-11 Thread Jonathan M Davis
On Friday, July 12, 2013 07:03:07 Daniel Kozak wrote: > Are all methods in final class non-virtual or must be explicity > marked as a final too? They're virtual if they override base class functions, but they're definitely all final. So, the compiler _should_ optimize the functions in a final cla

Re: Final class

2013-07-11 Thread Daniel Kozak
On Friday, 12 July 2013 at 05:13:44 UTC, Jonathan M Davis wrote: On Friday, July 12, 2013 07:03:07 Daniel Kozak wrote: Are all methods in final class non-virtual or must be explicity marked as a final too? They're virtual if they override base class functions, but they're definitely all final

thread local singleton vs. static variables

2013-07-11 Thread estew
Hi, I've been looking at std.idoms: http://someboddy.github.io/phobos/ddocs/for-idioms/idioms.html I am wondering why I would need ThreadLocalSingleton when D has thread local static variables. For example: class A { // My thread local globals. private this() {} static int x; stat

Re: Style question

2013-07-11 Thread Maxim Fomin
On Thursday, 11 July 2013 at 20:15:52 UTC, Namespace wrote: The whole situation looks strange. If you can change both files, than it is unclear what made you to write such inconsistent code. If you can change only one of them, then it should be adjusted to another (meaning importing external fi

Re: thread local singleton vs. static variables

2013-07-11 Thread estew
Could it be something to do with purity, perhaps?

Re: inverse of std.demangle?

2013-07-11 Thread Jacob Carlborg
On 2013-07-11 19:00, Adam D. Ruppe wrote: BTW if you guys are wondering how I found the allocations, it was pretty simple: dmd mangle.d -debug -gc gdb ./mangle break gc_malloc break gc_qalloc r Then when it breaks, do "where" and see what called the gc alloc. Then hit "c" to continue and repe

Re: how to determine if type is final/abstract

2013-07-11 Thread Jacob Carlborg
On 2013-07-12 00:45, JS wrote: I believe the issue is that isFinalFunction requires an actual function symbol but I'm passing it a string? How can I get this to work? Have you tried using a mixin? __traits(isFinalFunction, mixin(className ~ "." ~ member)); -- /Jacob Carlborg

Re: Style question

2013-07-11 Thread Jacob Carlborg
On 2013-07-11 20:22, Namespace wrote: [snip] Does anyone have any advice? Who is supposed to access these enums? Can you put it in a separate module but in the same package with package protection? -- /Jacob Carlborg