Re: Constructor Inheritance

2016-06-20 Thread Meta via Digitalmars-d-learn
On Tuesday, 21 June 2016 at 03:06:22 UTC, H. S. Teoh wrote: On Tue, Jun 21, 2016 at 02:48:39AM +, ketmar via Digitalmars-d-learn wrote: no and no. howewer, creating template mixin with default ctors may spare you of some typing. I think Phobos has an AutoImplement template that might do

Re: Constructor Inheritance

2016-06-20 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jun 21, 2016 at 02:48:39AM +, ketmar via Digitalmars-d-learn wrote: > no and no. howewer, creating template mixin with default ctors may > spare you of some typing. I think Phobos has an AutoImplement template that might do this for you. Maybe take a look in std.typecons or std.meta

Re: Meaning of const variables

2016-06-20 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jun 21, 2016 at 02:24:03AM +, jmh530 via Digitalmars-d-learn wrote: > I feel like I have a reasonable understanding of when to use const as > a parameter in a function or for const member functions. However, I > don't really understand why/when it should be used as a type modifier. >

Re: vibe.d - asynchronously wait() for process to exit

2016-06-20 Thread Vladimir Panteleev via Digitalmars-d-learn
On Monday, 20 June 2016 at 19:39:42 UTC, Steven Schveighoffer wrote: On 6/20/16 12:29 PM, Vladimir Panteleev wrote: On Monday, 20 June 2016 at 16:16:32 UTC, Steven Schveighoffer wrote: What is the OS support for waitid (http://man7.org/linux/man-pages/man2/waitpid.2.html)? Seems to have

Re: Meaning of const variables

2016-06-20 Thread ketmar via Digitalmars-d-learn
On Tuesday, 21 June 2016 at 02:24:03 UTC, jmh530 wrote: So the line from the spec is "Const types are like immutable types, except that const forms a read-only view of data. Other aliases to that same data may change it at any time." I tried making an alias of a const variable and modifying

Re: Constructor Inheritance

2016-06-20 Thread ketmar via Digitalmars-d-learn
no and no. howewer, creating template mixin with default ctors may spare you of some typing.

Re: D casting broke?

2016-06-20 Thread Joerg Joergonson via Digitalmars-d-learn
On Monday, 20 June 2016 at 23:35:28 UTC, Steven Schveighoffer wrote: On 6/19/16 5:19 PM, Joerg Joergonson wrote: On Sunday, 19 June 2016 at 20:21:35 UTC, ag0aep6g wrote: On 06/19/2016 09:59 PM, Joerg Joergonson wrote: This should be completely valid since B!T' obviously derives from A!T

Re: arsd png bug

2016-06-20 Thread Joerg Joergonson via Digitalmars-d-learn
On Tuesday, 21 June 2016 at 00:31:51 UTC, Adam D. Ruppe wrote: On Monday, 20 June 2016 at 21:39:45 UTC, Joerg Joergonson wrote: adding if (i >= previousLine.length) break; prevents some crashes and seems to work. So previousLine should be either the right length or null, so I put in

Re: D casting broke?

2016-06-20 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jun 21, 2016 at 02:09:50AM +, Joerg Joergonson via Digitalmars-d-learn wrote: [...] > Lets suppose A -> B means B is derived from A. That is, any object of > B can be cast to A because the memory layout of A is contained in B > and any object of B can be accessed as if it were an A.

Constructor Inheritance

2016-06-20 Thread Meta via Digitalmars-d-learn
It's been so long since I've had to use OOP in D that I'm starting to forget things like this. If I have the parent class A which defines a constructor: class A { string val; this(string val) { this.val = val; } } And a child class B which inherits from A: class B: A { } I get the

Meaning of const variables

2016-06-20 Thread jmh530 via Digitalmars-d-learn
I feel like I have a reasonable understanding of when to use const as a parameter in a function or for const member functions. However, I don't really understand why/when it should be used as a type modifier. For instance, the Programming in D book basically just says

Re: D casting broke?

2016-06-20 Thread Joerg Joergonson via Digitalmars-d-learn
On Monday, 20 June 2016 at 23:10:14 UTC, ag0aep6g wrote: On 06/20/2016 11:33 PM, Joerg Joergonson wrote: On Monday, 20 June 2016 at 10:38:12 UTC, ag0aep6g wrote: [...] Is your position that Button!SliderItem should derive/inherit from Button!ButtonItem, enabling the cast, or do you suppose

Re: arsd png bug

2016-06-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 20 June 2016 at 21:39:45 UTC, Joerg Joergonson wrote: adding if (i >= previousLine.length) break; prevents some crashes and seems to work. So previousLine should be either the right length or null, so I put in one test. Can you try it on your test image? BTW I do a few

Re: D casting broke?

2016-06-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/19/16 5:19 PM, Joerg Joergonson wrote: On Sunday, 19 June 2016 at 20:21:35 UTC, ag0aep6g wrote: On 06/19/2016 09:59 PM, Joerg Joergonson wrote: This should be completely valid since B!T' obviously derives from A!T directly ok and we see that T' derives from b which derives from a

Re: Is it legal to place a UDA on a module?

2016-06-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 20 June 2016 at 19:14:42 UTC, Jacob Carlborg wrote: On 2016-06-20 16:23, Jacob Carlborg wrote: On 2016-06-20 11:59, Nicholas Wilson wrote: as in @myattr module foo; not module foo; @myattr: No, I don't think so. Because "module" can only appear the the top of the file (except

Re: D casting broke?

2016-06-20 Thread ag0aep6g via Digitalmars-d-learn
On 06/20/2016 11:33 PM, Joerg Joergonson wrote: On Monday, 20 June 2016 at 10:38:12 UTC, ag0aep6g wrote: [...] Is your position that Button!SliderItem should derive/inherit from Button!ButtonItem, enabling the cast, or do you suppose the cast should succeed because the fields are compatible?

Re: arsd png bug

2016-06-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 20 June 2016 at 21:53:42 UTC, Alex Parrill wrote: You'd probably get better results by filing an issue with the project's bug tracker [1]. Also by including a sample image that causes the crash. It doesn't make much of a difference to me, it all just ends up in my email inbox

Re: arsd png bug

2016-06-20 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 20 June 2016 at 21:39:45 UTC, Joerg Joergonson wrote: 1810: case 3: auto arr = data.dup; foreach(i; 0 .. arr.length) { auto prev = i < bpp ? 0 : arr[i - bpp];

arsd png bug

2016-06-20 Thread Joerg Joergonson via Digitalmars-d-learn
1810: case 3: auto arr = data.dup; foreach(i; 0 .. arr.length) { auto prev = i < bpp ? 0 : arr[i - bpp]; if (i >= previousLine.length) break;

Re: Unmanaged drop in replacemet for [] and length -= 1

2016-06-20 Thread Joerg Joergonson via Digitalmars-d-learn
On Monday, 20 June 2016 at 16:27:29 UTC, Steven Schveighoffer wrote: On 6/18/16 5:55 PM, Joerg Joergonson wrote: I wanted to switch to std.container.Array but it doesn't seem to mimic [] for some odd ball reason. I threw this class together and it seems to work. The only problem is that I

Re: D casting broke?

2016-06-20 Thread Joerg Joergonson via Digitalmars-d-learn
On Monday, 20 June 2016 at 10:38:12 UTC, ag0aep6g wrote: On 06/20/2016 01:40 AM, Joerg Joergonson wrote: public class Button(T : ButtonItem) : Widget { ... } public class ButtonItem : Item { void Do() { auto parent = (cast(Button!ButtonItem)this.Parent); } ... } All this works great! As

Re: vibe.d - asynchronously wait() for process to exit

2016-06-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/20/16 12:29 PM, Vladimir Panteleev wrote: On Monday, 20 June 2016 at 16:16:32 UTC, Steven Schveighoffer wrote: What is the OS support for waitid (http://man7.org/linux/man-pages/man2/waitpid.2.html)? Seems to have support for async waiting of multiple processes (at least it can return

Re: Is it legal to place a UDA on a module?

2016-06-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-06-20 16:23, Jacob Carlborg wrote: On 2016-06-20 11:59, Nicholas Wilson wrote: as in @myattr module foo; not module foo; @myattr: No, I don't think so. Because "module" can only appear the the top of the file (except for comments). My mistake. It _is_ actually possible. It just

Re: How to group similar member functions from different classes?

2016-06-20 Thread Marc Schütz via Digitalmars-d-learn
Untested: // foo.d import a, b; mixin template Foos { static if(is(typeof(this) == A)) void foo() { /* implementation for A */ } static if(is(typeof(this) == B)) void foo() { /* implementation for B */ } } // a.d import foo; class A { mixin Foos; } // b.d import foo; class

Re: const and mutable opApply's

2016-06-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/19/16 6:17 PM, Oleg B wrote: Hello ... How I can rewrite this code without mixin's and with one (maybe inout) opApply? Someone just asked a similar question about this: https://forum.dlang.org/post/nk90v2$1fr3$1...@digitalmars.com -Steve

Re: vibe.d - asynchronously wait() for process to exit

2016-06-20 Thread Vladimir Panteleev via Digitalmars-d-learn
On Monday, 20 June 2016 at 16:16:32 UTC, Steven Schveighoffer wrote: What is the OS support for waitid (http://man7.org/linux/man-pages/man2/waitpid.2.html)? Seems to have support for async waiting of multiple processes (at least it can return immediately if no child has exited). One

Re: Unmanaged drop in replacemet for [] and length -= 1

2016-06-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/18/16 5:55 PM, Joerg Joergonson wrote: I wanted to switch to std.container.Array but it doesn't seem to mimic [] for some odd ball reason. I threw this class together and it seems to work. The only problem is that I can't do carray.length -= 1; I can't override `-=` because that is on

Re: vibe.d - asynchronously wait() for process to exit

2016-06-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/17/16 9:53 AM, Vladimir Panteleev wrote: std.process.wait() will wait for a child process to exit and return its exit code. How can this be done in Vibe.d, without blocking other fibers and without creating a new thread? What is the OS support for waitid

Re: Is there anyway to make opApply @nogc?

2016-06-20 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 20 June 2016 at 15:47:44 UTC, Gary Willoughby wrote: On Monday, 20 June 2016 at 15:27:32 UTC, Adam D. Ruppe wrote: On Monday, 20 June 2016 at 15:13:53 UTC, Gary Willoughby wrote: I think the problem is that the delegate which is required by opApply is allocated using the GC. make

Re: Is there anyway to make opApply @nogc?

2016-06-20 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 20 June 2016 at 15:27:32 UTC, Adam D. Ruppe wrote: On Monday, 20 June 2016 at 15:13:53 UTC, Gary Willoughby wrote: I think the problem is that the delegate which is required by opApply is allocated using the GC. make the delegate in opApply scope int opApply(scope int

Re: Is there anyway to make opApply @nogc?

2016-06-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 20 June 2016 at 15:13:53 UTC, Gary Willoughby wrote: I think the problem is that the delegate which is required by opApply is allocated using the GC. make the delegate in opApply scope int opApply(scope int delegate(whatever) dg)

Re: Is there anyway to make opApply @nogc?

2016-06-20 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 20 June 2016 at 14:34:33 UTC, Mathias Lang wrote: Can't `opApply` with `auto` return type works since it infers attributes ? I think the problem is that the delegate which is required by opApply is allocated using the GC.

Re: Using .lib and .dll in D applications

2016-06-20 Thread moe via Digitalmars-d-learn
On Monday, 20 June 2016 at 13:51:15 UTC, Mike Parker wrote: interface Plugin { bool initialize(); void terminate(); Throwable getLastException(); SomeObject getSomeObject(); void returnSomeObject(SomeObject); } Sorry, I forgot a couple of commments. I did explain it in the

Re: Is there anyway to make opApply @nogc?

2016-06-20 Thread Mathias Lang via Digitalmars-d-learn
On Monday, 20 June 2016 at 14:08:58 UTC, Gary Willoughby wrote: Is there any way to make opApply @nogc? or provide the same foreach functionality without implementing a range interface? I want to iterate over a piece of memory using a pointer. I thought about using opSlice but that doesn't

Re: Is it legal to place a UDA on a module?

2016-06-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-06-20 11:59, Nicholas Wilson wrote: as in @myattr module foo; not module foo; @myattr: No, I don't think so. Because "module" can only appear the the top of the file (except for comments). -- /Jacob Carlborg

Is there anyway to make opApply @nogc?

2016-06-20 Thread Gary Willoughby via Digitalmars-d-learn
Is there any way to make opApply @nogc? or provide the same foreach functionality without implementing a range interface? I want to iterate over a piece of memory using a pointer. I thought about using opSlice but that doesn't provide information for an index in a foreach loop. auto

Re: Static function as member delegate's initial value?

2016-06-20 Thread Mike Parker via Digitalmars-d-learn
On Monday, 20 June 2016 at 13:54:22 UTC, Mike Parker wrote: The best you can do is assign it in a constructor. Well, 'initialize' it in a constructor.

Re: Static function as member delegate's initial value?

2016-06-20 Thread Mike Parker via Digitalmars-d-learn
On Monday, 20 June 2016 at 13:20:04 UTC, OpenJelly wrote: I've got a delegate as a member of a class and I want to give it a default value. I can assign it an initial value in each initializer of the class but I'd like to make my code more readable and assign it a function at the declaration.

Re: Using .lib and .dll in D applications

2016-06-20 Thread Mike Parker via Digitalmars-d-learn
interface Plugin { bool initialize(); void terminate(); Throwable getLastException(); SomeObject getSomeObject(); void returnSomeObject(SomeObject); } Sorry, I forgot a couple of commments. I did explain it in the text, though. It was supposed to read: interface Plugin {

Re: Using .lib and .dll in D applications

2016-06-20 Thread Mike Parker via Digitalmars-d-learn
On Monday, 20 June 2016 at 11:25:04 UTC, moe wrote: Where I still have a problem is with a plugin system. I would like to write an app that is plugin based. So that I can write a plugin to extend the functionality of the app. I imagine that I could copy the plugin into a folder from the

Static function as member delegate's initial value?

2016-06-20 Thread OpenJelly via Digitalmars-d-learn
I've got a delegate as a member of a class and I want to give it a default value. I can assign it an initial value in each initializer of the class but I'd like to make my code more readable and assign it a function at the declaration. Trying to toDelegate the situation gives me the following

Re: Using .lib and .dll in D applications

2016-06-20 Thread moe via Digitalmars-d-learn
Thanks everyone for the info. It is very much appreciated! What works for me right now is dealing with various packages (dub packages) and use them in projects. I previously made too many assumptions about how lib's and dll's work. It's much clearer now. Where I still have a problem is with

Re: D casting broke?

2016-06-20 Thread ag0aep6g via Digitalmars-d-learn
On 06/20/2016 01:40 AM, Joerg Joergonson wrote: public class Button(T : ButtonItem) : Widget { ... } public class ButtonItem : Item { void Do() { auto parent = (cast(Button!ButtonItem)this.Parent); } ... } All this works great! As long as Do is not being called from a derived class public

Is it legal to place a UDA on a module?

2016-06-20 Thread Nicholas Wilson via Digitalmars-d-learn
as in @myattr module foo; not module foo; @myattr:

Re: Different struct sizeof between linux and windows

2016-06-20 Thread Kagamin via Digitalmars-d-learn
On Friday, 17 June 2016 at 16:25:15 UTC, Vladimir Panteleev wrote: If I were to import the time() function from MSVCR*.dll, what size its return value would be? MSVC runtime dll doesn't export `time` function, it exports _time32 and _time64. `time` is a wrapper in the import library, its

Re: What exactly does the compiler switch -betterC do?

2016-06-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-06-19 21:53, Gary Willoughby wrote: When compiling, what exactly does the -betterC flag do? The command help says "omit generating some runtime information and helper functions" but what does this really mean? Is there any specifics somewhere? It is intended to allow you to link an