Re: Stacktraces in static constructors

2016-05-03 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 12:31:10 UTC, Benjamin Thaut wrote: I assume this is on windows? Yes its a known issue (I know No, the problem occurs on my Linux aswell.

Code example for function/delegate as template argument ?

2016-05-03 Thread chmike via Digitalmars-d-learn
Hello, I failed to find some code example for a template class/struct that accept a function/delegate as template argument. All examples I could find use simple value types like int or double. I piggy bag another question. Defining a function/delegate as function argument is shown in exampl

Re: Setting a list of values

2016-05-03 Thread Joel via Digitalmars-d-learn
On Sunday, 1 May 2016 at 05:42:00 UTC, Ali Çehreli wrote: On 04/30/2016 10:05 PM, Joel wrote: > This has no effect: > _bars.each!(a => { a._plots.fillColor = Color(255, 180, 0); }); This is a common issue especially for people who know lambdas from other languages. :) Your lambda does not do

Re: undefined identifier 'size_t'

2016-05-03 Thread Joshua Hodkinson via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 01:44:31 UTC, Adam D. Ruppe wrote: Is there a file called object.d in your current directory? Not anymore, Thanks for pointing that out

Re: undefined identifier 'size_t'

2016-05-03 Thread Adam D. Ruppe via Digitalmars-d-learn
Is there a file called object.d in your current directory?

undefined identifier 'size_t'

2016-05-03 Thread Joshua Hodkinson via Digitalmars-d-learn
I have run into an issue compiling with dmd (version 2.071.0), it seems that the 'size_t' alias isn't resolving properly. I was wondering if someone has run into this before and if this is a bug or something I'm doing wrong? My call to dmd is: ..dmd2\windows\bin\dmd.exe -run hello.d -de -w -un

Re: what is equivalent to template template

2016-05-03 Thread Erik Smith via Digitalmars-d-learn
You're close. An `alias` template parameter can be any symbol, including a template. But you can't pass in a template as a runtime parameter, so having `F f` in your parameters list is wrong (there's nothing to pass anyway; you already have the template, which is F). static void call(alias

Re: constructed variadic call

2016-05-03 Thread Erik Smith via Digitalmars-d-learn
I don't think it's possible to call a vararg function whose number of arguments is only known at runtime, for the same reasons it is impossible in C [1]. Your switch statement is probably the best you can do, other than rewriting the API to not use varargs (which, depending on what the functi

Re: what is equivalent to template template

2016-05-03 Thread Alex Parrill via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 21:31:35 UTC, Erik Smith wrote: C++ has template templates. I'm not sure how to achieve the same effect where (in example below) the template function myVariadic is passed to another function. void myVaridatic(A...)(A a) {} static void call(alias F,A

Re: what is equivalent to template template

2016-05-03 Thread ag0aep6g via Digitalmars-d-learn
On 03.05.2016 23:31, Erik Smith wrote: void myVaridatic(A...)(A a) {} Aside: I think it's "variadic", not "varidatic". static void call(alias F,A...)(F f,A a) { static void call(alias f, A...)(A a) { f(a); } void foo() { call

Re: constructed variadic call

2016-05-03 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 2 May 2016 at 18:22:52 UTC, Erik Smith wrote: Is there way to construct an "argument pack" from a non-static array (like the switch below)? I need to transport a variadic call through a void*. switch (a.length) { case 1: foo(a[1]); break; case 2: foo(a[1], a[2]); break; case

what is equivalent to template template

2016-05-03 Thread Erik Smith via Digitalmars-d-learn
C++ has template templates. I'm not sure how to achieve the same effect where (in example below) the template function myVariadic is passed to another function. void myVaridatic(A...)(A a) {} static void call(alias F,A...)(F f,A a) { f(a); } void f

Re: constructed variadic call

2016-05-03 Thread Erik Smith via Digitalmars-d-learn
On Monday, 2 May 2016 at 18:56:59 UTC, Stefan Koch wrote: On Monday, 2 May 2016 at 18:22:52 UTC, Erik Smith wrote: Is there way to construct an "argument pack" from a non-static array (like the switch below)? I need to transport a variadic call through a void*. switch (a.length) { case 1:

Re: Strange stack variable corruption error after calling extern(C) function

2016-05-03 Thread cc via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 12:48:37 UTC, Benjamin Thaut wrote: It seems that one of the fmod functions you declared is not correct. Either the fmod api is not using the c calling convention or you made a mistake when declaring the paramters of the fmod functions. You should double check that the

Re: what is missing here?

2016-05-03 Thread Jonathan Villa via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 16:13:07 UTC, ag0aep6g wrote: On 03.05.2016 18:03, Jonathan Villa wrote: Types are not values. You cannot return a type from a function. Use aliases instead: alias user_id_t = typeof(dummy1); alias name_t = typeof(dummy2); /* ... etc ... *

Re: what is missing here?

2016-05-03 Thread ag0aep6g via Digitalmars-d-learn
On 03.05.2016 18:03, Jonathan Villa wrote: public final class accounts { public: static table_user user; } public final class table_user { private: static uint32 dummy1; static string dummy2; static DateTime dummy3; static ubyte dummy4;

what is missing here?

2016-05-03 Thread Jonathan Villa via Digitalmars-d-learn
public final class accounts { public: static table_user user; } public final class table_user { private: static uint32 dummy1; static string dummy2; static DateTime dummy3; static ubyte dummy4; public: static @property auto user_id_t() {

Re: inferred size for static array initialization

2016-05-03 Thread Basile B. via Digitalmars-d-learn
On Monday, 2 May 2016 at 17:43:56 UTC, Namespace wrote: I still like auto s(T, size_t n)(T[n] arr) { return arr; } Wooah, this trick is awesome. But actually it does the same thing that what I've proposed before. Exactly the same code is generated. So I'd say that it's rather a

Re: ubyte[] -> immutable(ubyte)[]

2016-05-03 Thread vino via Digitalmars-d-learn
On Friday, 10 September 2010 at 15:15:38 UTC, Andrej Mitrovic wrote: Yeah, one would think the destination is on the left (just like the standard C way of doing it), but it's not. I checked it in the docs and the source. And idup works, thanks. Kagamin Wrote: Andrej Mitrovic Wrote: > fo

Re: DlangUI FileDialog not working

2016-05-03 Thread Vadim Lopatin via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 06:14:25 UTC, stunaep wrote: FileDialog is showing a blank white window for me. Only tested on windows 7 so far, but if I run dmledit, the filedialog on there works fine. It's weird because I am using almost exactly the same code. Try fetch recent dlangui version (du

Re: struct cannot deduce function from argument types

2016-05-03 Thread chmike via Digitalmars-d-learn
Oops! Stupid of me. There were three bugs in the code. Correct code is as follow: import std.stdio; class Data { string m = "Hello world !"; } struct IdxElem(D) { bool inUse; D data; } IdxElem!(Data)[string] idx; void main() { idx["test1"] = IdxElem!Data(true, new Data);

struct cannot deduce function from argument types

2016-05-03 Thread chmike via Digitalmars-d-learn
The following code does not compile and I don't understand why. import std.stdio; class Data { string m = "Hello world !"; } struct IdxElem(D) { bool inUse; D data; } IdxElem!Data[string] idx; void main() { idx["test1"] = IdxElem(true, new Data); idx["test2"] = IdxElem(fa

Re: How can I save a class use the RedBlackTree?

2016-05-03 Thread Meta via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 12:12:04 UTC, Jonathan M Davis wrote: On Tue, 3 May 2016 11:37:13 +0200 Steven Schveighoffer via Digitalmars-d-learn wrote: bleh, Object.opCmp only works with mutable objects. Which means RedBlackTree cannot work with objects because it uses inout to ensure your objec

Re: Strange stack variable corruption error after calling extern(C) function

2016-05-03 Thread Benjamin Thaut via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 11:32:31 UTC, cc wrote: Hello, I've been encountering a strange problem that seems to occur after calling some external C functions. I've been working on a program that incorporates the FMOD C API for playing sound, with a simple D binding based off the C headers, an

Re: Stacktraces in static constructors

2016-05-03 Thread Benjamin Thaut via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 10:52:20 UTC, Nordlöw wrote: On Tuesday, 3 May 2016 at 10:48:51 UTC, Nordlöw wrote: AFAICT, stacktraces are not emitted with debug information when Should be static shared module constructors. errors occur in static module constructors. Is this a know bug? My stac

Re: How can I save a class use the RedBlackTree?

2016-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tue, 3 May 2016 11:37:13 +0200 Steven Schveighoffer via Digitalmars-d-learn wrote: > bleh, Object.opCmp only works with mutable objects. Which means > RedBlackTree cannot work with objects because it uses inout to ensure > your objects are not modified (since 2.068) > > It doesn't work with con

Strange stack variable corruption error after calling extern(C) function

2016-05-03 Thread cc via Digitalmars-d-learn
Hello, I've been encountering a strange problem that seems to occur after calling some external C functions. I've been working on a program that incorporates the FMOD C API for playing sound, with a simple D binding based off the C headers, and actually everything works more or less fine, I've

Re: Stacktraces in static constructors

2016-05-03 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 3 May 2016 at 10:48:51 UTC, Nordlöw wrote: AFAICT, stacktraces are not emitted with debug information when Should be static shared module constructors. errors occur in static module constructors. Is this a know bug? My stacktraces contain no information of the call stack so it's

Stacktraces in static constructors

2016-05-03 Thread Nordlöw via Digitalmars-d-learn
AFAICT, stacktraces are not emitted with debug information when errors occurr in static module constructors. Is this a know bug? This is a big problem for me because, in my application, I've realized unittests as functions called from within static shared module constructors to elide the probl

Re: How can I save a class use the RedBlackTree?

2016-05-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/3/16 5:10 AM, Dsby wrote: this is the test Code: import std.container.rbtree; import std.stdio; class TClass { int i; } void main() { RedBlackTree!(TClass) list = new RedBlackTree!(TClass)(); auto t = new TClass(); list.insert(t); writeln("The rbtree length is ",