Re: Optional monitors suggestion

2014-09-16 Thread deadalnix via Digitalmars-d
On Tuesday, 13 May 2014 at 15:46:51 UTC, Yuriy wrote: Hello, I've played a bit with monitors, trying to make them optional, and here's what i've come up with: https://github.com/yglukhov/dmd/tree/optional_monitor https://github.com/yglukhov/druntime/tree/optional_monitors The whole idea is that

Re: Optional monitors suggestion

2014-09-16 Thread Steven Schveighoffer via Digitalmars-d
On Tue, 16 Sep 2014 15:01:17 -0400, Sean Kelly wrote: Yeah I haven't looked at the implementation yet either. Currently, it's possible to set a core.sync.Mutex as an object monitor. Would this capability be preserved? Someone mentioned a hashtable of monitors... do we really need this? I c

Re: Optional monitors suggestion

2014-09-16 Thread Sean Kelly via Digitalmars-d
Yeah I haven't looked at the implementation yet either. Currently, it's possible to set a core.sync.Mutex as an object monitor. Would this capability be preserved? Someone mentioned a hashtable of monitors... do we really need this? I can see the desire to preserve existing semantics and so a u

Re: Optional monitors suggestion

2014-09-16 Thread Steven Schveighoffer via Digitalmars-d
On Mon, 08 Sep 2014 12:57:13 -0400, Andrei Alexandrescu wrote: On 9/8/14, 2:10 AM, Andrej Mitrovic wrote: On Thursday, 22 May 2014 at 17:25:30 UTC, Steven Schveighoffer wrote: A possible path is to introduce the change, but put @monitor on Object. This will allow all current code to compile

Re: Optional monitors suggestion

2014-09-10 Thread Yuriy via Digitalmars-d
On Monday, 8 September 2014 at 16:56:49 UTC, Andrei Alexandrescu wrote: FWIW we could do this for backward compatibility: objects without @monitor use the hashtable, and those with @monitor use a field. And that's exactly what current PR suggests. However, it's stalled due to another issue. Th

Re: Optional monitors suggestion

2014-09-08 Thread Andrei Alexandrescu via Digitalmars-d
On 9/8/14, 2:10 AM, Andrej Mitrovic wrote: On Thursday, 22 May 2014 at 17:25:30 UTC, Steven Schveighoffer wrote: A possible path is to introduce the change, but put @monitor on Object. This will allow all current code to compile as-is. Then users who are concerned about their code being affecte

Re: Optional monitors suggestion

2014-09-08 Thread Andrej Mitrovic via Digitalmars-d
On Thursday, 22 May 2014 at 17:25:30 UTC, Steven Schveighoffer wrote: A possible path is to introduce the change, but put @monitor on Object. This will allow all current code to compile as-is. Then users who are concerned about their code being affected would be able to remove @monitor from Ob

Re: Optional monitors suggestion

2014-05-22 Thread Yuriy via Digitalmars-d
On Thursday, 22 May 2014 at 06:48:17 UTC, Martin Nowak wrote: I don't see why we need to introduce a global hashtable (performance impact, not pure). We could warn/deprecate/remove synchronizing on classes without the @monitor attribute. It's not only about synchronization. Signals use monitors

Re: Optional monitors suggestion

2014-05-22 Thread Steven Schveighoffer via Digitalmars-d
On Thu, 22 May 2014 02:48:16 -0400, Martin Nowak wrote: On Monday, 19 May 2014 at 07:11:41 UTC, Yuriy wrote: On Sunday, 18 May 2014 at 19:57:34 UTC, Walter Bright wrote: The "_monitor" slot is also used for std.signals. It's been set up in druntime to support more than just being a monitor.

Re: Optional monitors suggestion

2014-05-21 Thread Martin Nowak via Digitalmars-d
On Monday, 19 May 2014 at 07:11:41 UTC, Yuriy wrote: On Sunday, 18 May 2014 at 19:57:34 UTC, Walter Bright wrote: The "_monitor" slot is also used for std.signals. It's been set up in druntime to support more than just being a monitor. We've also considered it for a hook for a reference count

Re: Optional monitors suggestion

2014-05-20 Thread Martin Nowak via Digitalmars-d
If we didn't have to worry about being backwards compatible, I'd definitely argue for the second solution. Java compatibility is not a very strong argument in my opinion. First, porting a Java application 1:1 is asking for performance hazards (w.r.t. GC, ...) anyway. Second, the no-synchroniz

Re: Optional monitors suggestion

2014-05-19 Thread David Gileadi via Digitalmars-d
On 5/18/14, 7:10 AM, David Nadlinger wrote: ... Java classes could just be translated to "@synchronizable class" or whatever. Whether we preserve backwards compatibility or not, @synchronizable has my vote for the bikeshed's color.

Re: Optional monitors suggestion

2014-05-19 Thread Steven Schveighoffer via Digitalmars-d
On Sun, 18 May 2014 06:33:55 -0400, Andrei Alexandrescu wrote: On 5/17/14, 10:01 PM, Walter Bright wrote: On 5/14/2014 2:17 PM, Andrei Alexandrescu wrote: On 5/14/14, 6:33 AM, Yuriy wrote: 4. I consider D a killemall language, that may be potentially used on tiny AVRs and PICs, where polym

Re: Optional monitors suggestion

2014-05-19 Thread Yuriy via Digitalmars-d
On Sunday, 18 May 2014 at 19:57:34 UTC, Walter Bright wrote: The "_monitor" slot is also used for std.signals. It's been set up in druntime to support more than just being a monitor. We've also considered it for a hook for a reference count (though that design had other problems). I'm not sa

Re: Optional monitors suggestion

2014-05-18 Thread Jacob Carlborg via Digitalmars-d
On 19/05/14 08:29, Jacob Carlborg wrote: DWT is still around. Although, I don't have any memory of seeing the monitor being used. The "synchronized" statement is used in DWT. -- /Jacob Carlborg

Re: Optional monitors suggestion

2014-05-18 Thread Jacob Carlborg via Digitalmars-d
On 18/05/14 07:01, Walter Bright wrote: While I agree with Andrei's agreements (!), the rationale for the current approach is to make it relatively straightforward to translate existing Java code into D. There was a fair amount of this in the early days of D, I'm not sure how much of that lately

Re: Optional monitors suggestion

2014-05-18 Thread Walter Bright via Digitalmars-d
On 5/13/2014 8:46 AM, Yuriy wrote: Your feedback is very appreciated. Thanx. The "_monitor" slot is also used for std.signals. It's been set up in druntime to support more than just being a monitor. We've also considered it for a hook for a reference count (though that design had other prob

Re: Optional monitors suggestion

2014-05-18 Thread David Nadlinger via Digitalmars-d
On Sunday, 18 May 2014 at 10:33:53 UTC, Andrei Alexandrescu wrote: Maybe I misunderstood - I thought the change preserves semantics. -- Andrei There are two layers to the changes discussed in this thread. The first is to remove __monitor from Object. This is something I think we all agree on.

Re: Optional monitors suggestion

2014-05-18 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: Maybe I misunderstood - I thought the change preserves semantics. -- Andrei Perhaps it's Walter that has misunderstood. Bye, bearophile

Re: Optional monitors suggestion

2014-05-18 Thread Andrei Alexandrescu via Digitalmars-d
On 5/17/14, 10:01 PM, Walter Bright wrote: On 5/14/2014 2:17 PM, Andrei Alexandrescu wrote: On 5/14/14, 6:33 AM, Yuriy wrote: 4. I consider D a killemall language, that may be potentially used on tiny AVRs and PICs, where polymorphism might be welcome, but an extra pointer for each class instan

Re: Optional monitors suggestion

2014-05-17 Thread Yuriy via Digitalmars-d
On Sunday, 18 May 2014 at 05:01:21 UTC, Walter Bright wrote: While I agree with Andrei's agreements (!), the rationale for the current approach is to make it relatively straightforward to translate existing Java code into D. There was a fair amount of this in the early days of D, I'm not sure h

Re: Optional monitors suggestion

2014-05-17 Thread Yuriy via Digitalmars-d
On Sunday, 18 May 2014 at 04:44:56 UTC, Martin Nowak wrote: Global hashmap is a bad idea IMO because it's possibly expensive and impure. Rather deprecate synchronizing on classes without an explicit monitor. Totally agreed. Hashmap is done just not to break existing code. I don't think i've got

Re: Optional monitors suggestion

2014-05-17 Thread Walter Bright via Digitalmars-d
On 5/14/2014 2:17 PM, Andrei Alexandrescu wrote: On 5/14/14, 6:33 AM, Yuriy wrote: 4. I consider D a killemall language, that may be potentially used on tiny AVRs and PICs, where polymorphism might be welcome, but an extra pointer for each class instance may become a blocker. I know, thats fanta

Re: Optional monitors suggestion

2014-05-17 Thread Martin Nowak via Digitalmars-d
On Wednesday, 14 May 2014 at 09:16:21 UTC, Yuriy wrote: On Wednesday, 14 May 2014 at 08:37:41 UTC, bearophile wrote: What's the syntax to define a class without its __monitor? Are you using an annotation like @no_monitor? No syntax for that. The __monitor is not present by default anywhere. If

Re: Optional monitors suggestion

2014-05-16 Thread bearophile via Digitalmars-d
Yuriy: http://dpaste.dzfl.pl/f44762a17fe4 As workaround for a D design bug I suggest to write code like this: foreach (immutable c; 0 .. 100_000) Instead of: foreach(c; 0..10) Because unfortunately by default that c index is not immutable, and this causes significant troubles if you m

Re: Optional monitors suggestion

2014-05-16 Thread Yuriy via Digitalmars-d
On Wednesday, 14 May 2014 at 19:08:30 UTC, bearophile wrote: You are good. Before this is ready for Walter's judgement I think this needs some simple performance/memory benchmarks, to compare the situation before and after this change. I've made some minor optimizations, and rebased everything o

Re: Optional monitors suggestion

2014-05-14 Thread Andrei Alexandrescu via Digitalmars-d
On 5/14/14, 6:33 AM, Yuriy wrote: On Wednesday, 14 May 2014 at 13:07:32 UTC, bearophile wrote: I'd like to know why you think D classes should not have the monitor on default (this means why you don't plan for a @no_pointer). There are 4 reasons for that. 1. I'm thinking of monitors as members

Re: Optional monitors suggestion

2014-05-14 Thread bearophile via Digitalmars-d
Yuriy: Meanwhile, i've updated the PRs according to latest notes. @monitor attr, forbid __monitor declaration, so everyone can have some fun with it. =) You are good. Before this is ready for Walter's judgement I think this needs some simple performance/memory benchmarks, to compare the sit

Re: Optional monitors suggestion

2014-05-14 Thread Dejan Lekic via Digitalmars-d
Actually, I prefer your original proposal @no_monitor as I expect D classes to have monitors by default, until D eventually changes. Having @monitor implies that by default there are no monitors (which makes sense, but unfortunatelly that is not the current state of affairs in D).

Re: Optional monitors suggestion

2014-05-14 Thread Yuriy via Digitalmars-d
On Wednesday, 14 May 2014 at 14:44:07 UTC, Marc Schütz wrote: The object's layout and size also change, but the layout of objects is implementation defined AFAIK, and its size shouldn't be hard-coded anyway, so the breakage is minimal. You're right. Shared libraries will need to be rebuilt. Me

Re: Optional monitors suggestion

2014-05-14 Thread via Digitalmars-d
On Wednesday, 14 May 2014 at 14:07:50 UTC, Yuriy wrote: On Wednesday, 14 May 2014 at 13:53:51 UTC, Damian Day wrote: These would be breaking changes. I see the benefit but... Breaking, only if someone used to define __monitor in his class. Which is kinda weird, and according to docs (identifier

Re: Optional monitors suggestion

2014-05-14 Thread Yuriy via Digitalmars-d
On Wednesday, 14 May 2014 at 13:53:51 UTC, Damian Day wrote: These would be breaking changes. I see the benefit but... Breaking, only if someone used to define __monitor in his class. Which is kinda weird, and according to docs (identifiers starting with __ should are reserved). Or if someone u

Re: Optional monitors suggestion

2014-05-14 Thread bearophile via Digitalmars-d
Yuriy: 4. I consider D a killemall language, that may be potentially used on tiny AVRs and PICs, where polymorphism might be welcome, but an extra pointer for each class instance may become a blocker. I know, thats fantasy now, but i think it's crucial to keep this concept of D. It's wiser

Re: Optional monitors suggestion

2014-05-14 Thread Damian Day via Digitalmars-d
On Wednesday, 14 May 2014 at 11:06:43 UTC, Yuriy wrote: bearophile, good point. What do you think of the following solution: 1. Declaring member variable with __monitor identifier is disallowed. 2. class may be defined with @__monitor attribute, in which case a __monitor variable will be added

Re: Optional monitors suggestion

2014-05-14 Thread Yuriy via Digitalmars-d
On Wednesday, 14 May 2014 at 13:07:32 UTC, bearophile wrote: I'd like to know why you think D classes should not have the monitor on default (this means why you don't plan for a @no_pointer). There are 4 reasons for that. 1. I'm thinking of monitors as members of Object class, so all other cla

Re: Optional monitors suggestion

2014-05-14 Thread bearophile via Digitalmars-d
Yuriy: 2. class may be defined with @__monitor attribute, in which case a __monitor variable will be added to it's beginning. I'd like to know why you think D classes should not have the monitor on default (this means why you don't plan for a @no_pointer). Currently D classes have that poi

Re: Optional monitors suggestion

2014-05-14 Thread Yuriy via Digitalmars-d
On Wednesday, 14 May 2014 at 11:14:47 UTC, bearophile wrote: I suggest a name like "@monitor". The is no need for the underscores. Done. A more tidy design could require the @monitor in all classes that inherit from a @monitor-annotated class. But this also looks a little overkill. So let's h

Re: Optional monitors suggestion

2014-05-14 Thread bearophile via Digitalmars-d
Yuriy: 2. class may be defined with @__monitor attribute, in which case a __monitor variable will be added to it's beginning. I suggest a name like "@monitor". The is no need for the underscores. 3. Subclass of such class may again be defined with @__monitor attar, in which case it will b

Re: Optional monitors suggestion

2014-05-14 Thread Yuriy via Digitalmars-d
bearophile, good point. What do you think of the following solution: 1. Declaring member variable with __monitor identifier is disallowed. 2. class may be defined with @__monitor attribute, in which case a __monitor variable will be added to it's beginning. 3. Subclass of such class may again be

Re: Optional monitors suggestion

2014-05-14 Thread bearophile via Digitalmars-d
Yuriy: No syntax for that. The __monitor is not present by default anywhere. If you need it, you need to define one. class B { void* __monitor; What kind of clear error messages do you receive if you write: class B { void* _monitor; Or: class B { size_t __monitor; This isn'

Re: Optional monitors suggestion

2014-05-14 Thread Yuriy via Digitalmars-d
On Wednesday, 14 May 2014 at 08:37:41 UTC, bearophile wrote: What's the syntax to define a class without its __monitor? Are you using an annotation like @no_monitor? No syntax for that. The __monitor is not present by default anywhere. If you need it, you need to define one. class A { } clas

Re: Optional monitors suggestion

2014-05-14 Thread bearophile via Digitalmars-d
Yuriy: Your feedback is very appreciated. Thanx. What's the syntax to define a class without its __monitor? Are you using an annotation like @no_monitor? Bye, bearophile

Re: Optional monitors suggestion

2014-05-14 Thread Yuriy via Digitalmars-d
Ok, i think i've found a simple yet effective solution. Implemented and pushed to the repo. Any more thoughts before a PR?

Re: Optional monitors suggestion

2014-05-13 Thread Yuriy via Digitalmars-d
The only downside i see here is that finalization of every object will now lookup for a corresponding monitor, if it's class doesn't define embedded one. Ok, i think i've found a simple yet effective solution. Adding a flag to ClassFlags: hasAllocatedMonitors. Mark m_flags with this flag in run

Re: Optional monitors suggestion

2014-05-13 Thread Andrei Alexandrescu via Digitalmars-d
On 5/13/14, 8:46 AM, Yuriy wrote: Hello, I've played a bit with monitors, trying to make them optional, and here's what i've come up with: https://github.com/yglukhov/dmd/tree/optional_monitor https://github.com/yglukhov/druntime/tree/optional_monitors The whole idea is that Object doesn't conta

Re: Optional monitors suggestion

2014-05-13 Thread Dmitry Olshansky via Digitalmars-d
13-May-2014 19:46, Yuriy пишет: Hello, I've played a bit with monitors, trying to make them optional, and here's what i've come up with: https://github.com/yglukhov/dmd/tree/optional_monitor https://github.com/yglukhov/druntime/tree/optional_monitors The whole idea is that Object doesn't contain

Optional monitors suggestion

2014-05-13 Thread Yuriy via Digitalmars-d
Hello, I've played a bit with monitors, trying to make them optional, and here's what i've come up with: https://github.com/yglukhov/dmd/tree/optional_monitor https://github.com/yglukhov/druntime/tree/optional_monitors The whole idea is that Object doesn't contain __monitor field anymore. TypeI