Thanks for excellent explanation!
On Sunday, 28 October 2018 at 19:00:52 UTC, Jonathan M Davis
wrote:
Because Object predats @safe (and most attributes), it really
isn't compatible with them. In fact, it predates const (since
it's basically the same as it was in D1) and it's only possible
On Sunday, October 28, 2018 12:56:10 PM MDT ikod via Digitalmars-d-learn
wrote:
> On Sunday, 28 October 2018 at 18:00:06 UTC, Stanislav Blinov
>
> wrote:
> > On Sunday, 28 October 2018 at 12:38:12 UTC, ikod wrote:
> >> and object.opEquals(a,b) do not inherits safety from class C
> >> properties,
On Sunday, October 28, 2018 6:38:12 AM MDT ikod via Digitalmars-d-learn
wrote:
> Hello
>
> How to make this code to compile? My goal is safe(not @trusted)
> longFunction().
>
>
> ---
> class C
> {
> override bool opEquals(Object o) const @safe
> {
> return true;
> }
> }
>
On Sunday, 28 October 2018 at 18:00:06 UTC, Stanislav Blinov
wrote:
On Sunday, 28 October 2018 at 12:38:12 UTC, ikod wrote:
and object.opEquals(a,b) do not inherits safety from class C
properties, and also I can't override it.
Yep. Since Object is the base class and it defines opEquals as:
On Sunday, October 28, 2018 12:17:41 PM MDT Neia Neutuladh via Digitalmars-
d-learn wrote:
> On Sun, 28 Oct 2018 18:00:06 +, Stanislav Blinov wrote:
> > On Sunday, 28 October 2018 at 12:38:12 UTC, ikod wrote:
> >> and object.opEquals(a,b) do not inherits safety from class C
> >> properties,
On Sun, 28 Oct 2018 18:00:06 +, Stanislav Blinov wrote:
> On Sunday, 28 October 2018 at 12:38:12 UTC, ikod wrote:
>
>> and object.opEquals(a,b) do not inherits safety from class C
>> properties, and also I can't override it.
>
> Yep. Since Object is the base class and it defines opEquals
On Sunday, 28 October 2018 at 12:38:12 UTC, ikod wrote:
and object.opEquals(a,b) do not inherits safety from class C
properties, and also I can't override it.
Yep. Since Object is the base class and it defines opEquals as:
```
bool opEquals(Object);
```
the compiler rewrites `a == b` as
Hello
How to make this code to compile? My goal is safe(not @trusted)
longFunction().
---
class C
{
override bool opEquals(Object o) const @safe
{
return true;
}
}
bool longFunction(C a, C b) @safe
{
return a==b;
}
void main()
{
}
---
As far as I understand the