Re: Cannot compare object.opEquals is not nogc

2016-08-02 Thread Mark J Twain via Digitalmars-d-learn
A hack is to create the gc code you in a function want to call, say does the "gc" opEquals. Then cast that function to a nogc version by first casting to a void*. This way you can call gc code from nogc code, by bypassing the compiler's ability to check. It will obviously break your code if

Re: Cannot compare object.opEquals is not nogc

2016-07-31 Thread ag0aep6g via Digitalmars-d-learn
On 07/31/2016 08:43 PM, Rufus Smith wrote: e.g., I have a nogc container and a remove(T obj). I can't search for obj and remove it because opEquals is not marked nogc. So I need an alternative that is somewhat robust. Jonathan M Davis has already mentioned his plans to templatize

Re: Cannot compare object.opEquals is not nogc

2016-07-31 Thread Rufus Smith via Digitalmars-d-learn
On Monday, 25 July 2016 at 12:24:53 UTC, Steven Schveighoffer wrote: On 7/23/16 5:44 PM, Rufus Smith wrote: [...] Again, I want to stress that Object.opEquals has been around since early D1 days, @nogc is only a few years old, it was not a wrong decision. @nogc cannot be added without

Re: Cannot compare object.opEquals is not nogc

2016-07-31 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function 'object.opEquals' Shouldn't object opEquals be marked? So, I need to compare two

Re: Cannot compare object.opEquals is not nogc

2016-07-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/23/16 5:44 PM, Rufus Smith wrote: On Saturday, 23 July 2016 at 17:27:24 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 17:04:42 UTC, Jonathan Marler wrote: On Saturday, 23 July 2016 at 16:46:20 UTC, Jonathan Marler wrote: [...] Actually Im going to disagree with myself.

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:41:55 UTC, Lodovico Giaretta wrote: On Sunday, 24 July 2016 at 15:28:53 UTC, Jonathan Marler wrote: Whoa wait a second...I didn't know you could do this. I thought everything had to inherit from the object class. Can you share the syntax to define a class that

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:31:28 UTC, lqjglkqjsg wrote: Almost off topic but I've recognized a typical error here, I think that many of us have already seen it too. You develop a nice class. You put attributes everywhere @safe pure nothrow @nogc. Yay the unittest pass. Later you use it

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:28:53 UTC, Jonathan Marler wrote: Whoa wait a second...I didn't know you could do this. I thought everything had to inherit from the object class. Can you share the syntax to define a class that doesn't derive from object? Currently, you cannot. Everything

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread lqjglkqjsg via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:09:53 UTC, Lodovico Giaretta wrote: Yes, making them @nogc would require all existing overrides to be changed (overrides cannot throw away attributes, but must specify them explicitly as in the parent class, or stricter). The real problem making these @nogc is that

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:09:53 UTC, Lodovico Giaretta wrote: Remember that comparison of complex objects may require normalization, which may change the objects themselves and allocate memory. Sure but this case will be the exception. If an application really needs this they can

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 24 July 2016 at 14:54:11 UTC, Jonathan Marler wrote: I believe Rufus was only referring to the virtual methods defined in the object class. That would be: toHash (Note: this is already nothrow, that's intersting and quite restrictive) opCmp opEquals I think all 3 of these are

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 09:03:04 UTC, Lodovico Giaretta wrote: On Sunday, 24 July 2016 at 02:17:27 UTC, Rufus Smith wrote: [...] Now you are telling me to "program by trust", because there's nothing ensuring that I remember to free everything I allocated with malloc/free, while a GC

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Lodovico Giaretta via Digitalmars-d-learn
On Sunday, 24 July 2016 at 02:17:27 UTC, Rufus Smith wrote: This just isn't right. What your saying is that because someone screwed up, we must live with the screw up and build everyone around the screw up. This mentality is why everyone is so screwed up in the first place, do you not see

Re: Cannot compare object.opEquals is not nogc

2016-07-24 Thread Jonathan Marler via Digitalmars-d-learn
On Sunday, 24 July 2016 at 02:17:27 UTC, Rufus Smith wrote: On Saturday, 23 July 2016 at 22:48:07 UTC, Lodovico Giaretta wrote: [...] This just isn't right. What your saying is that because someone screwed up, we must live with the screw up and build everyone around the screw up. This

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 22:48:07 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 21:44:05 UTC, Rufus Smith wrote: On Saturday, 23 July 2016 at 17:27:24 UTC, Lodovico Giaretta wrote: - we trust what we are doing: e.g. we cannot mark a thing @nogc, but we know it is and the

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 23 July 2016 at 21:44:05 UTC, Rufus Smith wrote: On Saturday, 23 July 2016 at 17:27:24 UTC, Lodovico Giaretta wrote: - we trust what we are doing: e.g. we cannot mark a thing @nogc, but we know it is and the profiler confirms that no allocation happens, so we are happy; our

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 23 July 2016 at 21:44:05 UTC, Rufus Smith wrote: Templates are not the end all be all. They don't allow for run-time polymorphism, which is an important aspect of software. Ok, so you need runtime polymorphism. And you want it in @nogc code. That's not difficult. Just have the

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 23, 2016 21:33:29 Rufus Smith via Digitalmars-d-learn wrote: > I am trying to write some general code that works on arbitrary > types. I need to compare, obviously, as that is relatively basic > thing on objects. That's part of of why attribute inferrence works on templates.

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 17:27:24 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 17:04:42 UTC, Jonathan Marler wrote: On Saturday, 23 July 2016 at 16:46:20 UTC, Jonathan Marler wrote: [...] Actually Im going to disagree with myself. This technique actually wouldn't work with

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 23, 2016 11:25:02 Steven Schveighoffer via Digitalmars-d- learn wrote: > The real problem here is that there is a base method at all. We have > been striving to remove it at some point, but it is very difficult due > to all the legacy code which is written. > > Almost all the

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 17:23:37 UTC, Marco Leise wrote: Am Sat, 23 Jul 2016 13:18:03 + schrieb Rufus Smith : Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 23 July 2016 at 17:04:42 UTC, Jonathan Marler wrote: On Saturday, 23 July 2016 at 16:46:20 UTC, Jonathan Marler wrote: [...] Actually Im going to disagree with myself. This technique actually wouldn't work with virtual methods:) I don't think we have the big problems with

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 23 Jul 2016 13:18:03 + schrieb Rufus Smith : > Trying to compare a *ptr value with a value in nogc code results > in the error: > > Error: @nogc function '...' cannot call non-@nogc function > 'object.opEquals' > > Shouldn't object opEquals be

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Jonathan Marler via Digitalmars-d-learn
On Saturday, 23 July 2016 at 16:46:20 UTC, Jonathan Marler wrote: [...] Actually Im going to disagree with myself. This technique actually wouldn't work with virtual methods:)

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Jonathan Marler via Digitalmars-d-learn
On Saturday, 23 July 2016 at 15:25:02 UTC, Steven Schveighoffer wrote: On 7/23/16 10:53 AM, Rufus Smith wrote: On Saturday, 23 July 2016 at 14:15:03 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/23/16 10:53 AM, Rufus Smith wrote: On Saturday, 23 July 2016 at 14:15:03 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 23 July 2016 at 14:53:49 UTC, Rufus Smith wrote: Um, this isn't right. GC code can always call non-gc code. If you mark opEquals nogc, it breaks nothing except implementations of opEquals that use the GC. GC code can still call it nogc opequals, it only enforces opEquals code to

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 14:15:03 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function 'object.opEquals'

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function 'object.opEquals' Shouldn't object opEquals be marked? If object.opEquals is marked