Issue #4824 has been updated by fxn (Xavier Noria).


I vote for __MAIN__.

I think "main" will resonate to a lot of people with different backgrounds to indicate the entry point of the program, and choosing a keyword instead of a method seems coherent with other keywords like __FILE__.

----------------------------------------
Feature #4824: Provide method Kernel#executed?
https://bugs.ruby-lang.org/issues/4824#change-27076

Author: lazaridis.com (Lazaridis Ilias)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
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://bugs.ruby-lang.org/