From: Lazaridis Ilias <ilias@...>
Date: 2011-06-06T20:50:21+09:00
Subject: [ruby-core:36783] [Ruby 1.9 - Feature #4824] Provide method Kernel#executed?


Issue #4824 has been updated by Lazaridis Ilias.


Clifford Heath wrote:
[...] - omitting, to focus on essence

>  > And at this point, the "dispute" is about the method name.
>  
>  No, it isn't. It's about how to make Ruby easier to read.

The status of this issue (#4823) is "agreed providing a method" (= provide an OO construct) and more actual "We need a better name." (Source: See the first comment). 

So, it's about to make the language easier to read, in context of an OO construct.

I've added some elaborations, subjecting the (OO method) name. Ideally, it would be one word, but it's possible to use something like this:

 if this_file_is_equal_with_the_program_name?

Although I dislike a two-word choice, the most logical seems to be this one:

if is_executed?      # refers to the actual main object. the user has *anyway* to learn: there is a "self" behind, an object behind

if self.is_executed? # can be written with "self", to make it more clear

main() if self.is_program?

main() if is_program?

So, the point is, to find a concise method name (ideally one word) which reads nice and fits in the overall existent naming scheme of the language.

(note that I "back-off" from this issue for now)


----------------------------------------
Feature #4824: Provide method Kernel#executed?
http://redmine.ruby-lang.org/issues/4824

Author: Lazaridis Ilias
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 


The current construct to execute main code looks not very elegant:

if __FILE__ == $0
  my_main()          # call any method or execute any code
end

With a Kernel#executed? method, this would become more elegant:

if executed?
  #do this
  #do that
  my_main()
end

or

main() if executed?

This addition would not break any existent behaviour.



-- 
http://redmine.ruby-lang.org