[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-core
Subject:    [ruby-core:76623] [Ruby trunk Feature#12637] Unified and consistent method naming for safe and dange
From:       radovan.smitala () gmail ! com
Date:       2016-07-30 4:53:24
Message-ID: redmine.journal-59843.20160730045324.51b62257f5715706 () ruby-lang ! org
[Download RAW message or body]

Issue #12637 has been updated by Radovan Smitala.

Subject changed from Unificate and consistent method naming for safe and dangerous \
methods to Unified and consistent method naming for safe and dangerous methods \
Description updated

Fixed typo

----------------------------------------
Feature #12637: Unified and consistent method naming for safe and dangerous methods
https://bugs.ruby-lang.org/issues/12637#change-59843

* Author: Radovan Smitala
* Status: Open
* Priority: Normal
* Assignee: ruby-core
----------------------------------------
Hello,

As a multi-paradign language allows programmers to code from imperative to functional \
style. This gives Ruby to be modern and wide used language in these days. Ruby is \
built on idea to be as fun, understandable and focused for people.

But i think it carry "complicated behaviour" in some method naming.

In this documentation is written: \
(http://docs.ruby-lang.org/en/trunk/syntax/methods_rdoc.html)
> The bang methods (! at the end of method name) are called and executed just like \
> any other method. However, by convention, a method with an exclamation point or \
> bang is considered dangerous. In ruby core library the dangerous method implies \
> that when a **method ends with a bang (!), it indicates that unlike its non-bang \
> equivalent, permanently modifies its receiver**. **Almost always**, ruby core \
> library will have a non-bang counterpart (method name which does NOT end with !) of \
> every bang method (method name which does end with !) that does not modify the \
> receiver. This convention is typically true for ruby core library but may or may \
> not hold true for other ruby libraries.

Hightlited part of citation talks about that method with exclamation mark modifies \
its receiver. What is good because i could choose between imperative habit and modify \
receiver, but i can also create new data and code in functional habit.

Eg: i can create new array with **map** method, but always i can modify existed \
object with **map!**. What is incredible and easy to understand. Or i want to get \
unique values from array by **uniq** assign into new variable. Still it is able to \
modify origin array with **uniq!**

Second highlighted part is about confused part. It tells to programmer be careful. \
Not all methods follows this great design. In Ruby are methods which are \
"inconsistent" in naming.

Eg. Many built-in Array methods like
* clear
* concat
* delete
* delete_at
* delete_if
* fill
* insert
* keep_if
* pop
* push
* replace
* shift
* unshift
are dangerous because modify its receiver. What is confusing for many programmers and \
it brings unexceptional behaviour without study documentation deeper.

I think Ruby is popular for people because it communicate with programmer like in \
human language. Nowadays are getting functional programming languages high popularity \
and trend increase more and more.

It could be great to remove that one word ("Almost") and have Ruby as language more \
clear, unambiguous and brings more functional principles into language what we like \
and love.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic