Giter Club home page Giter Club logo

Comments (11)

mbj avatar mbj commented on August 18, 2024 1

@americodls I like discussions like these. They keep me sharp, thx for disagreeing!

from procto.

mbj avatar mbj commented on August 18, 2024

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.

americodls avatar americodls commented on August 18, 2024

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.

mbj avatar mbj commented on August 18, 2024

@americodls If a method has no public call side the form foo.call it should be private for consistency.

from procto.

americodls avatar americodls commented on August 18, 2024

@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.

mbj avatar mbj commented on August 18, 2024

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.

americodls avatar americodls commented on August 18, 2024

@mbj

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.

mbj avatar mbj commented on August 18, 2024

@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.

americodls avatar americodls commented on August 18, 2024

@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.

mbj avatar mbj commented on August 18, 2024

@americodls

class Foo
  include Proto.call

 def call
   SomeClass.new(self) # may call `#call` which is a mistake
 end
end 

from procto.

americodls avatar americodls commented on August 18, 2024

@mbj You have a point. I get it. I am convinced. 👍

from procto.

Related Issues (4)

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.