Comments (13)
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.
@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.
...encapsulated attributes are equal,
So equals
can see inside any objects?
from eo.
@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.
@g4s8 I think we don't need generics, see #1.
from eo.
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.
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.
@g4s8 I need to think more about that.
from eo.
@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.
@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.
@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.
@g4s8 two objects are equal only if their datarization function results are equal
from eo.
Job gh:cqfn/eo#60
is not assigned, can't get performer
from eo.
Related Issues (20)
- `malloc.pointer` needs `realloc` object HOT 5
- eo benchmarks HOT 1
- Fix: no top-level lamdba package in generated PHI programs HOT 5
- BinarizeParseTest.java:54-57: Replace all appearances of... HOT 2
- EoIndentLexerTest.java:42-45: Replace all appearances of... HOT 2
- AtCompositeTest.java:42-45: Replace all appearances of... HOT 2
- validate snippets inside `README.md` HOT 2
- Do we use `@RetryOnFailure` correctly HOT 3
- Name rust projects more informatively HOT 1
- Print full error message if cargo fails HOT 1
- @Reload(MyClass.class) annotation HOT 3
- `BinarizeMojo` does not add dependencies into EO code after `unphi` HOT 3
- let's get rid of `sigma` HOT 16
- `ChRemote` has threadsafety vulnerability HOT 1
- add actionlint HOT 1
- We can allow not to comment named abstract objects on level >= 2 HOT 1
- expand .gitignore with eo-runtime/lib HOT 1
- CommitHashesTextTest.java:40-43: Add "Reload" to the test... HOT 2
- `PhPackageTest.findsAttributesConcurrently` test fails sometimes in CI in concurrent environment HOT 1
- PMD check disabled for entire `eo-runtime` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eo.