Comments (11)
@americodls I like discussions like these. They keep me sharp, thx for disagreeing!
from procto.
What do you think about it?
Fine from my side. Also we should allow #call
to be private, so use __send__
from the singleton level.
from procto.
I think to make #call
private it is not necessary since the object could not be instantiated out of the class context using private_class_method :new
.
from procto.
@americodls If a method has no public call side the form foo.call
it should be private for consistency.
from procto.
@mbj I fully agree with that.
But, look at line 5: new(text).call
. It has a public call. That's why you suggest to use __send__
.
from procto.
Yes. But that public call side is "private" in nature in regards to the only public API some_class.call
. Hence I think its clearer to document the intent not having the instance level #call
public in the first place.
from procto.
When .new
is made private, the intention will be clear:
You don't have to instantiate this object.
As the object cannot be instantianted the user doesn't have how to call its methods.
#call
will be public only to the class. Another instance methods must be private in order to communicate the class that #call
is the entry point.
We can avoid the use of __send__
just making .new
private.
from procto.
@americodls I like this discussion.
Still I think that it makes sense to have #call
private, as inside the procto
(infected) object, there could be a call side that leaks self
to somewhere (by accident) and there it should not have public methods, like #call
.
The idea is to use the least powerful primitive, a private method is more "primitive" in that sense. I'm fine to pay the extra cost of __send__
as an additional guarantee level.
from procto.
@mbj Sorry, I have no idea how this could happen.
I think, if it happens, the blame could not be on the design that I proposed (the problem is certainly in the misuse of the gem).
It seems that you is trying to solve a problem that doesn't exists yet. I can't agree with that.
I think my arguments are over and we reached the end of discussion here. Thank you for your time.
from procto.
class Foo
include Proto.call
def call
SomeClass.new(self) # may call `#call` which is a mistake
end
end
from procto.
@mbj You have a point. I get it. I am convinced. 👍
from procto.
Related Issues (4)
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 procto.