diff options
| author | Hiroshi Mimaki <[email protected]> | 2019-10-18 14:46:03 +0900 |
|---|---|---|
| committer | Hiroshi Mimaki <[email protected]> | 2019-10-18 14:46:03 +0900 |
| commit | b6546835457d1935a9c77965686b2a1256874d96 (patch) | |
| tree | 724cfd71a7c956b0648e8c58f3717d797fff5f29 /doc/limitations.md | |
| parent | 8ee516436b8d174a50764939bee23a442aa00b3f (diff) | |
| parent | 20d01f118ddb7e7f2f36926a7a3db35573611857 (diff) | |
| download | mruby-b6546835457d1935a9c77965686b2a1256874d96.tar.gz mruby-b6546835457d1935a9c77965686b2a1256874d96.zip | |
Merge master.
Diffstat (limited to 'doc/limitations.md')
| -rw-r--r-- | doc/limitations.md | 108 |
1 files changed, 79 insertions, 29 deletions
diff --git a/doc/limitations.md b/doc/limitations.md index 9b4ed9c6f..6958d396f 100644 --- a/doc/limitations.md +++ b/doc/limitations.md @@ -14,17 +14,17 @@ This document does not contain a complete list of limitations. Please help to improve it by submitting your findings. -## ```1/2``` gives ```0.5``` +## `1/2` gives `0.5` -Since mruby does not have ```Bignum```, bigger integers are represented -by ```Float``` numbers. To enhance interoperability between ```Fixnum``` -and ```Float```, mruby provides ```Float#upto``` and other iterating -methods for the ```Float``` class. As a side effect, ```1/2``` gives ```0.5``` -not ```0```. +Since mruby does not have `Bignum`, bigger integers are represented +by `Float` numbers. To enhance interoperability between `Fixnum` +and `Float`, mruby provides `Float#upto` and other iterating +methods for the `Float` class. As a side effect, `1/2` gives `0.5` +not `0`. -## ```Array``` passed to ```puts``` +## `Array` passed to `puts` -Passing an Array to ```puts``` results in different output. +Passing an Array to `puts` results in different output. ```ruby puts [1,2,3] @@ -44,9 +44,9 @@ puts [1,2,3] [1, 2, 3] ``` -## ```Kernel.raise``` in rescue clause +## `Kernel.raise` in rescue clause -```Kernel.raise``` without arguments does not raise the current exception within +`Kernel.raise` without arguments does not raise the current exception within a rescue clause. ```ruby @@ -59,7 +59,7 @@ end #### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)] -```ZeroDivisionError``` is raised. +`ZeroDivisionError` is raised. #### mruby [2.0.1 (2019-4-4)] @@ -67,13 +67,13 @@ No exception is raised. ## Fiber execution can't cross C function boundary -mruby's ```Fiber``` is implemented in a similar way to Lua's co-routine. This +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. +Only exception is `mrb_fiber_yield` at return. -## ```Array``` does not support instance variables +## `Array` does not support instance variables -To reduce memory consumption ```Array``` does not support instance variables. +To reduce memory consumption `Array` does not support instance variables. ```ruby class Liste < Array @@ -87,16 +87,16 @@ p Liste.new "foobar" #### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)] -``` [] ``` +` [] ` #### mruby [2.0.1 (2019-4-4)] -```ArgumentError``` is raised. +`ArgumentError` is raised. ## Method visibility For simplicity reasons no method visibility (public/private/protected) is -supported. +supported. Those methods are defined but they are dummy methods. ```ruby class VisibleTest @@ -126,10 +126,46 @@ true true ``` -## defined? +### Visibility Declaration -The ```defined?``` keyword is considered too complex to be fully -implemented. It is recommended to use ```const_defined?``` and +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. + +``` +module TestModule + module_function + def test_func + p 'test_func called' + end + + test_func +end + +p 'ok' +``` + +#### Ruby [ruby 2.5.5p157 (2019-03-15 revision 67260)] + +``` +ok +``` + +#### mruby [2.0.1 (2019-4-4)] + +``` +test.rb:8: undefined method 'test_func' (NoMethodError) +``` + +## `defined?` + +The `defined?` keyword is considered too complex to be fully +implemented. It is recommended to use `const_defined?` and other reflection methods instead. ```ruby @@ -144,9 +180,9 @@ nil #### mruby [2.0.1 (2019-4-4)] -```NameError``` is raised. +`NameError` is raised. -## ```alias``` on global variables +## `alias` on global variables Aliasing a global variable works in CRuby but is not part of the ISO standard. @@ -157,7 +193,7 @@ alias $a $__a__ #### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)] -``` nil ``` +` nil ` #### mruby [2.0.1 (2019-4-4)] @@ -178,15 +214,15 @@ end #### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)] -```ArgumentError``` is raised. -The re-defined ```+``` operator does not accept any arguments. +`ArgumentError` is raised. +The re-defined `+` operator does not accept any arguments. #### mruby [2.0.1 (2019-4-4)] -``` 'ab' ``` +` 'ab' ` Behavior of the operator wasn't changed. -## Kernel#binding is not supported +## `Kernel#binding` is not supported `Kernel#binding` method is not supported. @@ -238,7 +274,7 @@ 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: - + ```ruby def f(a,(b,c),d=b) p [a,b,c,d] @@ -247,3 +283,17 @@ f(1,[2,3]) ``` CRuby gives `[1,2,3,nil]`. mruby raises `NoMethodError` for `b`. + +## `nil?` redefinition in conditional expressions + +Redefinition of `nil?` is ignored in conditional expressions. + +```ruby +a = "a" +def a.nil? + true +end +puts(a.nil? ? "truthy" : "falsy") +``` + +Ruby outputs `falsy`. mruby outputs `truthy`. |
