Re: Real implicitly converts to float?

2016-06-22 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 14:17:42 UTC, Jonathan M Davis wrote: Well, that particular value should probably work thanks to VRP (value range propagation), since 10 can fit into float with no loss of precision. However, what's far more disconcerting is that real x = real.max; float y = x;

Re: Get specific item by index from DList

2016-06-22 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jun 22, 2016 at 10:49:54PM +, TheDGuy via Digitalmars-d-learn wrote: > On Wednesday, 22 June 2016 at 22:25:21 UTC, lmpo wrote: > > On Wednesday, 22 June 2016 at 22:10:09 UTC, TheDGuy wrote: > > > Hi, > > > > > > i am currently programming a small game with GTKD and i have to > > > use

Re: How to use a char[] buffer in D

2016-06-22 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jun 22, 2016 at 09:57:04PM +, Andrew Chapman via Digitalmars-d-learn wrote: > Hi everyone, just wanting some help with optimisation if anyone is > kind enough :-) > > I have a loop that iterates potentially millions of times, and inside > that loop I have code that appends some

Re: Get specific item by index from DList

2016-06-22 Thread lmpo via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 22:10:09 UTC, TheDGuy wrote: Hi, i am currently programming a small game with GTKD and i have to use a Dlist because an array is static Static ? An array is not static. a DList is only interesting when you have to insert or remove inside the list i.e not at the

Re: How to use a char[] buffer in D

2016-06-22 Thread Ali Çehreli via Digitalmars-d-learn
On 06/22/2016 02:57 PM, Andrew Chapman wrote: > Code such as: > > if(buffer in myHash) { > > } > > throws an access violation. A string value works without error. Does it throw an exception? Can you reproduce the issue with a short program? Ali

Get specific item by index from DList

2016-06-22 Thread TheDGuy via Digitalmars-d-learn
Hi, i am currently programming a small game with GTKD and i have to use a Dlist because an array is static but i want to add user inputs dynamically to a list. Now i am wondering how i can get a specific item from that list? I read that this isn't possible but is it possible to convert that

How to use a char[] buffer in D

2016-06-22 Thread Andrew Chapman via Digitalmars-d-learn
Hi everyone, just wanting some help with optimisation if anyone is kind enough :-) I have a loop that iterates potentially millions of times, and inside that loop I have code that appends some strings together, e.g.: string key = s1 ~ "_" ~ s2; I discovered that due to the memory

Re: Initialise dynamic array in array of structures

2016-06-22 Thread ketmar via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 09:27:01 UTC, cym13 wrote: what i meant is that "{}" should be fully equivalent to "Struct()" ctor in terms of calling postblits, and it isn't.

Re: Initialise dynamic array in array of structures

2016-06-22 Thread ketmar via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 09:27:01 UTC, cym13 wrote: On the other hand I don't see why you'd expect {} to call postblit at all. 'cause it essentially makes a copy. i gave the sample in bugreport. it worth me a hour of debugging to find why my refcounted struct keep crashing with invalid

Re: GTKD - get CSS class for button

2016-06-22 Thread TheDGuy via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 17:50:53 UTC, Mike Wey wrote: "Type T wraps should match the type of the data" Does string match the type of the data? What is the type of the data? How do i tell the function that i want the Array as a string array? I am not familiar with Types and what 'TC' or

Re: Behavior of __FILE__ in mixin template

2016-06-22 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 17:52:26 UTC, Ali Çehreli wrote: On 06/22/2016 10:07 AM, Andre Pany wrote: > Hi, > > I thought a mixin template is copied into the place where the mixin > statement > exists and then the coding is evaluated. > This seems not to be true for __FILE__ Apparently its

Re: Using .lib and .dll in D applications

2016-06-22 Thread moe via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 05:34:33 UTC, Mike Parker wrote: On Wednesday, 22 June 2016 at 03:06:29 UTC, moe wrote: I meant like this: - PluginContract // not a dub project, just some folder -- iplugin.d - TestApp // all files for the app (separate project) -- packages

Re: Behavior of __FILE__ in mixin template

2016-06-22 Thread Ali Çehreli via Digitalmars-d-learn
On 06/22/2016 10:07 AM, Andre Pany wrote: > Hi, > > I thought a mixin template is copied into the place where the mixin > statement > exists and then the coding is evaluated. > This seems not to be true for __FILE__ Apparently its the whole template that supports that. Is moving the 'file'

Re: GTKD - get CSS class for button

2016-06-22 Thread Mike Wey via Digitalmars-d-learn
On 06/22/2016 05:16 PM, TheDGuy wrote: On Wednesday, 22 June 2016 at 13:47:01 UTC, Gerald wrote: On Wednesday, 22 June 2016 at 12:57:51 UTC, TheDGuy wrote: widget.getStyleContext().listClasses() to get a list of all classes assigned to the widget. If you just want to see if a specific class is

Re: Is there anyway to make opApply @nogc?

2016-06-22 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 13:36:54 UTC, Marc Schütz wrote: On Tuesday, 21 June 2016 at 19:21:01 UTC, Gary Willoughby wrote: Right ok, thanks! It doesn't seem to help though as the compiler complains about it being not @nogc. You probably need to declare the delegate and opApply() itself

Behavior of __FILE__ in mixin template

2016-06-22 Thread Andre Pany via Digitalmars-d-learn
Hi, I thought a mixin template is copied into the place where the mixin statement exists and then the coding is evaluated. This seems not to be true for __FILE__ I have a module form, which has a class Form. This module also contains following mixin template mixin template formTemplate() {

Re: TypeInfo_Interface from runtime string?

2016-06-22 Thread Thalamus via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 15:46:15 UTC, Thalamus wrote: On Wednesday, 22 June 2016 at 15:43:08 UTC, Basile B. wrote: On Wednesday, 22 June 2016 at 15:15:51 UTC, Thalamus wrote: [...] No need for a constructor. typeid() returns a static instance that's pre-allocated. [...] Thanks

Re: TypeInfo_Interface from runtime string?

2016-06-22 Thread Thalamus via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 15:43:08 UTC, Basile B. wrote: On Wednesday, 22 June 2016 at 15:15:51 UTC, Thalamus wrote: [...] No need for a constructor. typeid() returns a static instance that's pre-allocated. [...] Thanks Basile.

Re: TypeInfo_Interface from runtime string?

2016-06-22 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 15:15:51 UTC, Thalamus wrote: Hi everyone, My project includes lots of .Net interop via C linkage. One of the things I need to do is refer in C# to an interface declared in the D code, and then to actually work with the interface concretely in the D layer. So, I

Re: GTKD - get CSS class for button

2016-06-22 Thread TheDGuy via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 13:47:01 UTC, Gerald wrote: On Wednesday, 22 June 2016 at 12:57:51 UTC, TheDGuy wrote: widget.getStyleContext().listClasses() to get a list of all classes assigned to the widget. If you just want to see if a specific class is assigned to the widget you can use

TypeInfo_Interface from runtime string?

2016-06-22 Thread Thalamus via Digitalmars-d-learn
Hi everyone, My project includes lots of .Net interop via C linkage. One of the things I need to do is refer in C# to an interface declared in the D code, and then to actually work with the interface concretely in the D layer. So, I need to get a TypeInfo_Interface object from a string

Re: TickDuration depreciated, yet stopwatch not?

2016-06-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 21, 2016 19:17:00 Joerg Joergonson via Digitalmars-d-learn wrote: > Stopwatch depends on TickDuration and TickDuration is depreciated > yet Stopwatch isn't and hasn't been converted to MonoTime... > makes sense? TickDuration does have a note in its documentation about how it's

Re: Real implicitly converts to float?

2016-06-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 22, 2016 05:04:42 Tofu Ninja via Digitalmars-d-learn wrote: > Is this intended behavior? I can't seem to find it documented > anywhere, I would think the loss in precision would atleast be a > warning. > > real x = 10; > float y = x; // No error or warning > > real to double and

Re: GTKD - get CSS class for button

2016-06-22 Thread Gerald via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 12:57:51 UTC, TheDGuy wrote: widget.getStyleContext().listClasses() to get a list of all classes assigned to the widget. If you just want to see if a specific class is assigned to the widget you can use widget.getStyleContext().hasClass() Thanks a lot for your

Re: Is there anyway to make opApply @nogc?

2016-06-22 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 21 June 2016 at 19:21:01 UTC, Gary Willoughby wrote: Right ok, thanks! It doesn't seem to help though as the compiler complains about it being not @nogc. You probably need to declare the delegate and opApply() itself as @nogc, too: int opApply(scope int delegate(int) @nogc dg)

Re: Access vialotion

2016-06-22 Thread Bell Baggins via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 13:24:47 UTC, vladdeSV wrote: On Wednesday, 22 June 2016 at 12:47:31 UTC, TheDGuy wrote: On Wednesday, 22 June 2016 at 12:45:29 UTC, TheDGuy wrote: I have an array of buttons: class Window : MainWindow{ private Button[4] bArr; this(){ Button btn_1

Re: Access vialotion

2016-06-22 Thread vladdeSV via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 12:47:31 UTC, TheDGuy wrote: On Wednesday, 22 June 2016 at 12:45:29 UTC, TheDGuy wrote: I have an array of buttons: class Window : MainWindow{ private Button[4] bArr; this(){ Button btn_1 = new Button(); Button btn_2 = new Button();

Re: Real implicitly converts to float?

2016-06-22 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 08:57:38 UTC, Guillaume Piolat wrote: On Wednesday, 22 June 2016 at 05:04:42 UTC, Tofu Ninja wrote: Is this intended behavior? I can't seem to find it documented anywhere, I would think the loss in precision would atleast be a warning. real x = 10; float y = x;

Re: Access vialotion

2016-06-22 Thread Moro Greenhand via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 12:47:31 UTC, TheDGuy wrote: On Wednesday, 22 June 2016 at 12:45:29 UTC, TheDGuy wrote: I have an array of buttons: class Window : MainWindow{ private Button[4] bArr; this(){ Button btn_1 = new Button(); Button btn_2 = new Button();

Re: GTKD - get CSS class for button

2016-06-22 Thread TheDGuy via Digitalmars-d-learn
widget.getStyleContext().listClasses() to get a list of all classes assigned to the widget. If you just want to see if a specific class is assigned to the widget you can use widget.getStyleContext().hasClass() Thanks a lot for your answer. Do you know how i can get the first classname as

Re: Access vialotion

2016-06-22 Thread TheDGuy via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 12:45:29 UTC, TheDGuy wrote: I have an array of buttons: class Window : MainWindow{ private Button[4] bArr; this(){ Button btn_1 = new Button(); Button btn_2 = new Button(); Button btn_3 = new Button(); Button btn_4 = new

Access vialotion

2016-06-22 Thread TheDGuy via Digitalmars-d-learn
I have an array of buttons: class Window : MainWindow{ private Button[4] bArr; this(){ Button btn_1 = new Button(); Button btn_2 = new Button(); Button btn_3 = new Button(); Button btn_4 = new Button(); Button[4] bArr = [btn_1,btn_2,btn_3,btn_4];

Re: GTKD - get CSS class for button

2016-06-22 Thread Gerald via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 08:08:20 UTC, TheDGuy wrote: Hello, i would like to know if it possible to get the CSS-class which is asigned to a button (for example)? I didn't find any documentation about this, just the function "getStyleContext().getProperty()", my current attempt: Value

Re: Initialise dynamic array in array of structures

2016-06-22 Thread cym13 via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 08:06:26 UTC, ketmar wrote: On Wednesday, 22 June 2016 at 06:43:12 UTC, Paul wrote: Why is initialisation via {} bad (in simple terms please :D)? first, it is buggy. i.e. it doesn't always call postblit[1]. second, it's syntax is the same as the syntax of

Re: Real implicitly converts to float?

2016-06-22 Thread Guillaume Piolat via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 05:04:42 UTC, Tofu Ninja wrote: Is this intended behavior? I can't seem to find it documented anywhere, I would think the loss in precision would atleast be a warning. real x = 10; float y = x; // No error or warning real to double and double to float also work.

Re: Searching for a T in a T[]

2016-06-22 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 08:07:51 UTC, David Nadlinger wrote: What about http://dlang.org/phobos/std_algorithm_searching.html#.canFind.canFind.2? My mistake. The reason for the template error message was another than I though of. Thanks.

Re: Searching for a T in a T[]

2016-06-22 Thread cym13 via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 08:04:34 UTC, Nordlöw wrote: Is there now algorithm (similar to `canFind`) that can search for a `T` in a `T[]`? Existing `canFind` only supports sub-sequence needles. I'm aware of `std.string.indexOf` but that's only for strings. I don't see why canFind isn't

GTKD - get CSS class for button

2016-06-22 Thread TheDGuy via Digitalmars-d-learn
Hello, i would like to know if it possible to get the CSS-class which is asigned to a button (for example)? I didn't find any documentation about this, just the function "getStyleContext().getProperty()", my current attempt: Value value;

Re: Initialise dynamic array in array of structures

2016-06-22 Thread ketmar via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 06:43:12 UTC, Paul wrote: Why is initialisation via {} bad (in simple terms please :D)? first, it is buggy. i.e. it doesn't always call postblit[1]. second, it's syntax is the same as the syntax of argument-less lambda, which makes it context-dependent -- so

Re: Searching for a T in a T[]

2016-06-22 Thread David Nadlinger via Digitalmars-d-learn
On Wednesday, 22 June 2016 at 08:04:34 UTC, Nordlöw wrote: Is there now algorithm (similar to `canFind`) that can search for a `T` in a `T[]`? Existing `canFind` only supports sub-sequence needles. What about http://dlang.org/phobos/std_algorithm_searching.html#.canFind.canFind.2? — David

Searching for a T in a T[]

2016-06-22 Thread Nordlöw via Digitalmars-d-learn
Is there now algorithm (similar to `canFind`) that can search for a `T` in a `T[]`? Existing `canFind` only supports sub-sequence needles. I'm aware of `std.string.indexOf` but that's only for strings.

Re: GTKD - overrideBackgroundColor of Button doesn't work

2016-06-22 Thread TheDGuy via Digitalmars-d-learn
I am wondering if it is possible to get the name of the current CSS-class the button is asigned to?

Re: Initialise dynamic array in array of structures

2016-06-22 Thread Paul via Digitalmars-d-learn
On Tuesday, 21 June 2016 at 19:33:31 UTC, cym13 wrote: ... but “trackTemplates[0].coords = [{0, 9}, {1, 1}, {3, 6}];” is an assignment so the compiler can infer as much and doesn't understand that each of those list of values are really CoordLists. I see, but it seems a bit strange given that