Skip to content
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

Compare Functor Project #1

Open
rubyworks opened this issue May 27, 2010 · 3 comments
Open

Compare Functor Project #1

rubyworks opened this issue May 27, 2010 · 3 comments

Comments

@rubyworks
Copy link
Collaborator

Take a look at the "Functor" project (yea I know, terrible name for a overload system) and compare it to Platypus' implementation of method overloading.

@trans
Copy link
Member

trans commented Jul 22, 2014

Now at https://github.com/waves/functor, but it has not seen any activity since May 2010.

@trans
Copy link
Member

trans commented Jul 22, 2014

Besides the over use of the term "Functor" (hey, I used it first for Ruby! 👅) The Functor project differs syntactically in that is defines a new "def" method called "functor" to handle the creation of overloaded methods. Feature wise, it offers static value and lambda matching, which is something Patypus doesn't provide, but is should not be hard to add. Actually Platypus might support this in part, b/c the === operator is used for matching, but it was never explicitly featured. So this is definitely something it can support, and I will eventually make sure it does.

Beyond that the project has anonymous "functors", which are like Procs but have pattern matching built into them, and provide a small DSL to define them by hand. e.g.

fib = Functor.new do |f|
  f.given( Integer ) { | n | f.call( n - 1 ) + f.call( n - 2 ) }
  f.given( 0 ) { |x| 0 }
  f.given( 1 ) { |x| 1 }
end

That's kind of nice, and I wonder if Platypus can incorporate something like that into its design as well.

@trans
Copy link
Member

trans commented Jul 22, 2014

On the other hand I just looked at the code (https://github.com/waves/functor/blob/master/lib/functor.rb) and my eyes went cross.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant