Re: Runtime heterogeneous collections?

2019-01-16 Thread Neia Neutuladh via Digitalmars-d-learn
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 different types (they just happen to be generated from the same

Runtime heterogeneous collections?

2019-01-16 Thread Steven O via Digitalmars-d-learn
I want to create a heterogeneous collection of red-black trees, and I can't seem to figure out if it's possible. I can easily do: import std.container.rbtree; import std.typecons; void main() { alias Rec_type = Tuple!(int, "x", int, "y", int, "z"); RedBlackTree!Rec_type[1] test; }

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

2019-01-16 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote: As an example let's say I have a type 'Window' that represents a win32 window. I'd like to be able to construct an instance of the type with some optional parameters that default to some reasonable settings and create the

Re: unittest which uses a disk file

2019-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 17, 2019 at 12:58:20AM +, Victor Porton via Digitalmars-d-learn wrote: > This way I would make data duplication (data files distributed with > the source and the same data embedding as strings into my D sources). [...] You could use -J and string imports, perhaps? In any case,

Re: unittest which uses a disk file

2019-01-16 Thread Victor Porton via Digitalmars-d-learn
This way I would make data duplication (data files distributed with the source and the same data embedding as strings into my D sources). Note that the source is multilingual (I am currently working on a multi-language bindings of a C library).

Re: LDC2 with -fxray-instrument

2019-01-16 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 23:29:45 UTC, Johan Engelen wrote: On Wednesday, 16 January 2019 at 22:10:14 UTC, Johan Engelen wrote: On Wednesday, 16 January 2019 at 17:36:31 UTC, Márcio Martins wrote: On Tuesday, 15 January 2019 at 22:51:15 UTC, Johan Engelen wrote: What platform are you

Re: LDC2 with -fxray-instrument

2019-01-16 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 22:10:14 UTC, Johan Engelen wrote: On Wednesday, 16 January 2019 at 17:36:31 UTC, Márcio Martins wrote: On Tuesday, 15 January 2019 at 22:51:15 UTC, Johan Engelen wrote: What platform are you on? Linux x64 OK, so that should work. What is your testcase? Try

Re: problem extracting data from GtkSourceView using Gtkd

2019-01-16 Thread Chris Bare via Digitalmars-d-learn
Weird, the code does work in my program during startup, but when I call the same function from Application.onShutdown it gets the 0 results. Are the widgets destroyed before onShutdown? Here's a stripped down version my Application subclass: int main (string[] args) { auto

Re: LDC2 with -fxray-instrument

2019-01-16 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 17:36:31 UTC, Márcio Martins wrote: On Tuesday, 15 January 2019 at 22:51:15 UTC, Johan Engelen wrote: What platform are you on? Linux x64 OK, so that should work. What is your testcase? Try with `-fxray-instruction-threshold=1` to also instrument small

Re: unittest which uses a disk file

2019-01-16 Thread Neia Neutuladh via Digitalmars-d-learn
On Wed, 16 Jan 2019 21:07:24 +, Victor Porton wrote: > What is the rule for unittest which uses a file (containing example data > for testing) available only in the source distribution, not in binary > distribution? > > I am writing a library. The easy way of doing things is to define a

Re: unittest which uses a disk file

2019-01-16 Thread Victor Porton via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 21:07:24 UTC, Victor Porton wrote: What is the rule for unittest which uses a file (containing example data for testing) available only in the source distribution, not in binary distribution? I am writing a library. The library has also a file main.d which is

Re: unittest which uses a disk file

2019-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 16, 2019 at 09:07:24PM +, Victor Porton via Digitalmars-d-learn wrote: > What is the rule for unittest which uses a file (containing example > data for testing) available only in the source distribution, not in > binary distribution? > > I am writing a library. > > The library

unittest which uses a disk file

2019-01-16 Thread Victor Porton via Digitalmars-d-learn
What is the rule for unittest which uses a file (containing example data for testing) available only in the source distribution, not in binary distribution? I am writing a library. The library has also a file main.d which is compiled only in DUB "application" configuration (I use this

Re: pragma mangle on extern(C) in function body

2019-01-16 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 19:59:02 UTC, Steven Schveighoffer wrote: I'm guessing it's a missed case in the compiler, and not intentionally omitted. -Steve The workaround is quite silly. Seems like a parser issue. --- pragma(mangle, "Foo") extern(C) void foo(); mixin template T()

Re: pragma mangle on extern(C) in function body

2019-01-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/16/19 2:41 PM, Sebastiaan Koppe wrote: While it is perfectly ok to define an extern(C) function in a function method, I can't seem to get pragma(mangle, "...") on it to work. --- pragma(mangle, "Foo")    // Ok extern(C) void foo(); void main() {     pragma(mangle, "Bar")    // Error

Re: pragma mangle on extern(C) in function body

2019-01-16 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 19:41:04 UTC, Sebastiaan Koppe wrote: While it is perfectly ok to define an extern(C) function in a function method, I can't seem to get pragma(mangle, "...") on it to work. --- pragma(mangle, "Foo")// Ok extern(C) void foo(); void main() {

pragma mangle on extern(C) in function body

2019-01-16 Thread Sebastiaan Koppe via Digitalmars-d-learn
While it is perfectly ok to define an extern(C) function in a function method, I can't seem to get pragma(mangle, "...") on it to work. --- pragma(mangle, "Foo")// Ok extern(C) void foo(); void main() { pragma(mangle, "Bar")// Error extern(C) void bar(); } --- Any idea

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 16, 2019 at 06:25:48PM +, bauss via Digitalmars-d-learn wrote: [...] > I'm aware of how to do it manually as I already stated I went with a > similar approach. > > There should just be something standard for it and uniq should have an > overload or something that allows for

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread bauss via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 18:20:57 UTC, H. S. Teoh wrote: T I'm aware of how to do it manually as I already stated I went with a similar approach. There should just be something standard for it and uniq should have an overload or something that allows for another behavior that

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread H. S. Teoh via Digitalmars-d-learn
De-duplicating a range that's not necessarily sorted seems to be a pretty common task, so here's a generic function for whoever else might want to do this: import std.range.primitives; auto deduplicate(R)(R range) if (isInputRange!R) {

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 16, 2019 at 04:37:21PM +, bauss via Digitalmars-d-learn wrote: > On Wednesday, 16 January 2019 at 16:35:04 UTC, H. S. Teoh wrote: [...] > > It's not trivial. In order for the computer to know whether or not > > the i'th element should be excluded, it needs to know what has come > >

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread bauss via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 17:28:14 UTC, Alex wrote: On Wednesday, 16 January 2019 at 16:52:50 UTC, bauss wrote: The problem with sorting is that the following: [3,5,6,6,2,1,2,5,3] will then become [1,2,3,5,6] or [6,5,3,2,1] and not: [3,5,6,2,1] which would be what you'd wanna use

Re: LDC2 with -fxray-instrument

2019-01-16 Thread Márcio Martins via Digitalmars-d-learn
On Tuesday, 15 January 2019 at 22:51:15 UTC, Johan Engelen wrote: What platform are you on? Linux x64

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

2019-01-16 Thread Neia Neutuladh via Digitalmars-d-learn
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. I'm glad we're no longer in those

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread Alex via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 16:52:50 UTC, bauss wrote: The problem with sorting is that the following: [3,5,6,6,2,1,2,5,3] will then become [1,2,3,5,6] or [6,5,3,2,1] and not: [3,5,6,2,1] which would be what you'd wanna use in some situations. The important thing to know here is

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

2019-01-16 Thread Vijay Nayar via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 17:01:06 UTC, Steven Schveighoffer wrote: On 1/14/19 2:30 PM, Neia Neutuladh wrote: On Mon, 14 Jan 2019 09:10:39 +, Vijay Nayar wrote: a.foo(1); // issues runtime error (instead of calling A.foo(int)) Calling the function doesn't issue any sort of

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

2019-01-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/14/19 2:30 PM, Neia Neutuladh wrote: On Mon, 14 Jan 2019 09:10:39 +, Vijay Nayar wrote: a.foo(1); // issues runtime error (instead of calling A.foo(int)) Calling the function doesn't issue any sort of error. Overriding one overload without overloading or explicitly aliasing in

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread bauss via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 16:40:34 UTC, Alex wrote: On Wednesday, 16 January 2019 at 16:21:12 UTC, bauss wrote: On Wednesday, 16 January 2019 at 16:12:28 UTC, H. S. Teoh wrote: On Wed, Jan 16, 2019 at 03:57:49PM +, bauss via Digitalmars-d-learn wrote: Is there a way to achieve the

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread Alex via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 16:21:12 UTC, bauss wrote: On Wednesday, 16 January 2019 at 16:12:28 UTC, H. S. Teoh wrote: On Wed, Jan 16, 2019 at 03:57:49PM +, bauss via Digitalmars-d-learn wrote: Is there a way to achieve the following: [...] enum Foo : string { a = "aa", b =

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread bauss via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 16:35:04 UTC, H. S. Teoh wrote: On Wed, Jan 16, 2019 at 04:21:12PM +, bauss via Digitalmars-d-learn wrote: On Wednesday, 16 January 2019 at 16:12:28 UTC, H. S. Teoh wrote: [...] > .uniq only works on adjacent identical elements. You should > sort your

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 16, 2019 at 04:21:12PM +, bauss via Digitalmars-d-learn wrote: > On Wednesday, 16 January 2019 at 16:12:28 UTC, H. S. Teoh wrote: [...] > > .uniq only works on adjacent identical elements. You should sort > > your array first. > > > > If you need to preserve the original order

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread bauss via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 16:12:28 UTC, H. S. Teoh wrote: On Wed, Jan 16, 2019 at 03:57:49PM +, bauss via Digitalmars-d-learn wrote: Is there a way to achieve the following: [...] enum Foo : string { a = "aa", b = "bb", c = "cc" } void main() { auto a = [Foo.a,

Re: uniq and array of enum members (That are all strings)

2019-01-16 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jan 16, 2019 at 03:57:49PM +, bauss via Digitalmars-d-learn wrote: > Is there a way to achieve the following: [...] > enum Foo : string > { > a = "aa", > b = "bb", > c = "cc" > } > > void main() > { > auto a = [Foo.a, Foo.b, Foo.a, Foo.b, Foo.c]; > > auto b =

uniq and array of enum members (That are all strings)

2019-01-16 Thread bauss via Digitalmars-d-learn
Is there a way to achieve the following: import std.stdio; import std.algorithm : uniq; import std.array : array; enum Foo : string { a = "aa", b = "bb", c = "cc" } void main() { auto a = [Foo.a, Foo.b, Foo.a, Foo.b, Foo.c]; auto b = a.uniq; writeln(b); //

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

2019-01-16 Thread Kagamin via Digitalmars-d-learn
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 height. Full screen is a rare functionality and shouldn't

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

2019-01-16 Thread John Burton via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 11:21:53 UTC, Dukc wrote: On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote: This is ok, but I'm not so keen on separating the creation and construction like this. Is there a better way that's not ugly? You can make the constructor a template

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

2019-01-16 Thread JN via Digitalmars-d-learn
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(); You can slightly modify it to the way APIs like DirectX or Vulkan do it. auto windowinfo = WindowInfo(); windowinfo.title = "My

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

2019-01-16 Thread Dukc via Digitalmars-d-learn
On Wednesday, 16 January 2019 at 11:21:53 UTC, Dukc wrote: a template that takes a single struct of arbitrary, meant "of arbitrary type"

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

2019-01-16 Thread Dukc via Digitalmars-d-learn
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote: This is ok, but I'm not so keen on separating the creation and construction like this. Is there a better way that's not ugly? You can make the constructor a template that takes a single struct of arbitrary, and inspects (at