GithubHelp home page GithubHelp logo

Object equality about eo HOT 13 CLOSED

objectionary avatar objectionary commented on August 16, 2024
Object equality

from eo.

Comments (13)

androidfred avatar androidfred commented on August 16, 2024 2

Not everything makes sense to perform equality operations on, so making everything equatable irrespective of whether there is an implementation of equality or not (like Java does) is nonsensical and dangerous.

In Haskell, only things which explicitly implement equality can have equality operations performed on them, and attempting to perform equality operations on non equatable things results in a compilation error.

from eo.

yegor256 avatar yegor256 commented on August 16, 2024

@g4s8 good question. I think that two objects are equal if there encapsulated attributes are equal, e.g.:

equals: // it's true
  text("hello"),
  text("hello")

from eo.

mdbs99 avatar mdbs99 commented on August 16, 2024

...encapsulated attributes are equal,

So equals can see inside any objects?

from eo.

g4s8 avatar g4s8 commented on August 16, 2024

@yegor256, if I understand, equals has internal implementation to access object attributes (like java reflection)? Maybe it will be better if equals arguments implement some type? E.g.:

type Equatable:
    Bool sameAs(? other)

object equals<T as Equatable> ():
    T @first
    T @second
    ctor(T first, T second)
    Bool bool():
        first.sameAs(second)

from eo.

mdbs99 avatar mdbs99 commented on August 16, 2024

@g4s8 I think we don't need generics, see #1.

from eo.

g4s8 avatar g4s8 commented on August 16, 2024

I think we don't need generics

@mdbs99, ok, but this is just an example. I mean that not any object should be equatable. For instance if, plus, minus: whether plus 4 1 is equal to plus 3 2 or not?
So if equality is not a built-in object property, then each equatable object should implement it itself. Besides object can be equal only to object with same type, and I don't know how to describe it without generics.

from eo.

NikoGJ avatar NikoGJ commented on August 16, 2024

equals: should be a method on the object and would require another object as an argument. You basically ask an object if he is the same as another one

from eo.

mdbs99 avatar mdbs99 commented on August 16, 2024

@g4s8 I need to think more about that.

from eo.

Lebedevsd avatar Lebedevsd commented on August 16, 2024

@mdbs99, @g4s8 but as far as I understand the objects plus 4 1 are not equal plus 3 2 even in java, but as types (interfaces) Number which have only one method int value() they are kind of equal.
So do we need to think about object and interface equality?
Because as an interfaces Number this two objects plus 4 1, plus 3 2 are equal.

from eo.

jachinte avatar jachinte commented on August 16, 2024

@Lebedevsd, cc. @g4s8 is there a discussion about how operators will work in EO? as far as I understand, without using syntactical sugar, plus should not be a special object, so objects plus 4 1 and plus 3 2 are objects, not values. If you want to get the result of the operation, you should ask the object to return the result; something like myPlus.value(). Then, myPlus1.value() and myPlus2.value() are equal, but plus 4 1 and plus 3 2 are not.

EDIT

There is something similar about operators and their syntax in #31

from eo.

g4s8 avatar g4s8 commented on August 16, 2024

@jachinte, it's not correct, plus, equals and whatever else are objects. There is no operators. The problem here is 'whether any object must be equatable and how to get object equality'.

from eo.

yegor256 avatar yegor256 commented on August 16, 2024

@g4s8 two objects are equal only if their datarization function results are equal

from eo.

0crat avatar 0crat commented on August 16, 2024

Job gh:cqfn/eo#60 is not assigned, can't get performer

from eo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.