Re: SDL and new Thread open two windows

2017-09-01 Thread SrMordred via Digitalmars-d-learn
On Saturday, 2 September 2017 at 03:47:24 UTC, Adam D. Ruppe wrote: On Saturday, 2 September 2017 at 03:41:47 UTC, SrMordred wrote: Whats going on , and how to prevent this ? Are you using a static this anywhere? Hm, right. I was constructing the window there. Forgot that static this will

Re: SDL and new Thread open two windows

2017-09-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 2 September 2017 at 03:41:47 UTC, SrMordred wrote: Whats going on , and how to prevent this ? Are you using a static this anywhere?

SDL and new Thread open two windows

2017-09-01 Thread SrMordred via Digitalmars-d-learn
Im using SDL2 with derelict, on ubuntu. Last DMD. When using spawn or new Thread like : spawn( (){ while(true){ Thread.sleep(500.msecs); }); the program open two SDL windows. Whats going on , and how to prevent this ?

Re: 24-bit int

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
On Saturday, 2 September 2017 at 02:37:08 UTC, Mike Parker wrote: On Saturday, 2 September 2017 at 01:19:52 UTC, EntangledQuanta wrote: The whole point is so that there is no wasted space, so if it requires that then it's not a waste of space but a bug. Audio that is in24 is 3 bytes per

Re: 24-bit int

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
On Saturday, 2 September 2017 at 02:49:41 UTC, Ilya Yaroshenko wrote: On Friday, 1 September 2017 at 19:39:14 UTC, EntangledQuanta wrote: Is there a way to create a 24-bit int? One that for all practical purposes acts as such? This is for 24-bit stuff like audio. It would respect endianness,

Re: 24-bit int

2017-09-01 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Friday, 1 September 2017 at 19:39:14 UTC, EntangledQuanta wrote: Is there a way to create a 24-bit int? One that for all practical purposes acts as such? This is for 24-bit stuff like audio. It would respect endianness, allow for arrays int24[] that work properly, etc. Hi, Probably you

Re: 24-bit int

2017-09-01 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 2 September 2017 at 01:19:52 UTC, EntangledQuanta wrote: The whole point is so that there is no wasted space, so if it requires that then it's not a waste of space but a bug. Audio that is in24 is 3 bytes per sample, not 4. Every 3 bytes are a sample, not every 3 out of 4.

Re: Template substitution for function parameters

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 1 September 2017 at 11:33:15 UTC, Biotronic wrote: On Friday, 1 September 2017 at 10:15:09 UTC, Nicholas Wilson wrote: So I have the following types struct DevicePointer(T) { T* ptr; } struct Buffer(T) { void* driverObject; T[] hostMemory; } and a function auto

Re: replace switch for mapping

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
I came up with a library solution that isn't pretty ;/ I offer it up to the gods, but being gods, they probably don't care. template EnumMapper(alias func, string[] args, eT...) { import std.meta, std.typecons, std.traits, std.string, std.algorithm, std.array, std.conv; private

Re: 24-bit int

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
On Saturday, 2 September 2017 at 00:43:00 UTC, Nicholas Wilson wrote: On Friday, 1 September 2017 at 22:10:43 UTC, Biotronic wrote: On Friday, 1 September 2017 at 19:39:14 UTC, EntangledQuanta wrote: Is there a way to create a 24-bit int? One that for all practical purposes acts as such? This

Re: 24-bit int

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 1 September 2017 at 22:10:43 UTC, Biotronic wrote: On Friday, 1 September 2017 at 19:39:14 UTC, EntangledQuanta wrote: Is there a way to create a 24-bit int? One that for all practical purposes acts as such? This is for 24-bit stuff like audio. It would respect endianness, allow for

Re: Bug in D!!!

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
On Friday, 1 September 2017 at 23:25:04 UTC, Jesse Phillips wrote: I've love being able to inherit and override generic functions in C#. Unfortunately C# doesn't use templates and I hit so many other issues where Generics just suck. I don't think it is appropriate to dismiss the need for the

Re: Bug in D!!!

2017-09-01 Thread Jesse Phillips via Digitalmars-d-learn
I've love being able to inherit and override generic functions in C#. Unfortunately C# doesn't use templates and I hit so many other issues where Generics just suck. I don't think it is appropriate to dismiss the need for the compiler to generate a virtual function for every instantiated T,

Re: get parameter names

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
On Friday, 1 September 2017 at 22:21:18 UTC, Biotronic wrote: On Friday, 1 September 2017 at 20:58:20 UTC, EntangledQuanta wrote: template(A, B...) { auto foo(C...)(C c) { ... get c's parameter names, should be alpha, beta } } foo!(., .)(alpha, beta) I need the actual

Re: 24-bit int

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
On Friday, 1 September 2017 at 22:10:43 UTC, Biotronic wrote: On Friday, 1 September 2017 at 19:39:14 UTC, EntangledQuanta wrote: [...] I haven't looked at endianness beyond it working on my computer. If you have special needs in that regard, consider this a starting point: [...]

Re: get parameter names

2017-09-01 Thread Biotronic via Digitalmars-d-learn
On Friday, 1 September 2017 at 20:58:20 UTC, EntangledQuanta wrote: template(A, B...) { auto foo(C...)(C c) { ... get c's parameter names, should be alpha, beta } } foo!(., .)(alpha, beta) I need the actual identifiers passed to foo. I can get the types(obviously C) but when

Re: 24-bit int

2017-09-01 Thread Biotronic via Digitalmars-d-learn
On Friday, 1 September 2017 at 19:39:14 UTC, EntangledQuanta wrote: Is there a way to create a 24-bit int? One that for all practical purposes acts as such? This is for 24-bit stuff like audio. It would respect endianness, allow for arrays int24[] that work properly, etc. I haven't looked at

Re: -betterC not working

2017-09-01 Thread SrMordred via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 23:12:07 UTC, SrMordred wrote: On Wednesday, 30 August 2017 at 22:45:27 UTC, Adam D. Ruppe wrote: On Wednesday, 30 August 2017 at 22:18:07 UTC, SrMordred wrote: DMD64 D Compiler v2.075.1 -betterC as described recently is not yet released.

Re: Help Required on Getopt

2017-09-01 Thread Jon Degenhardt via Digitalmars-d-learn
On Friday, 1 September 2017 at 19:04:39 UTC, Daniel Kozak wrote: I have same issue. How this help you? Catching exception does not help. How do I catch exception and still print help message? Your are correct, sorry about that. What my response showed is how to avoid printing the full stack

Re: get parameter names

2017-09-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 01, 2017 20:58:20 EntangledQuanta via Digitalmars-d- learn wrote: > template(A, B...) > { > auto foo(C...)(C c) > { > ... get c's parameter names, should be alpha, beta > } > } > > > foo!(., .)(alpha, beta) > > I need the actual identifiers passed to foo. I

Easy bug: reference to local variable

2017-09-01 Thread Ali Çehreli via Digitalmars-d-learn
Nothing new here but I almost fell prey to this bug today. Spot the bug: import std.stdio; import std.range; int[3] bar() { return [ 1, 2, 3 ]; } auto foo() { auto a = bar(); return zip(a[], a[]); } void main() { writeln(foo()); } In the real code, bar() was a call to

get parameter names

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
template(A, B...) { auto foo(C...)(C c) { ... get c's parameter names, should be alpha, beta } } foo!(., .)(alpha, beta) I need the actual identifiers passed to foo. I can get the types(obviously C) but when I try to get the identifier names(__traits(identifier or other

Re: Simplest multithreading example

2017-09-01 Thread ag0aep6g via Digitalmars-d-learn
On 09/01/2017 07:27 AM, Brian wrote: double [] hugeCalc(int i){ // Code that takes a long time } so if I do double[][int] _hugeCalcCache; foreach(i ; I) _hugeCalcCache[i] = hugeCalc(i); of course the required time is I.length * (a long time), so I wanted to shorten this by

Re: Bug in D!!!

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
This happens when building, not running. This might be a Visual D issue as when I use dmd from the command line, it works fine ;/

24-bit int

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
Is there a way to create a 24-bit int? One that for all practical purposes acts as such? This is for 24-bit stuff like audio. It would respect endianness, allow for arrays int24[] that work properly, etc.

Re: Bug in D!!!

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
On Friday, 1 September 2017 at 19:25:53 UTC, Adam D Ruppe wrote: On Friday, 1 September 2017 at 18:17:22 UTC, EntangledQuanta wrote: I get an access violation, changed the code to What is the rest of your code? access violation usually means you didn't new the class... No, that is the

Re: traits for function having actual source declaration?

2017-09-01 Thread bitwise via Digitalmars-d-learn
On Friday, 1 September 2017 at 18:06:04 UTC, Jonathan M Davis wrote: [...] You can use std.meta.Filter if you need to filter anything out of an AliasSeq like this, and whether you should be filtering out those functions is highly dependent on what you're doing - e.g. sometimes, you really

Re: Bug in D!!!

2017-09-01 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 1 September 2017 at 18:17:22 UTC, EntangledQuanta wrote: I get an access violation, changed the code to What is the rest of your code? access violation usually means you didn't new the class...

Re: Help Required on Getopt

2017-09-01 Thread Daniel Kozak via Digitalmars-d-learn
I have same issue. How this help you? Catching exception does not help. How do I catch exception and still print help message? Dne 1. 9. 2017 8:10 odpoledne napsal uživatel "Vino.B via Digitalmars-d-learn" : On Friday, 1 September 2017 at 17:23:01 UTC, Jon

Re: Bug in D!!!

2017-09-01 Thread EntangledQuanta via Digitalmars-d-learn
On Friday, 1 September 2017 at 15:24:39 UTC, Adam D. Ruppe wrote: static foreach is now in the new release! You can now do stuff like: --- alias I(A...) = A; interface Foo { static foreach(T; I!(int, float)) void set(T t); // define virt funcs for a list of types }

Re: Help Required on Getopt

2017-09-01 Thread Vino.B via Digitalmars-d-learn
On Friday, 1 September 2017 at 17:23:01 UTC, Jon Degenhardt wrote: On Friday, 1 September 2017 at 13:13:39 UTC, Vino.B wrote: Hi All, When i run the below program without any arguments "D1.d -r" it is throwing error, but i need it to show the help menu [snip...] Hi Vino, To get good

Re: traits for function having actual source declaration?

2017-09-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 01, 2017 14:38:38 bitwise via Digitalmars-d-learn wrote: > When I'm using __traits(allMembers), I get a all the invisible > functions added by the compiler as well "__ctor", "__xdtor", > "__cpctor", etc.. > > Is there a way to filter them out? You can use std.meta.Filter if

Re: Simplest multithreading example

2017-09-01 Thread Ali Çehreli via Digitalmars-d-learn
On 08/31/2017 10:27 PM, Brian wrote: > the 'real' problem is trying > to split a huge calculation to different threads. I still think you can take advantage of std.parallelism: https://dlang.org/phobos/std_parallelism.html Unfortunately, its features like asyncBuf, map, and amap do not

Re: traits for function having actual source declaration?

2017-09-01 Thread bitwise via Digitalmars-d-learn
On Friday, 1 September 2017 at 17:26:11 UTC, ketmar wrote: [...] they *should* listen. anyone who doesn't just aksing for troubles, and i see no reason to guard 'em further. Yeah...eventually came to the same conclusion ;) Thanks

Re: traits for function having actual source declaration?

2017-09-01 Thread ketmar via Digitalmars-d-learn
bitwise wrote: On Friday, 1 September 2017 at 14:38:38 UTC, bitwise wrote: When I'm using __traits(allMembers), I get a all the invisible functions added by the compiler as well "__ctor", "__xdtor", "__cpctor", etc.. Is there a way to filter them out? dlang's "Lexical" page says:

Re: Help Required on Getopt

2017-09-01 Thread Jon Degenhardt via Digitalmars-d-learn
On Friday, 1 September 2017 at 13:13:39 UTC, Vino.B wrote: Hi All, When i run the below program without any arguments "D1.d -r" it is throwing error, but i need it to show the help menu [snip...] Hi Vino, To get good error message behavior you need to put the construct in a try-catch

Re: Bug in D!!!

2017-09-01 Thread Adam D. Ruppe via Digitalmars-d-learn
static foreach is now in the new release! You can now do stuff like: --- alias I(A...) = A; interface Foo { static foreach(T; I!(int, float)) void set(T t); // define virt funcs for a list of types } class Ass : Foo { static foreach(T; I!(int, float))

Re: vibed services stop response after several days of work

2017-09-01 Thread Mike Wey via Digitalmars-d-learn
On 01-09-17 10:01, Suliman wrote: I got same problem on Windows Server 2016 and on Linux Debian 8.5. I have few very simple backend based on vibed 0.8.1, compiler dmd 2.075.1. nginx servise is do port forwarding. Nothing more is used. After several days of working I am begining to get "502 Bad

Re: vibed services stop response after several days of work

2017-09-01 Thread Suliman via Digitalmars-d-learn
It's seems that it's error in libevent on Linux. I tried to add to dub.sdl: versions "libasync" and it's seems that not it's working (but I need more time to test).

Re: traits for function having actual source declaration?

2017-09-01 Thread bitwise via Digitalmars-d-learn
On Friday, 1 September 2017 at 14:38:38 UTC, bitwise wrote: When I'm using __traits(allMembers), I get a all the invisible functions added by the compiler as well "__ctor", "__xdtor", "__cpctor", etc.. Is there a way to filter them out? dlang's "Lexical" page says: "Identifiers starting

traits for function having actual source declaration?

2017-09-01 Thread bitwise via Digitalmars-d-learn
When I'm using __traits(allMembers), I get a all the invisible functions added by the compiler as well "__ctor", "__xdtor", "__cpctor", etc.. Is there a way to filter them out?

Help Required on Getopt

2017-09-01 Thread Vino.B via Digitalmars-d-learn
Hi All, When i run the below program without any arguments "D1.d -r" it is throwing error, but i need it to show the help menu Program: import std.stdio; import std.getopt; string r; void main (string[] args) { getopt(args, std.getopt.config.caseInsensitive,

Re: Valid File Path

2017-09-01 Thread Vino.B via Digitalmars-d-learn
On Thursday, 31 August 2017 at 23:45:01 UTC, Jonathan M Davis wrote: On Thursday, August 31, 2017 23:23:17 Vino via Digitalmars-d-learn wrote: [...] And why would that not be valid? isValidPath and isValidFilename are quite specific about what they think are valid path/file names, and

Re: gcd with doubles

2017-09-01 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 1 September 2017 at 09:33:08 UTC, Alex wrote: On Sunday, 27 August 2017 at 23:13:24 UTC, Moritz Maxeiner wrote: On Sunday, 27 August 2017 at 19:47:59 UTC, Alex wrote: [...] To expand on the earlier workaround: You can also adapt a floating point to string algorithm in order to

Re: Template substitution for function parameters

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 1 September 2017 at 11:33:15 UTC, Biotronic wrote: On Friday, 1 September 2017 at 10:15:09 UTC, Nicholas Wilson wrote: So I have the following types struct DevicePointer(T) { T* ptr; } struct Buffer(T) { void* driverObject; T[] hostMemory; } and a function auto

Re: Template substitution for function parameters

2017-09-01 Thread Biotronic via Digitalmars-d-learn
On Friday, 1 September 2017 at 10:15:09 UTC, Nicholas Wilson wrote: So I have the following types struct DevicePointer(T) { T* ptr; } struct Buffer(T) { void* driverObject; T[] hostMemory; } and a function auto enqueue(alias k)(HostArgsOf!k) { ... } where k would be a function like

Re: Template substitution for function parameters

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 1 September 2017 at 10:58:51 UTC, user1234 wrote: On Friday, 1 September 2017 at 10:15:09 UTC, Nicholas Wilson wrote: So I have the following types ... i.e. it substitutes the template DevicePointer for the template Buffer in Parameters!foo, The templates can be assumed to not be

Re: Bug in D!!!

2017-09-01 Thread Biotronic via Digitalmars-d-learn
On Thursday, 31 August 2017 at 15:48:12 UTC, EntangledQuanta wrote: On Thursday, 31 August 2017 at 10:34:14 UTC, Kagamin wrote: On Thursday, 31 August 2017 at 00:49:22 UTC, EntangledQuanta wrote: I've already implemented a half ass library solution. It can be improved alot. Then, by all

Re: Template substitution for function parameters

2017-09-01 Thread user1234 via Digitalmars-d-learn
On Friday, 1 September 2017 at 10:15:09 UTC, Nicholas Wilson wrote: So I have the following types ... i.e. it substitutes the template DevicePointer for the template Buffer in Parameters!foo, The templates can be assumed to not be nested templates, i.e. DevicePointer!(DevicePointer!(float))

Re: vibed services stop response after several days of work

2017-09-01 Thread Suliman via Digitalmars-d-learn
On Friday, 1 September 2017 at 08:01:24 UTC, Suliman wrote: I got same problem on Windows Server 2016 and on Linux Debian 8.5. I have few very simple backend based on vibed 0.8.1, compiler dmd 2.075.1. nginx servise is do port forwarding. Nothing more is used. After several days of working I

Re: Synax for variadic template

2017-09-01 Thread Alex via Digitalmars-d-learn
On Friday, 1 September 2017 at 10:01:16 UTC, Nicholas Wilson wrote: b.arr refers to an `(AliasSeq!(int, double))[]`, so with `b.arr[0] ~= 5;` you are trying to append a integer to an array of pairs of ints and doubles, which you can't do. b.arr[0] ~= ElementType!(typeof(b.arr))(5,42.0);

Template substitution for function parameters

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
So I have the following types struct DevicePointer(T) { T* ptr; } struct Buffer(T) { void* driverObject; T[] hostMemory; } and a function auto enqueue(alias k)(HostArgsOf!k) { ... } where k would be a function like void foo( DevicePointer!float a, float b , int c) { ... } How can I

Re: Synax for variadic template

2017-09-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 1 September 2017 at 09:38:59 UTC, Alex wrote: Hi all! Say, I have struct A(T...) { T arr; } struct B(T...) { T[] arr; } void main() { A!(int[], double[]) a; a.arr[0] ~= 5; a.arr[0] ~= 6; static assert(!__traits(compiles, a.arr[0] ~=

Synax for variadic template

2017-09-01 Thread Alex via Digitalmars-d-learn
Hi all! Say, I have struct A(T...) { T arr; } struct B(T...) { T[] arr; } void main() { A!(int[], double[]) a; a.arr[0] ~= 5; a.arr[0] ~= 6; static assert(!__traits(compiles, a.arr[0] ~= 3.5)); a.arr[1] ~= 19.8;

Re: gcd with doubles

2017-09-01 Thread Alex via Digitalmars-d-learn
On Sunday, 27 August 2017 at 23:13:24 UTC, Moritz Maxeiner wrote: On Sunday, 27 August 2017 at 19:47:59 UTC, Alex wrote: [...] To expand on the earlier workaround: You can also adapt a floating point to string algorithm in order to dynamically determine an upper bound on the number of after

Re: Parse tree node allocator

2017-09-01 Thread Per Nordlöw via Digitalmars-d-learn
On Thursday, 31 August 2017 at 15:55:26 UTC, Stefan Koch wrote: On Thursday, 31 August 2017 at 15:43:05 UTC, Per Nordlöw wrote: Which allocator is best suited for allocating tree nodes (all of equal size around 40-60 bytes in size) in one shot and then delete them all in one go? My use case is

vibed services stop response after several days of work

2017-09-01 Thread Suliman via Digitalmars-d-learn
I got same problem on Windows Server 2016 and on Linux Debian 8.5. I have few very simple backend based on vibed 0.8.1, compiler dmd 2.075.1. nginx servise is do port forwarding. Nothing more is used. After several days of working I am begining to get "502 Bad Gateway" error. The service is