helix icon indicating copy to clipboard operation
helix copied to clipboard

Idea: short-hand to alias Ruby methods?

Open chancancode opened this issue 8 years ago • 1 comments

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 avatar Oct 17 '17 00:10 chancancode

Some other use cases

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

chancancode avatar Oct 17 '17 01:10 chancancode