Re: auto function attributes based on type

2015-03-11 Thread amber via Digitalmars-d-learn
On Thursday, 12 March 2015 at 04:04:28 UTC, weaselcat wrote: On Thursday, 12 March 2015 at 03:12:15 UTC, amber wrote: ... http://dlang.org/function.html#function-attribute-inference might be a good read if you haven't read it already. I did read it but didn't really understand it, so I've

Re: auto function attributes based on type

2015-03-11 Thread amber via Digitalmars-d-learn
On Thursday, 12 March 2015 at 04:51:42 UTC, amber wrote: On Thursday, 12 March 2015 at 04:04:28 UTC, weaselcat wrote: On Thursday, 12 March 2015 at 03:12:15 UTC, amber wrote: ... http://dlang.org/function.html#function-attribute-inference might be a good read if you haven't read it already.

auto function attributes based on type

2015-03-11 Thread amber via Digitalmars-d-learn
Hi, Is there a way in D to specify function attributes for a template struct/class by type? E.g. given a template struct/class as follows: --- struct S(T) { T[] values; void someFunc(int i) pure nothrow @safe {} } --- For some types the pure, nothrow, @safe attributes are valid and

Re: Does static ctor/dtor of struct behave differently in 2.067-b2?

2015-03-01 Thread amber via Digitalmars-d-learn
On Saturday, 28 February 2015 at 03:26:17 UTC, ketmar wrote: On Fri, 27 Feb 2015 23:58:16 +, amber wrote: On Friday, 27 February 2015 at 23:50:51 UTC, amber wrote: Hi All, [snip] Thanks, amber [edited subject] Sorry I should add that I'm talking about static ctor/dtor of struct.

Does static ctor/dtor behave differently in 2.067-b2?

2015-02-27 Thread amber via Digitalmars-d-learn
Hi All, I am just wondering if dmd 2067-b2 invokes static this() and static ~this() differently to 2066.1 I have a strange bug when I use DMD2.067-b2 and it looks a lot like the static ctor/dtor are run from a separate thread to main() and unittest{} blocks. When I run under 2066.1 the code

Re: Does static ctor/dtor of struct behave differently in 2.067-b2?

2015-02-27 Thread amber via Digitalmars-d-learn
On Friday, 27 February 2015 at 23:50:51 UTC, amber wrote: Hi All, [snip] Thanks, amber [edited subject] Sorry I should add that I'm talking about static ctor/dtor of struct. The bug I see with 2.067-b2 is this: 1. static this() {} called and static fields of struct are initialised 2.

Re: Struct inheritance

2015-02-24 Thread amber via Digitalmars-d-learn
On Tuesday, 24 February 2015 at 12:16:43 UTC, Tobias Pankrath wrote: On Tuesday, 24 February 2015 at 12:05:51 UTC, amber wrote: Hi, Is it possible in D to have inheritance using value types, i.e. structs? No runtime polymorphism, but a kind of sub typing via alias this. struct S { void

Struct inheritance

2015-02-24 Thread amber via Digitalmars-d-learn
Hi, Is it possible in D to have inheritance using value types, i.e. structs? Also I don't quite understand how copy ctors work in D. Do I need to implement opAssign(S other) {}, or this(this) {} and what's the difference between these two? Thanks, Amber

Re: Is this a bug in dmd 2.067 for struct initializers?

2015-02-22 Thread amber via Digitalmars-d-learn
On Sunday, 22 February 2015 at 23:17:33 UTC, Martin Nowak wrote: On Thursday, 19 February 2015 at 22:07:55 UTC, stewarth wrote: I've gone with static this() approach and it works. You should use shared static this to initialize immutable variables. OK, thanks a lot for the help. Cheers,