helix
helix copied to clipboard
Idea: short-hand to alias Ruby methods?
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.)
Some other use cases
match/===/=~to_s/inspect