blob: f60ab5930ef3afbe7539f65f6832479c7222baf1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# Limitations and Differences
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.
## Integrity
This document does not contain a complete list of limitations.
Please help to improve it by submitting your findings.
## ```1/2``` gives ```0.5```
Since mruby does not have ```Bignum```, bigger integers are represented
by ```Float``` numbers. To enhace interoperability between ```Float```
and ```Float```, mruby provides ``Float#upto``` and other iterationg
methods for ```Float`` class. As a side effect, ```1/2``` gives ```0.5```
not ```0```.
## ```Array``` passed to ```puts```
Passing an Array to ```puts``` results in different output.
```ruby
puts [1,2,3]
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
```
1
2
3
```
#### mruby [1.2.0 (2015-11-17)]
```
[1, 2, 3]
```
## ```Kernel.raise``` in rescue clause
```Kernel.raise``` without arguments does not raise the current exception within
a rescue clause.
```ruby
begin
1 / 0
rescue
raise
end
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
```ZeroDivisionError``` is raised.
#### mruby [1.2.0 (2015-11-17)]
No exception is raised.
## Check of infinite recursion
mruby does not check infinite recursion across C extensions.
```ruby
def test; eval 'test'; end; test
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
```SystemStackError``` is raised.
#### mruby [1.2.0 (2015-11-17)]
Segmentation fault.
## Fiber execution can't cross C function boundary
mruby's ```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 ```mrb_fiber_yield``` at return.
## ```Array``` does not support instance variables
To reduce memory consumption ```Array``` does not support instance variables.
```ruby
class Liste < Array
def initialize(str = nil)
@feld = str
end
end
p Liste.new "foobar"
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
``` [] ```
#### mruby [1.2.0 (2015-11-17)]
```ArgumentError``` is raised.
## Method visibility
For simplicity reasons no method visibility (public/private/protected) is
supported.
```ruby
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)
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
```
false
true
```
#### mruby [1.2.0 (2015-11-17)]
```
true
true
```
|