Re: why won't byPair work with a const AA?

2017-08-03 Thread Olivier FAURE via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 18:06:03 UTC, H. S. Teoh wrote: On Wed, Aug 02, 2017 at 01:15:44PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] The real answer is to have tail modifiers for structs, so you can do the same thing an array does. Note that if Result is an array,

Re: How to build GUI-based applications in D ?

2017-08-03 Thread ashit via Digitalmars-d-learn
On Tuesday, 1 August 2017 at 16:12:45 UTC, Dukc wrote: On Tuesday, 1 August 2017 at 15:18:12 UTC, ashit wrote: i couldn't set control's width and height (Button widget) shows error. maybe it works a different way. 1. Try layoutHeight/width. Remember to set it for the main widget too, not

Re: Access derived type in baseclass static function template

2017-08-03 Thread Timoses via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 15:38:12 UTC, Steven Schveighoffer wrote: On 8/2/17 11:06 AM, Timoses wrote: On Wednesday, 2 August 2017 at 13:51:01 UTC, Steven Schveighoffer wrote: However, your original code has potential as an enhancement request, as the type is known at compile-time and

Re: Why free and realloc seem to include .

2017-08-03 Thread Temtaime via Digitalmars-d-learn
On Thursday, 3 August 2017 at 14:03:56 UTC, Michael wrote: So this might be a bit of a stupid question, but looking at the DMD source code (dmodule.d in particular) I see the following code: if (srcfile._ref == 0) .free(srcfile.buffer); srcfile.buffer = null; srcfile.len = 0; and I was

Re: Why free and realloc seem to include .

2017-08-03 Thread Michael via Digitalmars-d-learn
On Thursday, 3 August 2017 at 14:15:40 UTC, Temtaime wrote: On Thursday, 3 August 2017 at 14:03:56 UTC, Michael wrote: So this might be a bit of a stupid question, but looking at the DMD source code (dmodule.d in particular) I see the following code: [...] and I was just wondering why

Template mixins and selective imports

2017-08-03 Thread jmh530 via Digitalmars-d-learn
I am trying to create a vectorize function that mixes in a new version of function with the same name that applies the function (to an ndslice). The code below compiles without error and has the behavior I would expect. However, when I change the function import to a selective import (e.g.

Re: Why free and realloc seem to include .

2017-08-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 3 August 2017 at 15:18:17 UTC, Michael wrote: I've not seen that either, though I'm not a C++ programmer. Does using free() on its own not assume access of a global namespace? Consider the following: class Foo { void free(void*); void other_method() { free(ptr); //

Re: Access derived type in baseclass static function template

2017-08-03 Thread Timoses via Digitalmars-d-learn
On Wednesday, 2 August 2017 at 12:07:46 UTC, Timoses wrote: Hey, wondering whether it's possible to access the derived type from a function template in the base class or interface. [...] Created an enhancement issue: https://issues.dlang.org/show_bug.cgi?id=17714

Why free and realloc seem to include .

2017-08-03 Thread Michael via Digitalmars-d-learn
So this might be a bit of a stupid question, but looking at the DMD source code (dmodule.d in particular) I see the following code: if (srcfile._ref == 0) .free(srcfile.buffer); srcfile.buffer = null; srcfile.len = 0; and I was just wondering why certain functions seem to be called

Re: Bug in gtkd?

2017-08-03 Thread Mike Wey via Digitalmars-d-learn
On 03-08-17 05:00, Johnson Jones wrote: On Wednesday, 2 August 2017 at 14:51:45 UTC, Mike Wey wrote: On 02-08-17 08:04, Johnson Jones wrote: Ok, Using msys I was able to get glade 3.20 running. Maybe that will fix everything. Great, unfortunately "Use msys2" seems to be the official way to

Re: why won't byPair work with a const AA?

2017-08-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/3/17 4:30 AM, Olivier FAURE wrote: I understand the general concept you're describing, but what exactly are tail modifiers? It's the first time I see this name, and my google-fu gives me nothing. tail modifiers are modifiers that only apply to the "tail" of the type. For example

Re: Bug in gtkd?

2017-08-03 Thread Mike Wey via Digitalmars-d-learn
On 03-08-17 22:40, Johnson Jones wrote: Ok, so, I linked the gtk to the msys gtk that I installed before when trying to get glade to work and it worked! seems that msys is much more up to date than anything else as it just works(I need to remember than in the future). The problem I see is

Re: Bug in gtkd?

2017-08-03 Thread Johnson Jones via Digitalmars-d-learn
On Thursday, 3 August 2017 at 15:11:46 UTC, Mike Wey wrote: On 03-08-17 05:00, Johnson Jones wrote: On Wednesday, 2 August 2017 at 14:51:45 UTC, Mike Wey wrote: On 02-08-17 08:04, Johnson Jones wrote: Ok, Using msys I was able to get glade 3.20 running. Maybe that will fix everything.

Re: Template mixins and selective imports

2017-08-03 Thread Meta via Digitalmars-d-learn
On Thursday, 3 August 2017 at 19:03:55 UTC, Meta wrote: `mixin vectorize!sin vsin; alias sin = vsin;` and see if it Should be `alias sin = vsin.sin;`

Re: Bug in gtkd?

2017-08-03 Thread Johnson Jones via Digitalmars-d-learn
On Thursday, 3 August 2017 at 15:11:46 UTC, Mike Wey wrote: On 03-08-17 05:00, Johnson Jones wrote: On Wednesday, 2 August 2017 at 14:51:45 UTC, Mike Wey wrote: On 02-08-17 08:04, Johnson Jones wrote: Ok, Using msys I was able to get glade 3.20 running. Maybe that will fix everything.

Re: Bug in gtkd?

2017-08-03 Thread Johnson Jones via Digitalmars-d-learn
On Thursday, 3 August 2017 at 15:11:46 UTC, Mike Wey wrote: On 03-08-17 05:00, Johnson Jones wrote: On Wednesday, 2 August 2017 at 14:51:45 UTC, Mike Wey wrote: On 02-08-17 08:04, Johnson Jones wrote: Ok, Using msys I was able to get glade 3.20 running. Maybe that will fix everything.

Re: gtkD load images

2017-08-03 Thread Johnson Jones via Digitalmars-d-learn
On Thursday, 3 August 2017 at 13:12:03 UTC, Mengu wrote: On Thursday, 3 August 2017 at 03:59:40 UTC, Johnson Jones wrote: How can be use gtkD to load images, I assume through gdkpixbuf? While I am getting errors loading images through glade's image: (test.exe:8188): Gtk-WARNING

Re: gtkD load images

2017-08-03 Thread Johnson Jones via Digitalmars-d-learn
On Thursday, 3 August 2017 at 13:12:03 UTC, Mengu wrote: On Thursday, 3 August 2017 at 03:59:40 UTC, Johnson Jones wrote: How can be use gtkD to load images, I assume through gdkpixbuf? While I am getting errors loading images through glade's image: (test.exe:8188): Gtk-WARNING

Re: Template mixins and selective imports

2017-08-03 Thread Meta via Digitalmars-d-learn
On Thursday, 3 August 2017 at 15:29:47 UTC, jmh530 wrote: I am trying to create a vectorize function that mixes in a new version of function with the same name that applies the function (to an ndslice). The code below compiles without error and has the behavior I would expect. However,

Re: Template mixins and selective imports

2017-08-03 Thread jmh530 via Digitalmars-d-learn
On Thursday, 3 August 2017 at 19:05:47 UTC, Meta wrote: On Thursday, 3 August 2017 at 19:03:55 UTC, Meta wrote: `mixin vectorize!sin vsin; alias sin = vsin;` and see if it Should be `alias sin = vsin.sin;` Thanks, this pointed me in the right direction. I got the line below working.

Re: Bug in gtkd?

2017-08-03 Thread Johnson Jones via Digitalmars-d-learn
On Thursday, 3 August 2017 at 21:00:17 UTC, Mike Wey wrote: On 03-08-17 22:40, Johnson Jones wrote: Ok, so, I linked the gtk to the msys gtk that I installed before when trying to get glade to work and it worked! seems that msys is much more up to date than anything else as it just works(I

Re: Why free and realloc seem to include .

2017-08-03 Thread Michael via Digitalmars-d-learn
On Thursday, 3 August 2017 at 15:29:29 UTC, Adam D. Ruppe wrote: On Thursday, 3 August 2017 at 15:18:17 UTC, Michael wrote: I've not seen that either, though I'm not a C++ programmer. Does using free() on its own not assume access of a global namespace? Consider the following: class Foo {

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Ali Çehreli via Digitalmars-d-learn
On 08/03/2017 06:02 PM, Andrew Edwards wrote: > char *s; That's an uninitialized C string. > nk_color_hex_rgb(s, str); That function is expecting it to have at least 7 chars when doing things like output[1] = (char)NK_TO_HEX((col.r & 0x0F)); So you have to have a proper

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/3/17 9:12 PM, Andrew Edwards wrote: Andrew Edwards wrote: int main() { //int wierd[4]; struct nk_color str = nk_rgba_hex("#deadbeef"); //int wierd[4]; char *s; //int wierd[4]; nk_color_hex_rgb(s, str); //int wierd[4]; printf("(%d,%d,%d)\n",str.r, str.g,

Re: Fix gtkD api display

2017-08-03 Thread Johnson Jones via Digitalmars-d-learn
Also, interfaces are not linkable. e.g., for gtk.ApplicationWindow, it inherits from gtk.Window but I have to go back to the packages and scroll down to find gtk.Window to see it's properties and methods. Would be nice if I could just click on the gtk.Window and it jump me to it.

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/3/17 10:14 PM, Andrew Edwards wrote: Steven Schveighoffer wrote: On 8/3/17 9:12 PM, Andrew Edwards wrote: Andrew Edwards wrote: Just in case... here are the two functions being called in main(): https://github.com/vurtun/nuklear/blob/master/nuklear.h#L5695-L5722 Can you show how you

Fix gtkD api display

2017-08-03 Thread Johnson Jones via Digitalmars-d-learn
https://api.gtkd.org It is difficult to navigate. 1. clicking the documentation on the main site takes it to the gtk.AboutDialog api. That is all it shows, I was confused at first, as I'm sure most people would be. 2. The packages list lists all the packages, but all the sub elements are

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Steven Schveighoffer wrote: On 8/3/17 9:12 PM, Andrew Edwards wrote: Andrew Edwards wrote: Just in case... here are the two functions being called in main(): https://github.com/vurtun/nuklear/blob/master/nuklear.h#L5695-L5722 Can you show how you declared these in D? It's important. I think

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Ali Çehreli wrote: On 08/03/2017 06:02 PM, Andrew Edwards wrote: char *s; That's an uninitialized C string. OK, I was is indeed the problem. I was thinking for some reason that s gets initialized inside nk_color_hex_rgb() but it's expecting to an array to work with. I actually

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Steven Schveighoffer wrote: On 8/3/17 10:14 PM, Andrew Edwards wrote: I certainly can, but the problem is completely in C, I'm not having any problems in D. In this case, I've simply copied the two functions to test.c and inserted main(). Oh. Then Ali is correct. I assumed that char *s was

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Ali Çehreli wrote: On 08/03/2017 06:02 PM, Andrew Edwards wrote: char *s; That's an uninitialized C string. OK, I was is indeed the problem. I was thinking for some reason that s gets initialized inside nk_color_hex_rgb() but it's expecting to an array to work with. I actually

GtkD custom theme on Windows

2017-08-03 Thread Andres Clari via Digitalmars-d-learn
I've made a linux program with GtkD, and so far, it's been pretty awesome, however I'm thinking about porting it to Windows also, but the Adwaita theme is too fugly, and cringy, so I'd want to use a compatible theme, which is supposed to be doable. What would be the way to go to make a GtkD

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Andrew Edwards wrote: int main() { //int wierd[4]; struct nk_color str = nk_rgba_hex("#deadbeef"); //int wierd[4]; char *s; //int wierd[4]; nk_color_hex_rgb(s, str); //int wierd[4]; printf("(%d,%d,%d)\n",str.r, str.g, str.b); //int wierd[4]; printf("%s\n",

OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
int main() { //int wierd[4]; struct nk_color str = nk_rgba_hex("#deadbeef"); //int wierd[4]; char *s; //int wierd[4]; nk_color_hex_rgb(s, str); //int wierd[4]; printf("(%d,%d,%d)\n",str.r, str.g, str.b); //int wierd[4]; printf("%s\n", s); //int

Re: gtkD load images

2017-08-03 Thread Mengu via Digitalmars-d-learn
On Thursday, 3 August 2017 at 03:59:40 UTC, Johnson Jones wrote: How can be use gtkD to load images, I assume through gdkpixbuf? While I am getting errors loading images through glade's image: (test.exe:8188): Gtk-WARNING **: Could not load image 'a.jpg': Couldn't recognize the

Re: Issue with template constraints in numeric types

2017-08-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 3 August 2017 at 12:24:02 UTC, data pulverizer wrote: import std.traits: isIntegral, isNumeric; Are you familiar with isFloatingPoint? http://dpldocs.info/experimental-docs/std.traits.isFloatingPoint.html if(is(T: double) && isNumeric!T) Keep in mind that T:double here means

Re: Issue with template constraints in numeric types

2017-08-03 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 3 August 2017 at 12:31:00 UTC, Adam D. Ruppe wrote: On Thursday, 3 August 2017 at 12:24:02 UTC, data pulverizer wrote: import std.traits: isIntegral, isNumeric; Are you familiar with isFloatingPoint? http://dpldocs.info/experimental-docs/std.traits.isFloatingPoint.html

Issue with template constraints in numeric types

2017-08-03 Thread data pulverizer via Digitalmars-d-learn
Dear all, I am writing template constraints for different numeric types: ``` import std.stdio: writeln; import std.traits: isIntegral, isNumeric; T test(T)(T x, T y) if(is(T: double) && isNumeric!T) { return x*y; } auto test(T)(T x, T y) if(!is(T: double) && isNumeric!T) {

Re: Issue with template constraints in numeric types

2017-08-03 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 3 August 2017 at 12:24:02 UTC, data pulverizer wrote: The same issue occurs when I try using template specializations instead. ... That is T test(T: double)(T x, T y){...} and T test(T)(T x, T y){...} Thanks

Re: Issue with template constraints in numeric types

2017-08-03 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 3 August 2017 at 12:35:08 UTC, data pulverizer wrote: What about this case: ``` T test(T: double)(T x, T y) { return x*y; } auto test(T)(T x, T y) { return 5*test!double(x, y); } ``` which also gives: ``` int test: 4 double test: 4 ``` Hmm ... it looks as the