The philosophy of mruby is to be a lightweight implementation of the Ruby ISO standard. These two objectives are partially contradicting. Ruby is an expressive language with complex implementation details which are difficult to implement in a lightweight manner. To cope with this, limitations to the “Ruby Compatibility” are defined.
This document is collecting these limitations.
This document does not contain a complete list of limitations. Please help to improve it by submitting your findings.
Since mruby does not have
Bignum, bigger integers are
Float numbers. To enhance interoperability
Float, mruby provides
Float#upto and other iterating methods for the
Float class. As a side effect,
Passing an Array to
in different output.
1 2 3
[1, 2, 3]
Kernel.raise without arguments does not raise the current
exception within a rescue clause.
begin 1 / 0 rescue raise end
ZeroDivisionError is raised.
No exception is raised.
Fiber is implemented in a similar way to Lua's
co-routine. This results in the consequence that you can't switch
context within C functions. Only exception is
To reduce memory consumption
Array does not support instance
class Liste < Array def initialize(str = nil) @feld = str end end p Liste.new "foobar"
ArgumentError is raised.
For simplicity reasons no method visibility (public/private/protected) is supported.
class VisibleTest def public_method; end private def private_method; end end p VisibleTest.new.respond_to?(:private_method, false) p VisibleTest.new.respond_to?(:private_method, true)
defined? keyword is considered too complex to be fully
implemented. It is recommended to use
const_defined? and other
reflection methods instead.
NameError is raised.
Aliasing a global variable works in CRuby but is not part of the ISO standard.
alias $a $__a__
An operator can't be overwritten by the user.
class String def + end end 'a' + 'b'
ArgumentError is raised. The re-defined
operator does not accept any arguments.
Behavior of the operator wasn't changed.