Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Idea: short-hand to alias Ruby methods? #131

Open
chancancode opened this issue Oct 17, 2017 · 1 comment
Open

Idea: short-hand to alias Ruby methods? #131

chancancode opened this issue Oct 17, 2017 · 1 comment

Comments

@chancancode
Copy link
Member

For example, you might want to define both a length/size method that shares the same implementation (like Ruby's Array/String classes).

This seems like a pretty common pattern in Ruby – when browsing through the standard library docs, there are fair number of Alias for: ... floating around.

One idea is to support something like Ruby's alias_method syntax in the macro/DSL. Another approach is to add a #[ruby_alias = "..."] that could appear 0 to N times, similar to how #[ruby_name = "..."] works.

If we are doing this, I suspect option 2 is what we want, since it doesn't seem as common to want to define alias for Rust methods. (If anyone want to try implementing it, the commit to add #[ruby_name = "..."] is probably a good place to draw inspiration.)

@chancancode
Copy link
Member Author

Some other use cases

  • match/===/=~
  • to_s/inspect

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

No branches or pull requests

1 participant