![]() |
mruby 3.3.0
mruby is the lightweight implementation of the Ruby language
|
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.
Kernel.raise
in rescue clauseKernel.raise
without arguments does not raise the current exception within a rescue clause.
ZeroDivisionError
is raised.
RuntimeError
is raised instead of ZeroDivisionError
. To re-raise the exception, you have to do:
mruby's Fiber
is implemented similarly to Lua's co-routine. This results in the consequence that you can't switch context within C functions. Only exception is mrb_fiber_yield
at return.
Array
does not support instance variablesTo reduce memory consumption Array
does not support instance variables.
[]
ArgumentError
is raised.
For simplicity reasons no method visibility (public/private/protected) is supported. Those methods are defined, but they are dummy methods.
The declaration form of following visibility methods are not implemented.
public
private
protected
module_function
Especially, module_function
method is not dummy, but no declaration form.
defined?
The 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.
alias
on global variablesAliasing a global variable works in CRuby but is not part of the ISO standard.
nil
Syntax error
An operator can't be overwritten by the user.
ArgumentError
is raised. The re-defined +
operator does not accept any arguments.
‘'ab’` Behavior of the operator wasn't changed.
Kernel#binding
is not supported until [3.0.0 (2021-03-05)]Kernel#binding
method is not supported.
nil?
redefinition in conditional expressionsRedefinition of nil?
is ignored in conditional expressions.
Ruby outputs truthy
. mruby outputs falsy
.
Destructured arguments (b
and c
in above example) cannot be accessed from the default expression of optional arguments and keyword arguments, since actual assignment is done after the evaluation of those default expressions. Thus:
CRuby gives [1,2,3,nil]
. mruby raises NoMethodError
for b
.
Keyword argument expansion has similar restrictions. The following example, gives [1, 1]
for CRuby, mruby raises NoMethodError
for b
.