Project

General

Profile

Actions

Feature #6251

closed

Magic comments for compile options

Added by shugo (Shugo Maeda) almost 12 years ago. Updated over 8 years ago.

Status:
Feedback
Target version:
-
[ruby-core:44105]

Description

Currently, compile options can be set by RubyVM::InstructionSequence.compile_option=.
However, it takes effect only on code compiled after the options are set.

So, how about to add new magic comments for compile options?
For example, the following code sets the options tailcall_optimization and trace_instruction.

  # -*- tailcall-optimization: true; trace-instruction: false -*-
  
  def fact(n, i = 1)
    if n == 0
      i
    else
      fact(n - 1, n * i)
    end
  end
  p fact(10000)

With the attached patch, magic comments in the main script sets global options, and magic comments in a required library are effective only in that library.


Files

magic-comments-for-compile-options.diff (7.66 KB) magic-comments-for-compile-options.diff shugo (Shugo Maeda), 04/03/2012 06:20 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0