Why does BinaryHeap sometime cause compile-error in foeach?

2017-09-30 Thread Shigeki Karita via Digitalmars-d-learn
https://dpaste.dzfl.pl/cd605899d050 why this code cannot convert to foreach (over Structs and Classes with Ranges). auto h = new BinaryHeap!(int[])(new int[0]); typeof(h).stringof.writeln; static assert(isInputRange!(typeof(h))); h.insert(3); h.insert(1); h.insert(2);

Re: Why does BinaryHeap sometime cause compile-error in foeach?

2017-09-30 Thread user1234 via Digitalmars-d-learn
On Saturday, 30 September 2017 at 09:27:23 UTC, Shigeki Karita wrote: https://dpaste.dzfl.pl/cd605899d050 why this code cannot convert to foreach (over Structs and Classes with Ranges). auto h = new BinaryHeap!(int[])(new int[0]); typeof(h).stringof.writeln; static

Re: static this not run?

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 30 September 2017 at 08:49:14 UTC, user1234 wrote: On Saturday, 30 September 2017 at 06:15:41 UTC, Nicholas Wilson wrote: No "initialising onError", the static this is not even being run! I'm using LDC master. See also https://github.com/libmir/dcompute/issues/32 LDC 1.4, DMD

Re: core.stdc.time

2017-09-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-09-30 08:56, Tony wrote: The documentation says: -- This module contains bindings to selected types and functions from the standard C header . Note that this is not automatically generated, and may omit some types/functions from the

Re: Creating a dynamic library

2017-09-30 Thread Mike Wey via Digitalmars-d-learn
On 30-09-17 03:27, Tony wrote: One thing I picked up from SCons is creating dynamic object files with a .os extension and static object files with the standard .o extension. That way they can be compiled in the same directory in the same build step. But dmd rejects the files that are named

Re: AliasSeq of T.tupleof for class and all base classes

2017-09-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/29/17 11:39 PM, bitwise wrote: As far as I can tell, this code should compile: class B   { int a; } class D1 : B  { int b; } class D2 : D1 { int c; } template TupleOf(Classes...) {     static if(Classes.length > 1)     alias TupleOf = AliasSeq!(Classes[0].tupleof,

Re: static this not run?

2017-09-30 Thread kinke via Digitalmars-d-learn
On Saturday, 30 September 2017 at 12:07:21 UTC, Nicholas Wilson wrote: Hmm. Everything except for the main function was in a different module, I dont see why that would cause it to not be run, but then bugs have a tendency to do strange things like that. I'll have to dust mite DCompute and see

Re: Region-based memory management and GC?

2017-09-30 Thread Jon Degenhardt via Digitalmars-d-learn
On Saturday, 30 September 2017 at 07:41:21 UTC, Igor wrote: On Friday, 29 September 2017 at 22:13:01 UTC, Jon Degenhardt wrote: Have there been any investigations into using region-based memory management (aka memory arenas) in D, possibly in conjunction with GC allocated memory? Sounds like

splitter string/char different behavior

2017-09-30 Thread SrMordred via Digitalmars-d-learn
writeln( "a.b.c".splitter('.').dropBack(1) ); //compiles ok writeln( "a.b.c".splitter(".").dropBack(1) ); //error: Error: template std.range.dropBack cannot deduce function from argument types !()(Result, int), candidates are: (...) Hm.. can someone explain whats going on?

Sockets and the Promiscous Mode

2017-09-30 Thread fichtknick via Digitalmars-d-learn
Hello all only for learning purposes and my interest for deeper network programming. I wanted to write a program and filter the entire traffic in my network. I have a server and various computers in my network, but I dont know, as I in D the promiscous mode for sockets can switch on. Is

Re: AliasSeq of T.tupleof for class and all base classes

2017-09-30 Thread bitwise via Digitalmars-d-learn
On Saturday, 30 September 2017 at 12:42:17 UTC, Steven Schveighoffer wrote: I think the problem may be that derived classes' tupleof has some of the same variables as the base class? I agree it should work, but I think if it did work, it may not be what you want. You would see a lot of

Re: Creating a dynamic library

2017-09-30 Thread Tony via Digitalmars-d-learn
On Saturday, 30 September 2017 at 10:09:43 UTC, Mike Wey wrote: On 30-09-17 03:27, Tony wrote: One thing I picked up from SCons is creating dynamic object files with a .os extension and static object files with the standard .o extension. That way they can be compiled in the same directory in

Re: Region-based memory management and GC?

2017-09-30 Thread Igor via Digitalmars-d-learn
On Friday, 29 September 2017 at 22:13:01 UTC, Jon Degenhardt wrote: Have there been any investigations into using region-based memory management (aka memory arenas) in D, possibly in conjunction with GC allocated memory? This would be a very speculative idea, but it'd be interesting to know if

generating @property from structs

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
struct MyType { void* ptr; static struct Info { @(42) int foo; } // Should be generated by the mixin below @property int foo() { int ret; getMyTypeInfo(ptr,42,int.sizeof,); return ret; } mixin generateInfo!getMyTypeInfo; }

Re: Is it possible to specify the address returned by the address of operator?

2017-09-30 Thread Paolo Invernizzi via Digitalmars-d-learn
On Friday, 29 September 2017 at 22:15:44 UTC, Mengu wrote: On Friday, 29 September 2017 at 02:34:08 UTC, DreadKyller wrote: [...] +1 for forum issue. +1 please...

static this not run?

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
I want a module level initialised delegate. if I try module foo; enum Status { success, } class StatusException : Exception { Status s; // usual exception constructors } void delegate(Status) onError = (Status s) { throw new StatusException(s);}; I get a error like cannot

Re: core.stdc.time

2017-09-30 Thread Tony via Digitalmars-d-learn
On Saturday, 30 September 2017 at 07:45:27 UTC, Jacob Carlborg wrote: On 2017-09-30 08:56, Tony wrote: The documentation says: -- This module contains bindings to selected types and functions from the standard C header . Note that this is

Re: generating @property from structs

2017-09-30 Thread user1234 via Digitalmars-d-learn
On Saturday, 30 September 2017 at 08:20:44 UTC, Nicholas Wilson wrote: struct MyType { void* ptr; static struct Info { @(42) int foo; } // Should be generated by the mixin below @property int foo() { int ret;

Re: static this not run?

2017-09-30 Thread user1234 via Digitalmars-d-learn
On Saturday, 30 September 2017 at 06:15:41 UTC, Nicholas Wilson wrote: No "initialising onError", the static this is not even being run! I'm using LDC master. See also https://github.com/libmir/dcompute/issues/32 LDC 1.4, DMD 2.076, DMD ~master and finally GDC all give the expected result

core.stdc.time

2017-09-30 Thread Tony via Digitalmars-d-learn
The documentation says: -- This module contains bindings to selected types and functions from the standard C header . Note that this is not automatically generated, and may omit some types/functions from the original C header.

Best way to display images with GTKD

2017-09-30 Thread Psychological Cleanup via Digitalmars-d-learn
I have to display images with a few controls: alpha channel, rotation, scaling, cropping. Generally it should be png but I want to be able to handle many images. The images will be memory based(I'll load the file in to memory then) and will be displayed in a drawing area. Any ideas how to go

Re: splitter string/char different behavior

2017-09-30 Thread SrMordred via Digitalmars-d-learn
In order to know where to split, it really has to do it from the front. If it starts from the back, you won't necessarily split in the same places as when iterating from the front, and that would violate how bidirectional ranges are supposed to work (the elements should be the same - just in

[Template] Mixins and foreach

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
struct MyType { void* raw; static struct Info { @(42) int foo; } mixin generateGetInfo!MyTypeGetInfo; } extern(C) void MyTypeGetInfo(void*,int,size_t,void*size_t*); mixin template generateGetInfo(alias func) { foreach(field; typeof(this).Info.tupleof) {

Re: splitter string/char different behavior

2017-09-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 30, 2017 20:18:25 Jon Degenhardt via Digitalmars-d- learn wrote: > On Saturday, 30 September 2017 at 17:17:17 UTC, SrMordred wrote: > > writeln( "a.b.c".splitter('.').dropBack(1) ); //compiles ok > > writeln( "a.b.c".splitter(".").dropBack(1) ); > > > > //error: > > Error:

Re: [Template] Mixins and foreach

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 October 2017 at 01:05:56 UTC, Nicholas Wilson wrote: struct MyType { void* raw; static struct Info { @(42) int foo; } mixin generateGetInfo!MyTypeGetInfo; } extern(C) void MyTypeGetInfo(void*,int,size_t,void*size_t*); mixin template generateGetInfo(alias

Re: splitter string/char different behavior

2017-09-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 01, 2017 00:56:23 SrMordred via Digitalmars-d-learn wrote: > > In order to know where to split, it really has to do it from > > the front. If it starts from the back, you won't necessarily > > split in the same places as when iterating from the front, and > > that would violate

Re: [Template] Mixins and foreach

2017-09-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 01, 2017 02:07:26 Nicholas Wilson via Digitalmars-d-learn wrote: > On Sunday, 1 October 2017 at 01:05:56 UTC, Nicholas Wilson wrote: > > struct MyType > > { > > > > void* raw; > > static struct Info > > { > > > > @(42) int foo; > > > > } > > mixin

Re: splitter string/char different behavior

2017-09-30 Thread Jon Degenhardt via Digitalmars-d-learn
On Saturday, 30 September 2017 at 17:17:17 UTC, SrMordred wrote: writeln( "a.b.c".splitter('.').dropBack(1) ); //compiles ok writeln( "a.b.c".splitter(".").dropBack(1) ); //error: Error: template std.range.dropBack cannot deduce function from argument types !()(Result, int), candidates are:

Re: splitter string/char different behavior

2017-09-30 Thread WhatMeWorry via Digitalmars-d-learn
On Saturday, 30 September 2017 at 18:21:11 UTC, Jon Degenhardt wrote: On Saturday, 30 September 2017 at 17:17:17 UTC, SrMordred wrote: [...] It's easy to overlook, but documentation for splitter starts out: Lazily splits a range using an element as a separator. An element of a string

Re: splitter string/char different behavior

2017-09-30 Thread SrMordred via Digitalmars-d-learn
For "a.b.c"splitter(x), Range r is a string, r.front is a char. The template can only be instantiated if the predicate function is valid. The predicate function is "a == b". Since r.front is a char, then s must be a type that can be compared with '=='. A string and char cannot be compared with

Re: splitter string/char different behavior

2017-09-30 Thread Jon Degenhardt via Digitalmars-d-learn
On Saturday, 30 September 2017 at 19:26:14 UTC, SrMordred wrote: For "a.b.c"splitter(x), Range r is a string, r.front is a char. The template can only be instantiated if the predicate function is valid. The predicate function is "a == b". Since r.front is a char, then s must be a type that can

Re: splitter string/char different behavior

2017-09-30 Thread Jon Degenhardt via Digitalmars-d-learn
On Saturday, 30 September 2017 at 17:17:17 UTC, SrMordred wrote: writeln( "a.b.c".splitter('.').dropBack(1) ); //compiles ok writeln( "a.b.c".splitter(".").dropBack(1) ); //error: Error: template std.range.dropBack cannot deduce function from argument types !()(Result, int), candidates are:

compile time sequence variable

2017-09-30 Thread Andrey via Digitalmars-d-learn
Hello, can I make AliasSeq not inside template function, for example I want add function called `registerComponent` which will add the components classes to list and based on this generated list I want add additional fields inside `ComponentsManager`. Example: Registering components: struct

Re: [Template] Mixins and foreach

2017-09-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 01, 2017 03:11:15 Nicholas Wilson via Digitalmars-d-learn wrote: > On Sunday, 1 October 2017 at 02:29:57 UTC, Jonathan M Davis wrote: > > I would have thought that it would be pretty straightforward to > > just write a recursive, eponymous template to solve the problem > > and

Re: Why does BinaryHeap sometime cause compile-error in foeach?

2017-09-30 Thread Shigeki Karita via Digitalmars-d-learn
Oh, struct/class semantics really confuses me!

Re: [Template] Mixins and foreach

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 October 2017 at 02:29:57 UTC, Jonathan M Davis wrote: I would have thought that it would be pretty straightforward to just write a recursive, eponymous template to solve the problem and have it recursively build a single string to mix in for everything. In general though,