Re: Ropes (concatenation trees) for strings in D ?

2014-08-16 Thread MrSmith via Digitalmars-d-learn
On Saturday, 16 August 2014 at 02:26:29 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 15 Aug 2014 19:04:10 -0700 Timothee Cour via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: sounds like my C library based on this article:

Re: Ropes (concatenation trees) for strings in D ?

2014-08-16 Thread ketmar via Digitalmars-d-learn
On Sat, 16 Aug 2014 10:25:01 + MrSmith via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Can you also share your progress? sure. the project has no public repo yet, but you can take a look at it's current state here: http://ketmar.no-ip.org/etx.txz no undo/redo support for

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Philippe Sigaud via Digitalmars-d-learn
If I understand correctly Adam Ruppe's Cookbook, by putting @safe: pure: nothrow: at the beginning of a module, I distribute it on all definitions, right? Even methods, inner classes, and so on? I read Adam's book again and I was wrong: Chapter 7, p. 173: You may add @safe: to the top

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Artur Skawina via Digitalmars-d-learn
On 08/16/14 13:18, Philippe Sigaud via Digitalmars-d-learn wrote: We indeed need to put annotations inside aggregates to affect their innards. If that's true, I have a lot of annotation sprinkling to do. It's not true for @safe, but true for some other attributes.

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Philippe Sigaud via Digitalmars-d-learn
On Sat, Aug 16, 2014 at 1:30 PM, Artur Skawina via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 08/16/14 13:18, Philippe Sigaud via Digitalmars-d-learn wrote: We indeed need to put annotations inside aggregates to affect their innards. If that's true, I have a lot of

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Artur Skawina via Digitalmars-d-learn
On 08/16/14 13:58, Philippe Sigaud via Digitalmars-d-learn wrote: On Sat, Aug 16, 2014 at 1:30 PM, Artur Skawina via Digitalmars-d-learn http://forum.dlang.org/post/mailman.125.1397731134.2763.digitalmar...@puremagic.com Okay... So @safe includes child scopes. I suppose @trusted and

Re: extern (c++) std::function?

2014-08-16 Thread Etienne via Digitalmars-d-learn
On 2014-08-15 6:12 AM, Rémy Mouëza wrote: assignments of anonymous/inline ones. You may want to add a layer of abstraction to the API you expose in D so that user D delegates are used from a second extern (C) delegate itself used by the C++ wrapper: Thanks for the detailed answer, this is the

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Philippe Sigaud via Digitalmars-d-learn
Artur: @safe, @trusted, @system, shared, immutable, const, inout and `extern (...)` affect child scopes. `synchronized` does too, but in a rather unintuitive way; hopefully nobody uses this. ;) Well, I also hope no one uses inout: at the module level? Other attributes, including 'pure' and

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-16 Thread Kagamin via Digitalmars-d-learn
On Friday, 15 August 2014 at 22:26:54 UTC, ketmar via Digitalmars-d-learn wrote: and we -- 32-bit addicts -- will run out of address space while 64-bit happy people will laugh looking at us. ;-) You should only choose stack size carefully or keep data in TempAlloc instead of stack.

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 16 Aug 2014 14:39:00 +0200 Artur Skawina via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 08/16/14 13:58, Philippe Sigaud via Digitalmars-d-learn wrote: On Sat, Aug 16, 2014 at 1:30 PM, Artur Skawina via Digitalmars-d-learn

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread monarch_dodra via Digitalmars-d-learn
On Saturday, 16 August 2014 at 19:30:16 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: On Sat, 16 Aug 2014 14:39:00 +0200 Artur Skawina via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 08/16/14 13:58, Philippe Sigaud via Digitalmars-d-learn wrote: On Sat, Aug 16,

Re: drop* and take* only for specific element values

2014-08-16 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 14 August 2014 at 07:30:59 UTC, Nordlöw wrote: On Thursday, 14 August 2014 at 00:56:47 UTC, Jonathan M Davis wrote: You forgot the !, making the predicate a function argument. It Great! My solution: Depending on your exact needs, don't forget too about findSkip (same as find,

Re: String Prefix Predicate

2014-08-16 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 14 August 2014 at 17:41:08 UTC, Nordlöw wrote: On Thursday, 14 August 2014 at 17:33:41 UTC, Justin Whear wrote: std.algorithm.startsWith? Should auto-decode, so it'll do a What about https://github.com/D-Programming-Language/phobos/pull/2043 Auto-decoding should be avoided

Re: String Prefix Predicate

2014-08-16 Thread monarch_dodra via Digitalmars-d-learn
On Saturday, 16 August 2014 at 20:59:47 UTC, monarch_dodra wrote: If anything, you are *preventing* the (many) opportunities phobos has to *avoid* decoding when it can... By that I want to stress what Jonathan M Davis said Unless the string types match, there's no way around it. You should

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, 16 August 2014 at 20:48:25 UTC, monarch_dodra wrote: On Saturday, 16 August 2014 at 19:30:16 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: On Sat, 16 Aug 2014 14:39:00 +0200 Artur Skawina via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: @safe, @trusted,

GC can collect object allocated in function, despite a pointer to the object living on?

2014-08-16 Thread 岩倉 澪
Hello, I've been interested in the D language for a few years now, but only dabble. I have read TDPL and recently started reading D Cookbook. On the side, I started to write a small game in D, but ran into a problem. I would greatly appreciate any help! My design is a simple state machine. I

Re: GC can collect object allocated in function, despite a pointer to the object living on?

2014-08-16 Thread Sean Kelly via Digitalmars-d-learn
Interface and object variables are reference types--you don't need the '*' to make them so. By adding the extra layer of indirection you're losing the only reference the GC can decipher to the currentState instance.

Re: GC can collect object allocated in function, despite a pointer to the object living on?

2014-08-16 Thread Chris Cain via Digitalmars-d-learn
On Saturday, 16 August 2014 at 22:36:51 UTC, 岩倉 澪 wrote: void changeState(){ if(nextState != WaitState nextState != ExitState){ auto newState = cast(IState) Object.factory(game.states.~nextState); import std.exception; enforce(newState); // !!!

Re: GC can collect object allocated in function, despite a pointer to the object living on?

2014-08-16 Thread 岩倉 澪
Thank you for the help! I just removed the unnecessary indirection and it is working great! I was aware that interface and object variables are reference types, but it slipped my mind. I'm too used to the C++ way of things still :p On Saturday, 16 August 2014 at 22:41:45 UTC, Sean Kelly wrote:

Re: GC can collect object allocated in function, despite a pointer to the object living on?

2014-08-16 Thread 岩倉 澪
I see now, makes sense. :) On Saturday, 16 August 2014 at 22:43:21 UTC, Chris Cain wrote: This is actually not garbage collection. newState is making a pointer to a reference that is located on the stack (that is, when you return from that function you now have a pointer that may at any time

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-16 Thread ketmar via Digitalmars-d-learn
On Sat, 16 Aug 2014 17:49:28 + Kagamin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You should only choose stack size carefully or keep data in TempAlloc instead of stack. but i can choose stack size carefully without such 'address reserving' feature. ;-)

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread ketmar via Digitalmars-d-learn
On Sat, 16 Aug 2014 20:48:23 + monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Well, you got @system to override @safe, but no @impure or @throws. So the behavior can kind of make sense in a way. Maybe. talking about attributes. the unability to reverse

Re: Ropes (concatenation trees) for strings in D ?

2014-08-16 Thread ketmar via Digitalmars-d-learn
On Sat, 16 Aug 2014 10:25:01 + MrSmith via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Can you also share your progress? here is public repo: http://repo.or.cz/w/etx.d.git remember, this is not even alpha-quality code (but it seems to be stable enough to build something upon