Re: Runtime heterogeneous collections?

2019-01-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 17, 2019 1:21:41 AM MST Dukc via Digitalmars-d-learn wrote: > On Thursday, 17 January 2019 at 02:27:20 UTC, Neia Neutuladh > > wrote: > > 1. Make a wrapper class. Now you can store Object[], or you can > > make a > > base class or base interface and use that. > > 2. Use

Re: Alternative to Interfaces

2019-01-17 Thread 1001Days via Digitalmars-d-learn
On Friday, 18 January 2019 at 01:00:33 UTC, H. S. Teoh wrote: Maybe you could help us answer your question better by explaining a bit more what you're trying to achieve. Generally, if you want to use an interface, that usually means you want (1) runtime polymorphism, i.e., the ability to swap

Re: Alternative to Interfaces

2019-01-17 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jan 18, 2019 at 12:08:00AM +, 1001Days via Digitalmars-d-learn wrote: > Hello, > > Preface: I do apologize if this is too simplistic of a matter, and if > I need to RTFM. I'm quite slow. > > I want to use Structs instead of Classes, but I don't want to lose the > abilities of

Alternative to Interfaces

2019-01-17 Thread 1001Days via Digitalmars-d-learn
Hello, Preface: I do apologize if this is too simplistic of a matter, and if I need to RTFM. I'm quite slow. I want to use Structs instead of Classes, but I don't want to lose the abilities of Interfaces. So instead I used a combination of templates, constraints, the hasMember trait, and

Re: problem extracting data from GtkSourceView using Gtkd

2019-01-17 Thread Chris Bare via Digitalmars-d-learn
I think I finally figured it out. I think the GTKapplication shutdown signal is called after the window has been destroyed. If I attach a handler to the window's destroy signal, then I am able to get the data from the sourceView.

Re: problem extracting data from GtkSourceView using Gtkd

2019-01-17 Thread Mike Wey via Digitalmars-d-learn
On 17-01-2019 00:31, Chris Bare wrote: Are the widgets destroyed before onShutdown? The onShutdown callback is run after the GTK main loop terminates, so most objects would be finalized. -- Mike Wey

Re: beginner's linking error

2019-01-17 Thread James Cranch via Digitalmars-d-learn
On Thursday, 17 January 2019 at 12:38:55 UTC, Adam D. Ruppe wrote: You need to pass all the modules you use to the compiler, or compile each one at a time and pass the resultant .o files to the linker together. Marvellous, thanks! (Okay, it was a naive beginner's question. But I can't help

Re: How to include curl.lib?

2019-01-17 Thread Andre Pany via Digitalmars-d-learn
On Thursday, 17 January 2019 at 20:05:27 UTC, Head Scratcher wrote: On Monday, 14 January 2019 at 18:45:27 UTC, Head Scratcher wrote: The following text is in the source code for curl.d: Windows x86 note: A DMD compatible libcurl static library can be downloaded from the dlang.org $(LINK2

Re: How to include curl.lib?

2019-01-17 Thread Head Scratcher via Digitalmars-d-learn
On Monday, 14 January 2019 at 18:45:27 UTC, Head Scratcher wrote: The following text is in the source code for curl.d: Windows x86 note: A DMD compatible libcurl static library can be downloaded from the dlang.org $(LINK2 http://downloads.dlang.org/other/index.html, download archive page).

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-17 Thread Matheus via Digitalmars-d-learn
On Thursday, 17 January 2019 at 16:55:33 UTC, SrMordred wrote: Yes, but there is a mistake there: alias is part of the template: foo(alias x)(){} //note extra parens than u call like an template: foo!"a"; //equivalent = foo!("a")(); foo!1; I see now and thanks. Matheus.

Re: What is the Utility of Parent Class Method Hiding in Inheritance?

2019-01-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/16/19 12:25 PM, Neia Neutuladh wrote: On Wed, 16 Jan 2019 12:01:06 -0500, Steven Schveighoffer wrote: It was 2.068 that removed the HiddenFuncError, and made this a compile error instead. If your compiler is that or newer, definitely file a bug report. Oh god, that must have been awful.

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-17 Thread kdevel via Digitalmars-d-learn
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote: On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote: [...] auto window = Window(); window.title = "My Window"; window.width = 1000; window.create(); [...] Is there a better way that's not ugly? [...] //usage:

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-17 Thread SrMordred via Digitalmars-d-learn
On Thursday, 17 January 2019 at 12:11:02 UTC, Matheus wrote: foo(alias x){} foo("a"); foo(1); 'x' will be string one time and integer another? Or there is something that I'm missing. Matheus. Yes, but there is a mistake there: alias is part of the template: foo(alias x)(){} //note extra

Re: beginner's linking error

2019-01-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 January 2019 at 10:38:50 UTC, James Cranch wrote: An attempt to compile it looks as follows: | $ gdc executable.d -o executable You need to pass all the modules you use to the compiler, or compile each one at a time and pass the resultant .o files to the linker together. |

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-17 Thread Matheus via Digitalmars-d-learn
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote: Let me throw this idea here: ... I usually do this too, I like to use struct and then in another language I use reflection do optimize binding. Anyway I understood all your code, except for this "alias code" auto NewWindow(

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-17 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 17, 2019 at 10:29:13AM +, John Burton via Digitalmars-d-learn wrote: [...] > Well window was just an example really, my real use case is a similar > object that needs a lot of configuration where mostly the default > works but you might want to override, and the config is needed

beginner's linking error

2019-01-17 Thread James Cranch via Digitalmars-d-learn
Hi all, I've just installed gdc from Debian Stable (gdc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516), and have been having linker errors when using writeln. A minimal nonworking example is as follows: I have a file library.d which contains the following: | module library; | | import

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-17 Thread John Burton via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 14:59:01 UTC, Kagamin wrote:> On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote: auto window = Window(title = "My Window", width = 1000, fullscreen = true); In this particular case I would make the constructor take 3 parameters - title, width and

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-17 Thread John Burton via Digitalmars-d-learn
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote: On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote: [...] Let me throw this idea here: struct Config { string title; int width; } struct Window { this(Config config) {

Re: Runtime heterogeneous collections?

2019-01-17 Thread Seb via Digitalmars-d-learn
On Thursday, 17 January 2019 at 02:27:20 UTC, Neia Neutuladh wrote: On Thu, 17 Jan 2019 02:21:21 +, Steven O wrote: I want to create a heterogeneous collection of red-black trees, and I can't seem to figure out if it's possible. RedBlackTree!int and RedBlackTree!string are entirely

Re: Runtime heterogeneous collections?

2019-01-17 Thread Dukc via Digitalmars-d-learn
On Thursday, 17 January 2019 at 02:27:20 UTC, Neia Neutuladh wrote: 1. Make a wrapper class. Now you can store Object[], or you can make a base class or base interface and use that. 2. Use Variant, which can wrap anything, or the related Algebraic, which can wrap a fixed collection of types.