Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-24 Thread Dmitry Olshansky
23-May-2013 01:23, Idan Arye пишет: On Tuesday, 21 May 2013 at 17:40:02 UTC, Idan Arye wrote: On Tuesday, 21 May 2013 at 14:58:16 UTC, Idan Arye wrote: At any rate, I am forced to admit I made a mistake about `hasIntance()` not needing synchronization. I neglected the possibility that the

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-24 Thread Jonathan M Davis
On Friday, May 24, 2013 17:42:59 Dmitry Olshansky wrote: There was a pull that allowed to separate qualifier of instance from reference (handle) looking like this: ref const(Object) refToConst; ref Object mutableTlsRef; Object mutableTlsRef; //same as above ref const Object

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-24 Thread Dmitry Olshansky
24-May-2013 22:13, Jonathan M Davis пишет: On Friday, May 24, 2013 17:42:59 Dmitry Olshansky wrote: There was a pull that allowed to separate qualifier of instance from reference (handle) looking like this: ref const(Object) refToConst; ref Object mutableTlsRef; Object mutableTlsRef; //same

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-24 Thread Idan Arye
On Friday, 24 May 2013 at 13:43:02 UTC, Dmitry Olshansky wrote: I've found github pages to be just fine. Then GitHub pages it is - http://someboddy.github.io/phobos/ddocs/for-idioms/idioms.html I've also added this link to the pull request and to the review queue. Turns out that doing

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-24 Thread Idan Arye
And here is the Phobos solution: http://d.puremagic.com/issues/show_bug.cgi?id=10165 https://github.com/D-Programming-Language/phobos/pull/1302

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-24 Thread Jonathan M Davis
On Saturday, May 25, 2013 00:08:37 Dmitry Olshansky wrote: 24-May-2013 22:13, Jonathan M Davis пишет: Lacking a proper language solution, we could create something similar to Rebindable but for shared. Then in my vision built-in OOP has failed if we need at least 2 wrapper types

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-22 Thread Idan Arye
On Tuesday, 21 May 2013 at 14:58:16 UTC, Idan Arye wrote: At any rate, I am forced to admit I made a mistake about `hasIntance()` not needing synchronization. I neglected the possibility that the constructor(or anything else used for initialization) can throw! The compiler might decide that

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-22 Thread Idan Arye
On Tuesday, 21 May 2013 at 17:40:02 UTC, Idan Arye wrote: On Tuesday, 21 May 2013 at 14:58:16 UTC, Idan Arye wrote: At any rate, I am forced to admit I made a mistake about `hasIntance()` not needing synchronization. I neglected the possibility that the constructor(or anything else used for

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-21 Thread Dmitry Olshansky
21-May-2013 02:02, Idan Arye пишет: On Monday, 20 May 2013 at 19:15:34 UTC, Dmitry Olshansky wrote: If you need synchronization and coordination based on what the reference happens to be right now then there are tools far better fit for the job - mutexes, semaphore, condition vars etc.

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-21 Thread Idan Arye
On Tuesday, 21 May 2013 at 06:44:02 UTC, Dmitry Olshansky wrote: A-ha. That's it and it's totally wrong. Exposing as much interface as possible is a disaster. Libraries (esp standard) take great deal of deliberation in picking what to expose. Exposing less is a common theme in interfaces.

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-21 Thread Idan Arye
At any rate, I am forced to admit I made a mistake about `hasIntance()` not needing synchronization. I neglected the possibility that the constructor(or anything else used for initialization) can throw! The compiler might decide that it's better to write the global reference first, and if

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Idan Arye
On Monday, 20 May 2013 at 05:39:42 UTC, Diggory wrote: In your logic you're assuming that the order of operations is maintained - without the correct memory barriers or synchronisation both the compiler and CPU are free to completely reorder any operations you do. That's why it's always a bug

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Diggory
On Monday, 20 May 2013 at 06:53:34 UTC, Idan Arye wrote: On Monday, 20 May 2013 at 05:39:42 UTC, Diggory wrote: In your logic you're assuming that the order of operations is maintained - without the correct memory barriers or synchronisation both the compiler and CPU are free to completely

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Idan Arye
On Monday, 20 May 2013 at 11:19:44 UTC, Diggory wrote: Of course it's possible, for example the code may produce the expected result if some invariant holds which does in fact hold if there was a single thread running, but with multiple threads the invariant is broken. Or more simply - the

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Dmitry Olshansky
20-May-2013 19:28, Idan Arye пишет: On Monday, 20 May 2013 at 11:19:44 UTC, Diggory wrote: Of course it's possible, for example the code may produce the expected result if some invariant holds which does in fact hold if there was a single thread running, but with multiple threads the invariant

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Idan Arye
On Monday, 20 May 2013 at 16:40:27 UTC, Dmitry Olshansky wrote: Long story short - re-read the discussion in the Low-lock thread again: http://forum.dlang.org/thread/pelhvaxwjzhehdjtp...@forum.dlang.org To sum up the discussion, there are three problems with unsynchronized access to the

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Dmitry Olshansky
20-May-2013 22:14, Idan Arye пишет: On Monday, 20 May 2013 at 16:40:27 UTC, Dmitry Olshansky wrote: Long story short - re-read the discussion in the Low-lock thread again: http://forum.dlang.org/thread/pelhvaxwjzhehdjtp...@forum.dlang.org To sum up the discussion, there are three problems

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Jesse Phillips
On Saturday, 18 May 2013 at 16:58:19 UTC, Idan Arye wrote: OK, I implemented everything and made a pull request: https://github.com/D-Programming-Language/phobos/pull/1294 I've added this to the review queue. The module is in need of documentation (publishing not required) before it can be

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Jesse Phillips
On Monday, 20 May 2013 at 21:01:36 UTC, Jesse Phillips wrote: On Saturday, 18 May 2013 at 16:58:19 UTC, Idan Arye wrote: OK, I implemented everything and made a pull request: https://github.com/D-Programming-Language/phobos/pull/1294 I've added this to the review queue. The module is in need

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Idan Arye
On Monday, 20 May 2013 at 19:15:34 UTC, Dmitry Olshansky wrote: 20-May-2013 22:14, Idan Arye пишет: 1) It doesn't matter if the object is not ready, because when you want to actually access the object, you need to use `instance()` which has synchronization. Then where you see hasInstance to

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Idan Arye
On Monday, 20 May 2013 at 21:08:36 UTC, Jesse Phillips wrote: On Monday, 20 May 2013 at 21:01:36 UTC, Jesse Phillips wrote: On Saturday, 18 May 2013 at 16:58:19 UTC, Idan Arye wrote: OK, I implemented everything and made a pull request:

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Diggory
On Monday, 20 May 2013 at 22:02:57 UTC, Idan Arye wrote: On Monday, 20 May 2013 at 19:15:34 UTC, Dmitry Olshansky wrote: 20-May-2013 22:14, Idan Arye пишет: 1) It doesn't matter if the object is not ready, because when you want to actually access the object, you need to use `instance()` which

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-20 Thread Idan Arye
On Monday, 20 May 2013 at 23:18:59 UTC, Diggory wrote: On Monday, 20 May 2013 at 22:02:57 UTC, Idan Arye wrote: If `hasInstance()` returns `true`, you can assume that there is an instance for you to access, because even if the instance is not ready yet, some other thread has entered the

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-19 Thread Diggory
On Saturday, 18 May 2013 at 16:58:19 UTC, Idan Arye wrote: OK, I implemented everything and made a pull request: https://github.com/D-Programming-Language/phobos/pull/1294 Nice, but the singleton implementation seems somewhat over-complicated, and the low-lock singleton is broken, possibly

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-19 Thread Idan Arye
On Sunday, 19 May 2013 at 08:36:24 UTC, Diggory wrote: On Saturday, 18 May 2013 at 16:58:19 UTC, Idan Arye wrote: OK, I implemented everything and made a pull request: https://github.com/D-Programming-Language/phobos/pull/1294 Nice, but the singleton implementation seems somewhat

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-19 Thread Diggory
There is no point in saving a thread local reference to the global instance. The `__gshared` instance is never changed once initialized, so if we saved a thread local reference, it would *always* be either null or the same as the `__gshared` one - which means that if the local reference is

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-19 Thread Idan Arye
On Sunday, 19 May 2013 at 20:35:06 UTC, Diggory wrote: There is no point in saving a thread local reference to the global instance. The `__gshared` instance is never changed once initialized, so if we saved a thread local reference, it would *always* be either null or the same as the

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-19 Thread Idan Arye
On Sunday, 19 May 2013 at 20:35:06 UTC, Diggory wrote: It's also less efficient as you have to read both the thread-local boolean and the __gshared instance. Since the thread-local boolean is likely going to use a word anyway you may as well store the instance in there instead. This is a

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-19 Thread Diggory
In your logic you're assuming that the order of operations is maintained - without the correct memory barriers or synchronisation both the compiler and CPU are free to completely reorder any operations you do. That's why it's always a bug to access mutable shared data without synchronisation -

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-18 Thread Idan Arye
OK, I implemented everything and made a pull request: https://github.com/D-Programming-Language/phobos/pull/1294

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-13 Thread Tove
On Friday, 10 May 2013 at 21:04:32 UTC, Idan Arye wrote: On Wednesday, 8 May 2013 at 20:11:34 UTC, Idan Arye wrote: OK, so I'm gonna go ahead and implement it, so I can show by example that the string solution can be typesafe, scalable and elegant. OK, this is a basic implementation:

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-11 Thread skeptical
In article pgasgjrfryfbwkebb...@forum.dlang.org, generic...@gmail.com says... On Wednesday, 8 May 2013 at 20:11:34 UTC, Idan Arye wrote: Aryan?? White premisey your message? Wait, Ary lye-in-dyke won the indie 4500, is he gay? OMG, DYKES are the issue! How many dykes have driven race cars?

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-10 Thread Idan Arye
On Wednesday, 8 May 2013 at 20:11:34 UTC, Idan Arye wrote: OK, so I'm gonna go ahead and implement it, so I can show by example that the string solution can be typesafe, scalable and elegant. OK, this is a basic implementation: https://gist.github.com/someboddy/5557358 Before I can make the

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-10 Thread Diggory
On Friday, 10 May 2013 at 21:04:32 UTC, Idan Arye wrote: On Wednesday, 8 May 2013 at 20:11:34 UTC, Idan Arye wrote: OK, so I'm gonna go ahead and implement it, so I can show by example that the string solution can be typesafe, scalable and elegant. OK, this is a basic implementation:

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-08 Thread Idan Arye
OK, so I'm gonna go ahead and implement it, so I can show by example that the string solution can be typesafe, scalable and elegant.

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-07 Thread Jacob Carlborg
On 2013-05-07 01:20, Idan Arye wrote: However, your idea of having a single mixin handle all the class\struct's properties gave me another idea - to use a single mixin, but instead of having it analyze the owner class to find the fields we want to make properties, we simply give them to it with

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-07 Thread Dicebot
I really think that UDA annotations + single mixin like this: class Test { private: // annotated stuff public: mixin implementAnnotations!Test; } is a most type-safe approach which scales.

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-07 Thread Idan Arye
On Tuesday, 7 May 2013 at 08:58:47 UTC, Dicebot wrote: I really think that UDA annotations + single mixin like this: class Test { private: // annotated stuff public: mixin implementAnnotations!Test; } is a most type-safe approach which scales. I think any method will

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-07 Thread Dicebot
On Tuesday, 7 May 2013 at 19:10:23 UTC, Idan Arye wrote: So, we have to change it: class Test { private: @Property int m_foo; public: mixin implementAnnotations!Test; } and inside `implementAnnotations` we would have to strip `m_foo` out of

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-07 Thread Idan Arye
On Tuesday, 7 May 2013 at 19:10:23 UTC, Idan Arye wrote: Anyways, a small enhancement to dmd can help solve both problems easily - a mixin template that has an identifier and does not leak to the surrounding scope. Actually, forget about that enhancement - I can use aliases, CTFE and a mixin

I want to add a Phobos module with template mixins for common idioms.

2013-05-06 Thread Idan Arye
Template mixins can be used to implement some common programming idioms(and design patterns). I have already implemented two of them for my own project - and I want to make them into a Phobos module - maybe `std.mixins`. The wiki at http://wiki.dlang.org/Review/Process says that before I start

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-06 Thread Diggory
It's a nice idea but personally I don't like the syntax much, for example it's completely non-obvious what true does when passed to the singleton mixin, or that the parameters to the property mixin are type, name, condition, initial value. I suppose you could do something like this: mixin

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-06 Thread Andrei Alexandrescu
On 5/6/13 3:14 PM, Idan Arye wrote: Template mixins can be used to implement some common programming idioms(and design patterns). I have already implemented two of them for my own project - and I want to make them into a Phobos module - maybe `std.mixins`. Nice idea, but at the first level of

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-06 Thread Robert Rouse
On Monday, 6 May 2013 at 19:57:27 UTC, Andrei Alexandrescu wrote: On 5/6/13 3:14 PM, Idan Arye wrote: Template mixins can be used to implement some common programming idioms(and design patterns). I have already implemented two of them for my own project - and I want to make them into a Phobos

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-06 Thread Andrei Alexandrescu
On 5/6/13 4:03 PM, Robert Rouse wrote: On Monday, 6 May 2013 at 19:57:27 UTC, Andrei Alexandrescu wrote: On 5/6/13 3:14 PM, Idan Arye wrote: Template mixins can be used to implement some common programming idioms(and design patterns). I have already implemented two of them for my own project -

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-06 Thread Idan Arye
On Monday, 6 May 2013 at 20:10:59 UTC, Andrei Alexandrescu wrote: On 5/6/13 4:03 PM, Robert Rouse wrote: On Monday, 6 May 2013 at 19:57:27 UTC, Andrei Alexandrescu wrote: On 5/6/13 3:14 PM, Idan Arye wrote: Template mixins can be used to implement some common programming idioms(and design

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-06 Thread Idan Arye
On Monday, 6 May 2013 at 19:47:33 UTC, Diggory wrote: It's a nice idea but personally I don't like the syntax much, for example it's completely non-obvious what true does when passed to the singleton mixin, or that the parameters to the property mixin are type, name, condition, initial value.

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-06 Thread Idan Arye
On Monday, 6 May 2013 at 21:18:56 UTC, Idan Arye wrote: Anyways, I'll have to add a new trait template to extract the name from the declaration(Compile time regex are too slow) You know what? I take that back. I can probably pull this off with an anonymous struct to get better compilation

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-06 Thread Steven Schveighoffer
On Mon, 06 May 2013 17:13:00 -0400, Idan Arye generic...@gmail.com wrote: On Monday, 6 May 2013 at 19:47:33 UTC, Diggory wrote: It's a nice idea but personally I don't like the syntax much, for example it's completely non-obvious what true does when passed to the singleton mixin, or that

Re: I want to add a Phobos module with template mixins for common idioms.

2013-05-06 Thread Idan Arye
On Monday, 6 May 2013 at 21:58:08 UTC, Steven Schveighoffer wrote: On Mon, 06 May 2013 17:13:00 -0400, Idan Arye generic...@gmail.com wrote: On Monday, 6 May 2013 at 19:47:33 UTC, Diggory wrote: It's a nice idea but personally I don't like the syntax much, for example it's completely