-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tuple
too complex and breaks LSP
#3227
Comments
I want create PR, but this is more complex work than just modify EO implementation. Because I need to rewrite part of parser works with |
About attribute
|
@maxonfjvipon wdyt? |
@Chamber6821 such |
@Chamber6821 about
Ofc if you have to rewrite
But in such case there'll be no duplication here for every new implementation |
@Chamber6821 I didn't really understand which part of
|
@maxonfjvipon about |
@maxonfjvipon
Expected that |
@maxonfjvipon similar problem with |
@maxonfjvipon perfornace issue is not reason to break LSP. If you want optimize index calculation you can use special implementation inside compiler:
|
@maxonfjvipon about
Expected that |
@Chamber6821 I can agree about LSP in |
@maxonfjvipon but it leads to code repetitions. I think it is significant issue. Logic of |
@Chamber6821 why it leads to code repetitions?
Every new decoration requires new implementation of |
@maxonfjvipon because your implementations breaks LSP and principle of least astonishment.
Expects:
I think there is no reason for |
@Chamber6821 what's the point of creating new |
@maxonfjvipon this is how I perceive thple. And I believe that the decorator is better than the additional method. I don’t know how correct it is to refer to the book Elegant Objects, but chained methods are designated there as an antipattern or undesirable I think it:
better than
|
@maxonfjvipon
than that
|
@Chamber6821 imagine you have multiple implementations of So In order finish this discussion: I agree that we probably should change implementation of |
@maxonfjvipon maybe I don't understand something about the idea. What difference between |
@Chamber6821 for now we have just |
@maxonfjvipon I don't understand why it is require extra object. |
@Chamber6821 actually you're right, |
@maxonfjvipon I also wrote about changing the tuple itself from gluing an element to the end, to gluing two tuples. This implementation can replace chaining
Implementation via binary tree:
Last implementation have better asymptotics
WDYT? |
@Chamber6821 how are you going to convert |
@maxonfjvipon recursive turn it in half (rounded down). Examples:
I can describe algorithm if you interested |
@maxonfjvipon I also think about optimizing compiler that can use native array in real program, but it is raw idea |
@Chamber6821 we don't want to use native arrays because current java implementation is not forever. We already have javascript runtime, maybe we'll have more. The more objects are implemented in pure EO - the better. |
@maxonfjvipon I think the same |
@yegor256 WDYT about |
@Chamber6821 If I understood your idea correctly, adding of element to current tuple force us to create a new tuple with changed structure instead of referencing to existing tuple.
And you want to declare
I mean it can be too expensive to add a new element to tuple |
@levBagryansky No, read about
|
@Chamber6821 I see. So
Looks good |
@Chamber6821 we're not sure about implementation via binary tree. For now you can fix the bug in a separated PR with |
@maxonfjvipon what about |
@Chamber6821 let's leave it for now, the less changes in PR - the better |
Simpler implementation
Just use polymorhism with
head.at
Breaks LSP
Current implementation breaks LSP in attribute
as-fast
:tup
may not havehead
andtail
. Example:More useful
tuple
I think
tuple
constructor may be more useful iftuple
will be implemented via binary tree:You can use
tuple
to concat two other tuples:The text was updated successfully, but these errors were encountered: