Implementing SmartPtr - compiler bug?

2014-10-27 Thread Shachar Shemesh via Digitalmars-d-learn
For reasons I won't go into (but should be fairly obvious), I am trying to write code that does not rely on the garbage collector. As such, I'm using reference counting structs allocated on a pool. To keep things sane, I'm trying to use RAII semantics, and to that end, a smart pointer that

Re: Implementing SmartPtr - compiler bug?

2014-10-27 Thread ketmar via Digitalmars-d-learn
just checked this with gdc and dmd head. interesting that a = a.init; works the same in gdc and in dmd: just calls destructors for structs. but doing a[] = S.init works different. gdc does the same as in the first case: just calling destructors for all array elements. but dmd head calls

Re: Implementing SmartPtr - compiler bug?

2014-10-27 Thread Szymon Gatner via Digitalmars-d-learn
On Monday, 27 October 2014 at 07:31:34 UTC, Shachar Shemesh wrote: For reasons I won't go into (but should be fairly obvious), I am trying to write code that does not rely on the garbage collector. As such, I'm using reference counting structs allocated on a pool. To keep things sane, I'm

Re: Where is a variable declared in a module allocated?

2014-10-27 Thread John Colvin via Digitalmars-d-learn
On Saturday, 25 October 2014 at 22:16:12 UTC, John Colvin wrote: On Saturday, 25 October 2014 at 21:52:13 UTC, MachineCode wrote: Where is a variable declared in a module allocated? is it same as a C's global? for example: module foo; int myvar; that is in thread local storage. __shared,

Re: Implementing SmartPtr - compiler bug?

2014-10-27 Thread ketmar via Digitalmars-d-learn
On Mon, 27 Oct 2014 09:11:33 + Szymon Gatner via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You have created dynamic array of SmartPtrs. nope. it's stack-allocated array. signature.asc Description: PGP signature

Re: Implementing SmartPtr - compiler bug?

2014-10-27 Thread Szymon Gatner via Digitalmars-d-learn
On Monday, 27 October 2014 at 09:21:14 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 27 Oct 2014 09:11:33 + Szymon Gatner via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You have created dynamic array of SmartPtrs. nope. it's stack-allocated array. Right, sorry.

Re: Reflections on isPalindrome

2014-10-27 Thread via Digitalmars-d-learn
On Sunday, 26 October 2014 at 20:38:29 UTC, Nordlöw wrote: On Friday, 24 October 2014 at 22:29:12 UTC, Peter Alexander wrote: Further, I would like to extend isPalindrome() with a minimum length argument minLength that for string and wstring does I extended my algorithm with a minLength

Re: Implementing SmartPtr - compiler bug?

2014-10-27 Thread Shachar Shemesh via Digitalmars-d-learn
On 27/10/14 11:31, Szymon Gatner wrote: Right, sorry. Tho I admit I made assumptions since that was not the full code. I've opened a bug. It has a fully contained sample (that does not, in fact, implement smartptr). https://issues.dlang.org/show_bug.cgi?id=13661

Re: Problems with Mutex

2014-10-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/26/14 7:13 PM, ketmar via Digitalmars-d-learn wrote: On Sun, 26 Oct 2014 22:53:07 + Neven via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Why cannot I globally have auto mutex = new Mutex? And why it works now when I put __gshared? this is because 'auto mutex = new

Re: Problems with Mutex

2014-10-27 Thread ketmar via Digitalmars-d-learn
On Mon, 27 Oct 2014 09:24:13 -0400 Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Just as a followup, for some reason Mutex is not callable as a shared object, so you have to make it __gshared. that's due to difference betwen plain type and shared type.

Re: Problems with Mutex

2014-10-27 Thread ketmar via Digitalmars-d-learn
On Mon, 27 Oct 2014 09:24:13 -0400 Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Just as a followup, for some reason Mutex is not callable as a shared object, so you have to make it __gshared. This is unfortunate, but it is the only way to do it right

Re: Implementing SmartPtr - compiler bug?

2014-10-27 Thread via Digitalmars-d-learn
On Monday, 27 October 2014 at 12:40:17 UTC, Shachar Shemesh wrote: On 27/10/14 11:31, Szymon Gatner wrote: Right, sorry. Tho I admit I made assumptions since that was not the full code. I've opened a bug. It has a fully contained sample (that does not, in fact, implement smartptr).

Re: Problems with Mutex

2014-10-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/27/14 9:34 AM, ketmar via Digitalmars-d-learn wrote: On Mon, 27 Oct 2014 09:24:13 -0400 Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Just as a followup, for some reason Mutex is not callable as a shared object, so you have to make it __gshared.

Re: Reflections on isPalindrome

2014-10-27 Thread Nordlöw
On Monday, 27 October 2014 at 12:10:59 UTC, Marc Schütz wrote: You could add an early `return false;` if the range has length and it is less than minLength. See update :) Thanks!

Re: Implementing SmartPtr - compiler bug?

2014-10-27 Thread Szymon Gatner via Digitalmars-d-learn
On Monday, 27 October 2014 at 14:04:53 UTC, Marc Schütz wrote: On Monday, 27 October 2014 at 12:40:17 UTC, Shachar Shemesh wrote: On 27/10/14 11:31, Szymon Gatner wrote: Right, sorry. Tho I admit I made assumptions since that was not the full code. I've opened a bug. It has a fully

Re: Implementing SmartPtr - compiler bug?

2014-10-27 Thread via Digitalmars-d-learn
On Monday, 27 October 2014 at 16:58:56 UTC, Szymon Gatner wrote: On Monday, 27 October 2014 at 14:04:53 UTC, Marc Schütz wrote: On Monday, 27 October 2014 at 12:40:17 UTC, Shachar Shemesh wrote: On 27/10/14 11:31, Szymon Gatner wrote: Right, sorry. Tho I admit I made assumptions since that

Re: Problems with Mutex

2014-10-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 27, 2014 09:24:13 Steven Schveighoffer via Digitalmars-d- learn wrote: Just as a followup, for some reason Mutex is not callable as a shared object, so you have to make it __gshared. This is unfortunate, but it is the only way to do it right now. Because an actual mutex is

Re: Reflections on isPalindrome

2014-10-27 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 27 October 2014 at 16:59:19 UTC, Nordlöw wrote: On Monday, 27 October 2014 at 12:10:59 UTC, Marc Schütz wrote: You could add an early `return false;` if the range has length and it is less than minLength. See update :) Thanks! And you can return true if length = 1 Why

Need assistance translating this C++ template

2014-10-27 Thread John via Digitalmars-d-learn
Howdy, I stumbled across a tiny NES emulator written in C++ (http://bisqwit.iki.fi/jutut/kuvat/programming_examples/nesemu1/nesemu1.cc) that I feel compelled to make even tinier with some D magic. I am having trouble with a nested template in the code. The C++ code: // Bitfield utilities

Re: Need assistance translating this C++ template

2014-10-27 Thread Justin Whear via Digitalmars-d-learn
On Mon, 27 Oct 2014 22:43:22 +, John wrote: void opAssign(T2 val) Without looking at the rest of your code, looks like this line needs to be void opAssign(T2)(T2 val)

Re: Reflections on isPalindrome

2014-10-27 Thread Nordlöw
On Monday, 27 October 2014 at 21:28:17 UTC, Andrea Fontana wrote: And you can return true if length = 1 Thanks. Why bidirectional range only? popBack() only for http://dlang.org/phobos/std_range.html#isBidirectionalRange

Re: Need assistance translating this C++ template

2014-10-27 Thread anonymous via Digitalmars-d-learn
On Monday, 27 October 2014 at 22:43:23 UTC, John wrote: The C++ code: // Bitfield utilities templateunsigned bitno, unsigned nbits=1, typename T=u8 struct RegBit { [...] templatetypename T2 RegBit operator=(T2 val) [...] }; My D implementation thus far: [...] template RegBit(uint

Re: Need assistance translating this C++ template

2014-10-27 Thread John via Digitalmars-d-learn
On Monday, 27 October 2014 at 23:19:42 UTC, anonymous wrote: On Monday, 27 October 2014 at 22:43:23 UTC, John wrote: The C++ code: // Bitfield utilities templateunsigned bitno, unsigned nbits=1, typename T=u8 struct RegBit { [...] templatetypename T2 RegBit operator=(T2 val) [...] };

Creation of 0MQ D project

2014-10-27 Thread Evan Lowry via Digitalmars-d-learn
Hey all, I've been playing around w/ D for a little while, and figured I would dive more into it with some side project stuff that has come up at work. The interface I am hooking up to is a zmq server, so I created a dub.json file ~ as follows: { dependencies: { zeromq: ~master,

Embedding D Shared Library in WSGI Web Server

2014-10-27 Thread John McFarlane via Digitalmars-d-learn
Hi, I've written a modest shared library in D that I'd like to call directly from a Python web server (Linux/OS X, Apache, WSGI, Pyramid). I can call it reliably from within Python unit tests but on a running server, the library causes a SIGSEGV as soon as I try anything as complicated as a

Re: Creation of 0MQ D project

2014-10-27 Thread anonymous via Digitalmars-d-learn
On Monday, 27 October 2014 at 23:56:11 UTC, Evan Lowry wrote: ../../.dub/packages/zeromq-master/deimos/zmq/zmq.d(96): Error: function deimos.zmq.zmq.zmq_strerror without 'this' cannot be const You found a bug in the binding. Line 96 of zmq.d [1]: const char* zmq_strerror(int errnum); Should

Tagged enums why reserved words are not permitted ?

2014-10-27 Thread Domingo via Digitalmars-d-learn
Hello ! I'm not sure if I'm missing something here but for a tagged enum it doesn't seem to make sense to forbid reserved keywords like: enum CrudOps {read, write, delete} The dmd compiler are complaining: -- cte.d(4): Error: basic type expected, not delete cte.d(4): Error: no identifier

Re: Tagged enums why reserved words are not permitted ?

2014-10-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 28, 2014 00:31:43 Domingo via Digitalmars-d-learn wrote: Hello ! I'm not sure if I'm missing something here but for a tagged enum it doesn't seem to make sense to forbid reserved keywords like: enum CrudOps {read, write, delete} The dmd compiler are complaining: --

Re: Tagged enums why reserved words are not permitted ?

2014-10-27 Thread ketmar via Digitalmars-d-learn
On Tue, 28 Oct 2014 00:31:43 + Domingo via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hello ! I'm not sure if I'm missing something here but for a tagged enum it doesn't seem to make sense to forbid reserved keywords like: enum CrudOps {read, write, delete} The

Re: Tagged enums why reserved words are not permitted ?

2014-10-27 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 28, 2014 at 12:31:43AM +, Domingo via Digitalmars-d-learn wrote: Hello ! I'm not sure if I'm missing something here but for a tagged enum it doesn't seem to make sense to forbid reserved keywords like: enum CrudOps {read, write, delete} The dmd compiler are complaining:

Re: Creation of 0MQ D project

2014-10-27 Thread Evan Lowry via Digitalmars-d-learn
On Tuesday, 28 October 2014 at 00:21:20 UTC, anonymous wrote: Line 96 of zmq.d [1]: const char* zmq_strerror(int errnum); Should be: const(char)* zmq_strerror(int errnum); Yep, this seemed to do the trick cleanly. S'all compiling and the examples provided in the repo run. Can submit a pull

Re: Creation of 0MQ D project

2014-10-27 Thread Matt Soucy via Digitalmars-d-learn
On 10/27/2014 09:02 PM, Evan Lowry wrote: On Tuesday, 28 October 2014 at 00:21:20 UTC, anonymous wrote: Line 96 of zmq.d [1]: const char* zmq_strerror(int errnum); Should be: const(char)* zmq_strerror(int errnum); Yep, this seemed to do the trick cleanly. S'all compiling and the examples

Cheap Kitchens in North London

2014-10-27 Thread lupalupa via Digitalmars-d-learn
Cheap Kitchens in North London. Thirty Ex Display Kitchens To Clear. w w w. e x d i s p l a y k i t c h e n s 1. c o. u k £ 595 Each with appliances.Tel 01616-694785