lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


With my 'I do this for money' hat on I have to say that the Ruby conventions of mutable methods ending in ! (as in sort!) and the non mutable versions not having the ! at the end (as in sort) is less useful than it sounds. Firstly this only seems to be enforced when there is a mutable and non-mutable version of the method. So if ​the method foo mutates the object but there is no non-mutable version then the method will be called foo and not foo! Which is a problem when you come up with a non mutable version at some later point.

Also using ? as a suffix to indicate a method that returns a boolean is also less than consistent.

They are purely conventions with no way of enforcing them unless there is a gatekeeper, so the core Ruby language is pretty consistent but libraries less so.

This was in Ruby since version 1 and it is still not something you can rely on so I would say that if you want to use the ? and ! suffixes as described above then you have to build a checker into the language that will enforce this.

Now image adding this to a 20 year old language :(