Crystal: alias_method - change argument order

Created on 14 Aug 2015  路  2Comments  路  Source: crystal-lang/crystal

the current alias_method goes alias_method :new_method, :old_method - exactly as ruby does it.

Personally I always found this to be super confusing (I remember the order of arguments for alias_method by remembering that it is the reverse of what I'd expect). I think it makes more sense to say alias_method :old_method, :new_method - e.g. I alias the old_method to the new_method.

What does everyone think? Happy to do the change if people agree.

Most helpful comment

I just removed alias_method. Reasons:

  1. It doesn't work in some cases (blocks and named arguments)
  2. They are redundant.

Point 2 is very important: more aliases means more names to learn. Even if you don't use an alias, if somebody on your team or a project you are working on uses it, you'll have to learn it. That means that eventually everyone learns all aliases, and that just occupies space in your mind for no real reason. Let's simplify the language.

All 2 comments

A lot of languages allow you to make an alias by using new_method = old_method. Python, JavaScript, and Haskell come to mind. On other hand, the unix command ln does expect its arguments in the order you propose.

I have to look up the order of alias_method and ln every time I use them. I never get new = old mixed up ... but I never get confused by def new_met(*args); old_met(*args); end either, and that's all alias_method does right now in Crystal.

I just removed alias_method. Reasons:

  1. It doesn't work in some cases (blocks and named arguments)
  2. They are redundant.

Point 2 is very important: more aliases means more names to learn. Even if you don't use an alias, if somebody on your team or a project you are working on uses it, you'll have to learn it. That means that eventually everyone learns all aliases, and that just occupies space in your mind for no real reason. Let's simplify the language.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grosser picture grosser  路  3Comments

lbguilherme picture lbguilherme  路  3Comments

Sija picture Sija  路  3Comments

ArthurZ picture ArthurZ  路  3Comments

relonger picture relonger  路  3Comments