Project

General

Profile

Feature #6251

Magic comments for compile options

Added by Shugo Maeda over 4 years ago. Updated 11 months ago.

Status:
Feedback
Priority:
Normal
[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.

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

History

#1 [ruby-core:44108] Updated by Yusuke Endoh over 4 years ago

  • Status changed from Open to Assigned

#2 [ruby-core:48372] Updated by Koichi Sasada over 3 years ago

  • Target version changed from 2.0.0 to Next Major

Sorry, I can't implement it until 2.0 release.

#3 Updated by Koichi Sasada 11 months ago

  • Description updated (diff)
  • Status changed from Assigned to Feedback
  • Assignee changed from Koichi Sasada to Yukihiro Matsumoto

I have no idea such magic comment is acceptable or not.

Matz's issue?

Also available in: Atom PDF