Re: onDispatch demo not compiling

2014-08-21 Thread ketmar via Digitalmars-d-learn
On Thu, 21 Aug 2014 05:39:14 + Shachar via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: auto onDispatch(string m, Args...)(Args args) first: opDispatch, not onDispatch. second: underscoresToCamelCase() can't be evaluated in compile-time anymore. the necessary changes: 1.

Re: onDispatch demo not compiling

2014-08-21 Thread ketmar via Digitalmars-d-learn
On Thu, 21 Aug 2014 05:39:14 + Shachar via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: that's it: failing to evaluate opDispatch() template is not a compilation error. compiler will silently try to find direct method if opDispatch() fails. so be very careful with it. you can

Re: onDispatch demo not compiling

2014-08-21 Thread Shachar via Digitalmars-d-learn
On Thursday, 21 August 2014 at 06:11:06 UTC, ketmar via Digitalmars-d-learn wrote: that will do the trick. Indeed. I ended up simply directly calling a.opDispatch!do_something_cool(5, 6), which brought most of those issues to light. Shachar

Re: onDispatch demo not compiling

2014-08-21 Thread ketmar via Digitalmars-d-learn
On Thu, 21 Aug 2014 06:34:10 + Shachar via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Indeed. I ended up simply directly calling a.opDispatch!do_something_cool(5, 6), which brought most of those issues to light. ah, silly me. i forgot about such simple thing.

Re: Can you explain this?

2014-08-21 Thread Colin via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 20:18:15 UTC, Dicebot wrote: On Wednesday, 20 August 2014 at 20:01:05 UTC, Colin wrote: I see 3 distinct parts playing a role in my confusion: A) The 'is' keyword. What does it do when you have is(expression); http://dlang.org/expression.html#IsExpression It

Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread MarisaLovesUsAll via Digitalmars-d-learn
tl;dr - how to get child classname from inherited parent function at compile time? class A { string getName(); }; class B { }; B foo = new B; assert(foo.getName() == B); ... Hi! I'm stuck at one issue, and I don't know how to solve it. I think this is about mixins/templates, isn't it? When

Re: goto skips declaration of variable

2014-08-21 Thread nrgyzer via Digitalmars-d-learn
On Tuesday, 19 August 2014 at 20:33:00 UTC, monarch_dodra wrote: On Monday, 18 August 2014 at 13:51:14 UTC, nrgyzer wrote: Hi all, I've the following code snipped: import std.bigint; void main(string[] args) { BigInt i = 12345; if (args.length 1) {

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread MarisaLovesUsAll via Digitalmars-d-learn
I found a rough solution. It's not ideal and I still want to make autoinject, but it works. mixin template Manager(T) {}; class Component {}; class Sprite:Component { mixin Manager!Sprite; }; 1) How to make mixin inject automatic? 2) If it's impossible, how to use mixin Manager; without

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread anonymous via Digitalmars-d-learn
On Thursday, 21 August 2014 at 12:58:13 UTC, MarisaLovesUsAll wrote: I found a rough solution. It's not ideal and I still want to make autoinject, but it works. mixin template Manager(T) {}; class Component {}; class Sprite:Component { mixin Manager!Sprite; }; 1) How to make mixin inject

Generating a tree structure

2014-08-21 Thread Ricky C via Digitalmars-d-learn
I'm trying to make a tree data structure in part of my first non-trivial D-based program. Turns out that DMD likes to re-use PODs - sounds good, but that trapped me, and I'm not sure how to clear myself out of the problem nicely. My simplified, but not oversimplified, example is

Re: Generating a tree structure

2014-08-21 Thread anonymous via Digitalmars-d-learn
On Thursday, 21 August 2014 at 14:09:24 UTC, Ricky C wrote: I'm trying to make a tree data structure in part of my first non-trivial D-based program. Turns out that DMD likes to re-use PODs - sounds good, but that trapped me, and I'm not sure how to clear myself out of the problem nicely.

Re: Generating a tree structure

2014-08-21 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 21 August 2014 at 14:09:24 UTC, Ricky C wrote: TileTree* self; Don't do that. D has banned internal pointers to implement its move semantics. branches[index] = tile_trees[index]; This will make a *value-copy* of your TileTree nodes. There are good chances it'll break your

Re: goto skips declaration of variable

2014-08-21 Thread Ali Çehreli via Digitalmars-d-learn
On 08/21/2014 04:12 AM, nrgyzer wrote: I'm using the goto-command to exit my function if an error (not necessarily an exception) occured. Sorry to repeat myself but if an exception occurs in code before the goto, the exit code will not be executed. Of course, it may be that the function is

Re: D with no druntime

2014-08-21 Thread maarten van damme via Digitalmars-d-learn
There were 2 talks about bare metal D this year at the D conference. The first one is about someone able to use D on microcontrollers with a few k ram.: https://www.youtube.com/watch?v=o5m0m_ZG9e8 The second one is about someone trying to strip almost everything out and see what works:

Re: goto skips declaration of variable

2014-08-21 Thread nrgyzer via Digitalmars-d-learn
On Thursday, 21 August 2014 at 17:39:16 UTC, Ali Çehreli wrote: On 08/21/2014 04:12 AM, nrgyzer wrote: I'm using the goto-command to exit my function if an error (not necessarily an exception) occured. Sorry to repeat myself but if an exception occurs in code before the goto, the exit code

Value of floating in JSONValue

2014-08-21 Thread nrgyzer via Digitalmars-d-learn
Hi everyone, I'm facing a problem with the JSON functions. I've to communicate with another PC using JSON. Here's a simple snipped which shows my problem: import std.json; import std.stdio; void main() { double d = 1.23456789; JSONValue j = d; sendToRemote(toJSON(j)); }

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread MarisaLovesUsAll via Digitalmars-d-learn
On Thursday, 21 August 2014 at 13:19:06 UTC, anonymous wrote: 1) How to make mixin inject automatic? You could use this pattern: interface Component {} class ComponentImpl(T) {} class Sprite : ComponentImpl!Sprite {} From my view, it's an architectural crutch. %) You can use `typeof(this)`

Re: new error message in 2.066, type bool (const)

2014-08-21 Thread Brad Anderson via Digitalmars-d-learn
On Thursday, 21 August 2014 at 03:02:53 UTC, Paul D Anderson wrote: What changed? It ran okay with early beta versions, but not with the release. Paul It compiles in beta-5 but not beta-6. Is the list of changes in the beta testing wiki complete? None seem pertinent. monarch_dodra:

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread Ary Borenszweig via Digitalmars-d-learn
On 8/21/14, 6:38 AM, MarisaLovesUsAll wrote: tl;dr - how to get child classname from inherited parent function at compile time? class A { string getName(); }; class B { }; B foo = new B; assert(foo.getName() == B); ... Hi! I'm stuck at one issue, and I don't know how to solve it. I think this

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread anonymous via Digitalmars-d-learn
On Thursday, 21 August 2014 at 19:58:18 UTC, MarisaLovesUsAll wrote: When I make mixin injection in one class, I want auto-injection in another class. How can I do this? class Component:GameObject { //second injection must be here and must be automatic }; class Sprite:Component {

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread anonymous via Digitalmars-d-learn
On Thursday, 21 August 2014 at 20:05:13 UTC, Ary Borenszweig wrote: I'll tell you how it's done in Crystal in case someone wants to come up with a proposal to make it work in D. ~~~ class Foo macro inherited def method_in_{{@class_name.downcase.id}} puts Hello {{@class_name.id}}!

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread MarisaLovesUsAll via Digitalmars-d-learn
On Thursday, 21 August 2014 at 20:16:33 UTC, anonymous wrote: Maybe you can explain what you're trying to achieve with all this. There may be a different/better way to do it. Sure. Class tree: GameObject-Component-Sprite. GameObject structure: Component[]; Component

Re: Value of floating in JSONValue

2014-08-21 Thread Ali Çehreli via Digitalmars-d-learn
On 08/21/2014 11:53 AM, nrgyzer wrote: double d = 1.23456789; JSONValue j = d; sendToRemote(toJSON(j)); } My problem is that the remote PC receives 1.23457 instead of 1.23456789. I think it is due to the following code simply calling to!string in std/phobos/json.d:

Re: Value of floating in JSONValue

2014-08-21 Thread Idan Arye via Digitalmars-d-learn
On Thursday, 21 August 2014 at 23:05:48 UTC, Ali Çehreli wrote: I don't think it is a concern as JSON does not encode types. It is up to the receiver how to interpret the data. Here is the output of the program above: {value:1.234567889998901} Ali JSON may not encode the very specific

Re: new error message in 2.066, type bool (const)

2014-08-21 Thread Paul D Anderson via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 20:46:20 UTC, Paul D Anderson wrote: Re-compiling existing code with version 2.066 generates a lot of errors complaining about implicit conversion to const. Typical is this call (inside a struct with properties 1 2): z.sign = x.sign ^ y.sign; Error:

Trouble reproducing compilation error

2014-08-21 Thread Xinok via Digitalmars-d-learn
I'm currently receiving several errors when trying to compile this code with DMD 2.066 (beginning with RC1): https://github.com/Xinok/XSort The compiler throws an error because it's unable to deduce a type for the predicate in a few places. This repository compiles just fine in DMD 2.065 and

Re: Trouble reproducing compilation error

2014-08-21 Thread Xinok via Digitalmars-d-learn
This is the full compiler output: combsort.d(90): Error: template D main.pred cannot deduce function from argument types !()(uint, uint), candidates are: benchsort.d(37):benchsort.main.pred(T)(T a, T b) benchsort.d(81): Error: template instance combsort.combSortLinear!(pred, uint[])

RAII limitations in D?

2014-08-21 Thread Timothee Cour via Digitalmars-d-learn
What would be a good answer to this article? http://swiftcoder.wordpress.com/2009/02/18/raii-why-is-it-unique-to-c/ Especially the part mentioning D:{ D’s scope keyword, Python’s with statement and C#’s using declaration all provide limited RAII, by allowing resources to have a scoped lifetime,

Re: RAII limitations in D?

2014-08-21 Thread Dicebot via Digitalmars-d-learn
http://dlang.org/phobos/std_typecons.html#.RefCounted

Re: RAII limitations in D?

2014-08-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 22 August 2014 at 02:22:16 UTC, Timothee Cour via Digitalmars-d-learn wrote: What would be a good answer to this article? It's own publication date: Feb 2009. The D struct has changed a lot since then, getting new features (@disable, postblit, more reliable destructor) and bugs

Re: RAII limitations in D?

2014-08-21 Thread Timothee Cour via Digitalmars-d-learn
On Thu, Aug 21, 2014 at 7:26 PM, Dicebot via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: http://dlang.org/phobos/std_typecons.html#.RefCounted That doesn't work with classes though; is there any way to get a ref counted class? (and btw RefCounted should definitely appear in

Re: new error message in 2.066, type bool (const)

2014-08-21 Thread Paul D Anderson via Digitalmars-d-learn
On Friday, 22 August 2014 at 01:25:05 UTC, Paul D Anderson wrote: On Wednesday, 20 August 2014 at 20:46:20 UTC, Paul D Anderson I don't know if this is expected behavior that just wasn't enforced before, or if this is something new. Either way I don't like it. And I'm a little surprised I'm

Re: RAII limitations in D?

2014-08-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, 22 August 2014 at 03:00:01 UTC, Timothee Cour via Digitalmars-d-learn wrote: On Thu, Aug 21, 2014 at 7:26 PM, Dicebot via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: http://dlang.org/phobos/std_typecons.html#.RefCounted That doesn't work with classes though; is

Re: RAII limitations in D?

2014-08-21 Thread Kagamin via Digitalmars-d-learn
On Friday, 22 August 2014 at 02:22:16 UTC, Timothee Cour via Digitalmars-d-learn wrote: Especially the part mentioning D:{ D’s scope keyword, Python’s with statement and C#’s using declaration all provide limited RAII, by allowing resources to have a scoped lifetime, but none of them readily