Re: Switch function from runtime to compile time

2019-03-14 Thread Michelle Long via Digitalmars-d-learn
On Thursday, 14 March 2019 at 11:38:44 UTC, alex1974 wrote: I have several geometric shapes (triangle, trapezoid, gauss, ...) forming the membership functions of a fuzzy set. For example the shape of the triangle is defined by the variables a, b and c. The function calculating membership looks

Re: local class instance (at module-level)

2019-03-14 Thread spir via Digitalmars-d-learn
On 15/03/2019 00:45, ag0aep6g via Digitalmars-d-learn wrote: On 14.03.19 20:43, Jacob Carlborg wrote: class C { uint i ; this (uint i) { this.i = i ; } this (uint i) shared { this.i = i ; } this (uint i) immutable { this.i = i ; }

Re: local class instance (at module-level)

2019-03-14 Thread ag0aep6g via Digitalmars-d-learn
On 14.03.19 20:43, Jacob Carlborg wrote: class C {     uint i ;     this (uint i) {     this.i = i ;     }     this (uint i) shared {     this.i = i ;     }     this (uint i) immutable {     this.i = i ;     } } __gshared c0 = new C(0); shared c1 = new shared C(1);

Re: bug in doc?

2019-03-14 Thread Dennis via Digitalmars-d-learn
On Thursday, 14 March 2019 at 19:46:30 UTC, spir wrote: But the doc (the language ref for the matter) should definitely say what you just explained above, shouldn't they? Well arguably, the spec should detail the language semantics formally and not just be a description of the reference

Re: Setting the GtkD Include Path in dexed?

2019-03-14 Thread Basile B. via Digitalmars-d-learn
On Thursday, 14 March 2019 at 20:06:08 UTC, Ron Tarrant wrote: On Thursday, 14 March 2019 at 16:02:01 UTC, Basile B. wrote: You must register put the static library file, not the object I thing, anyway, i just made you a video showing exactly what to do since finally the linker error is gone

Re: Setting the GtkD Include Path in dexed?

2019-03-14 Thread Ron Tarrant via Digitalmars-d-learn
On Thursday, 14 March 2019 at 16:02:01 UTC, Basile B. wrote: You must register put the static library file, not the object I thing, anyway, i just made you a video showing exactly what to do since finally the linker error is gone (yay !), also launch one of the demo file as a "runnable

Re: bug in doc?

2019-03-14 Thread spir via Digitalmars-d-learn
On 14/03/2019 15:52, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Mar 14, 2019 at 03:22:52PM +0100, spir via Digitalmars-d-learn wrote: https://dlang.org/spec/hash-map.html#static_initialization: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; ==> Error:

Re: local class instance (at module-level)

2019-03-14 Thread Jacob Carlborg via Digitalmars-d-learn
On 2019-03-14 12:05, spir wrote: I desperately try to declare/define/initialise a simple class instance at module-level. This is a special (conceptually static and immutable) instance used as a "marker", that just should exist and be accessible by methods of this class and/or other classes

Re: Operator overloading for size_t

2019-03-14 Thread Alec Stewart via Digitalmars-d-learn
On Thursday, 14 March 2019 at 18:25:17 UTC, H. S. Teoh wrote: On Thu, Mar 14, 2019 at 06:07:46PM +, Alec Stewart via Digitalmars-d-learn wrote: [...] bool opEquals(ref const Interval i) const { // probably would be a bit more than just this, but for this issue // let's

Re: Operator overloading for size_t

2019-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 14, 2019 at 06:07:46PM +, Alec Stewart via Digitalmars-d-learn wrote: [...] > bool opEquals(ref const Interval i) const { > // probably would be a bit more than just this, but for this issue > // let's just stick with this. > return

Re: Operator overloading for size_t

2019-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 14 March 2019 at 18:07:46 UTC, Alec Stewart wrote: // let's just stick with this. return d_start.opEquals(other.d_start) && d_end.opEquals(other.d_end); Why not just use d_start == other.d_start && d_end == other.d_end there? So should I bother with operator

Operator overloading for size_t

2019-03-14 Thread Alec Stewart via Digitalmars-d-learn
I thought (for shits and giggles) to try and implement the Aho-Corasick algorithm[1]. I thought I'd start with a struct to represent the "interval": struct Interval { size_t d_start; size_t d_end; size_t size; this(size_t start, size_t end) {

Re: Setting the GtkD Include Path in dexed?

2019-03-14 Thread Basile B. via Digitalmars-d-learn
On Thursday, 14 March 2019 at 15:50:55 UTC, Ron Tarrant wrote: Thanks for replying, Basile. It's always nice to get info straight from the original code author. :) On Wednesday, 13 March 2019 at 11:59:11 UTC, Basile B. wrote: 1. "Compile File and Run" It's for the scripts-like program, i.e

Re: Tuple!(string, int))[] field_orders

2019-03-14 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 14 March 2019 at 15:29:28 UTC, Ozan wrote: Hi In vibe.d / data / mongo / collection I found the function * ensureIndex(Tuple!(string, int))[] field_orders) What could be the right way to use "Tuple!(string, int))[] field_orders"? I tried different ways like [Tuple!("a", 1),

Re: Setting the GtkD Include Path in dexed?

2019-03-14 Thread Ron Tarrant via Digitalmars-d-learn
Thanks for replying, Basile. It's always nice to get info straight from the original code author. :) On Wednesday, 13 March 2019 at 11:59:11 UTC, Basile B. wrote: 1. "Compile File and Run" It's for the scripts-like program, i.e single module. For this, the dependencies must be registered in

Re: Setting the GtkD Include Path in dexed?

2019-03-14 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 12 March 2019 at 15:48:14 UTC, Ron Tarrant wrote: I managed to get dexed to compile a single-file dub project, but for completeness sake, I'm also trying to configure it to use dmd (non-dub) to compile GtkD projects using Compilation (menu) > Compile File and Run. To that end, I

Tuple!(string, int))[] field_orders

2019-03-14 Thread Ozan via Digitalmars-d-learn
Hi In vibe.d / data / mongo / collection I found the function * ensureIndex(Tuple!(string, int))[] field_orders) What could be the right way to use "Tuple!(string, int))[] field_orders"? I tried different ways like [Tuple!("a", 1), Tuple!("b", 2)]", but compiler said "No" Any hint? Thanks

Re: bug in doc?

2019-03-14 Thread Daniel N via Digitalmars-d-learn
On Thursday, 14 March 2019 at 14:47:18 UTC, Adam D. Ruppe wrote: On Thursday, 14 March 2019 at 14:22:52 UTC, spir wrote: https://dlang.org/spec/hash-map.html#static_initialization: Well, bug in implementation. That is *supposed* to work, but the compiler never implemented it. The docs

Re: bug in doc?

2019-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 14, 2019 at 03:22:52PM +0100, spir via Digitalmars-d-learn wrote: > https://dlang.org/spec/hash-map.html#static_initialization: > > immutable long[string] aa = [ > "foo": 5, > "bar": 10, > "baz": 2000 > ]; > > ==> Error: non-constant expression `["foo":5L, "bar":10L,

Re: bug in doc?

2019-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 14 March 2019 at 14:22:52 UTC, spir wrote: https://dlang.org/spec/hash-map.html#static_initialization: Well, bug in implementation. That is *supposed* to work, but the compiler never implemented it. The docs really should point out this fact explicitly, though.

Re: bug in doc?

2019-03-14 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 14 March 2019 at 14:22:52 UTC, spir wrote: https://dlang.org/spec/hash-map.html#static_initialization: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; If I'm right, you can't use this syntax with global array. Insted this works: void main() {

Re: local class instance (at module-level)

2019-03-14 Thread spir via Digitalmars-d-learn
On 14/03/2019 12:16, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Mar 14, 2019 at 12:05:22PM +0100, spir via Digitalmars-d-learn wrote: I desperately try to declare/define/initialise a simple class instance at module-level. This is a special (conceptually static and immutable) instance

bug in doc?

2019-03-14 Thread spir via Digitalmars-d-learn
https://dlang.org/spec/hash-map.html#static_initialization: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; ==> Error: non-constant expression `["foo":5L, "bar":10L, "baz":2000L]` Also: I don't understand the error message: * What is non-constant in the *expression*? *

Re: Switch function from runtime to compile time

2019-03-14 Thread Alex via Digitalmars-d-learn
On Thursday, 14 March 2019 at 11:38:44 UTC, alex1974 wrote: I have several geometric shapes (triangle, trapezoid, gauss, ...) forming the membership functions of a fuzzy set. For example the shape of the triangle is defined by the variables a, b and c. The function calculating membership looks

Re: local class instance (at module-level)

2019-03-14 Thread Alex via Digitalmars-d-learn
On Thursday, 14 March 2019 at 11:05:22 UTC, spir wrote: I desperately try to declare/define/initialise a simple class instance at module-level. This is a special (conceptually static and immutable) instance used as a "marker", that just should exist and be accessible by methods of this class

Switch function from runtime to compile time

2019-03-14 Thread alex1974 via Digitalmars-d-learn
I have several geometric shapes (triangle, trapezoid, gauss, ...) forming the membership functions of a fuzzy set. For example the shape of the triangle is defined by the variables a, b and c. The function calculating membership looks like: real triangle (real a, real b, real c, real value) {

Re: local class instance (at module-level)

2019-03-14 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 14 March 2019 at 11:05:22 UTC, spir wrote: The most confusing error is: Error: variable `_base.c0` is a thread-local class and cannot have a static initializer. Use `static this()` to initialize instead. Error is reffering to: https://dlang.org/spec/module.html#staticorder

Re: local class instance (at module-level)

2019-03-14 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 14, 2019 at 12:05:22PM +0100, spir via Digitalmars-d-learn wrote: > I desperately try to declare/define/initialise a simple class instance > at module-level. This is a special (conceptually static and immutable) > instance used as a "marker", that just should exist and be accessible >

local class instance (at module-level)

2019-03-14 Thread spir via Digitalmars-d-learn
I desperately try to declare/define/initialise a simple class instance at module-level. This is a special (conceptually static and immutable) instance used as a "marker", that just should exist and be accessible by methods of this class and/or other classes defined in the same module. (Thus I