summaryrefslogtreecommitdiffhomepage
path: root/doc/limitations.md
AgeCommit message (Collapse)Author
2021-10-12Support Ruby3.0 keyword arguments.Yukihiro "Matz" Matsumoto
The Difference Since Ruby1.9, the keyword arguments were emulated by Ruby using the hash object at the bottom of the arguments. But we have gradually moved toward keyword arguments separated from normal (positinal) arguments. At the same time, we value compatibility, so that Ruby3.0 keyword arguments are somewhat compromise. Basically, keyword arguments are separated from positional arguments, except when the method does not take any formal keyword arguments, given keyword arguments (packed in the hash object) are considered as the last argument. And we also allow non symbol keys in the keyword arguments. In that case, those keys are just passed in the `**` hash (or raise `ArgumentError` for unknown keys). The Instruction Changes We have changed `OP_SEND` instruction. `OP_SEND` instruction used to take 3 operands, the register, the symbol, the number of (positional) arguments. The meaning of the third operand has been changed. It is now considered as `n|(nk<<4)`, where `n` is the number of positional arguments, and `nk` is the number of keyword arguments, both occupies 4 bits in the operand. The number `15` in both `n` and `nk` means variable sized arguments are packed in the object. Positional arguments will be packed in the array, and keyword arguments will be packed in the hash object. That means arguments more than 14 values are always packed in the object. Arguments information for other instructions (`OP_SENDB` and `OP_SUPER`) are also changed. It works as the third operand of `OP_SEND`. the difference between `OP_SEND` and `OP_SENDB` is just trivial. It assigns `nil` to the block hidden arguments (right after arguments). The instruction `OP_SENDV` and `OP_SENDVB` are removed. Those instructions are replaced by `OP_SEND` and `OP_SENDB` respectively with the `15` (variable sized) argument information. Calling Convention When calling a method, the stack elements shall be in the order of the receiver of the method, positional arguments, keyword arguments and the block argument. If the number of positional or keyword arugument (`n` or `nk`) is zero, corresponding arguments will be empty. So when `n=0` and `nk=0` the stack layout (from bottom to top) will be: +-----------------------+ | recv | block (or nil) | +-----------------------+ The last elements `block` should be explicitly filled before `OP_SEND` or assigned to `nil` by `OP_SENDB` internally. In other words, the following have exactly same behavior: OP_SENDB clears `block` implicitly: ``` OP_SENDB reg sym 0 ``` OP_SEND clears `block` implicitly: ``` OP_LOADNIL R2 OP_SEND R2 sym 0 ``` When calling a method with only positional arguments (n=0..14) without keyword arguments, the stack layout will be like following: +--------------------------------------------+ | recv | arg1 | ... | arg_n | block (or nil) | +--------------------------------------------+ When calling a method with arguments packed in the array (n=15) which means argument splat (*) is used in the actual arguments, or more than 14 arguments are passed the stack layout will be like following: +-------------------------------+ | recv | array | block (or nil) | +-------------------------------+ The number of the actual arguments is determined by the length of the argument array. When keyword arguments are given (nk>0), keyword arguments are passed between positional arguments and the block argument. For example, when we pass one positional argument `1` and one keyword argument `a: 2`, the stack layout will be like: +------------------------------------+ | recv | 1 | :a | 2 | block (or nil) | +------------------------------------+ Note that keyword arguments consume `2*nk` elements in the stack when `nk=0..14` (unpacked). When calling a method with keyword arguments packed in the hash object (nk=15) which means keyword argument splat (**) is used or more than 14 keyword arguments in the actual arguments, the stack layout will be like: +------------------------------+ | recv | hash | block (or nil) | +------------------------------+ Note for mruby/c When mruby/c authors try to support new keyword arguments, they need to handle the new meaning of the argument information operand. If they choose not to support keyword arguments in mruby/c, it just raise error when `nk` (taken by `(c>>4)&0xf`) is not zero. And combine `OP_SENDV` behavior with `OP_SEND` when `n` is `15`. If they want to support keyword arguments seriously, contact me at <[email protected]> or `@yukihiro_matz`. I can help you.
2021-06-16Run pre-commit with GitHub ActionsJohn Bampton
Running pre-commit with GitHub Actions now gives us more tests and coverage Remove duplicate GitHub Actions for merge conflicts and trailing whitespace Remove duplicate checks for markdownlint and yamllint from the GitHub Super-Linter Add new custom pre-commit hook running with a shell script to sort alphabetically and uniquify codespell.txt Add new pre-commit hook to check spelling with codespell https://github.com/codespell-project/codespell Fix spelling
2021-05-10doc/limitation.md: update the limitation.Yukihiro "Matz" Matsumoto
- `puts` behavior changed as CRuby - fix wrong behavior in re-raising in `rescue`
2021-03-09chore: fix grammarJohn Bampton
2021-03-05Update version and release date. (mruby 3.0.0 (2021-03-05))3.0.0mimaki
2021-01-28Update `limitation.md` for integer division change in 3.0.Yukihiro "Matz" Matsumoto
2020-12-19feat(CI): add a GitHub Action to lint the MarkdownJohn Bampton
Run on pull request only Using https://www.npmjs.com/package/markdownlint-cli Lint Markdown for rules: - MD009/no-trailing-spaces - MD012/no-multiple-blanks - MD022/blanks-around-headings - MD031/blanks-around-fences - MD032/blanks-around-lists
2020-10-12Make division by zero cause `ZeroDivisionError`.Yukihiro "Matz" Matsumoto
As described in ISO 15.2.30.
2020-10-12Integrate `Fixnum` class into `Integer` classdearblue
* The `Fixnum` constant is now an alias for the `Integer` class. * Remove `struct mrb_state::fixnum_class` member. If necessary, use `struct mrb_state::integer_class` instead.
2020-10-12Small updates on documents:Yukihiro "Matz" Matsumoto
- README.md - CONTRIBUTING.md - doc/limitations.md
2020-08-06Update release date.2.1.2Hiroshi Mimaki
2020-07-01Update version to `2.1.2`. (mruby 2.1.2 RC)2.1.2-rcHiroshi Mimaki
2020-06-04Update release date.2.1.1Hiroshi Mimaki
2020-04-10Update version to `2.1.1`. (mruby 2.1.1 RC)2.1.1-rcHiroshi Mimaki
2019-11-19Release `mruby 2.1.0`.2.1.0Hiroshi Mimaki
2019-10-18Update version to `2.1.0`. (mruby 2.1.0 RC)2.1.0-rcHiroshi Mimaki
2019-09-14Add unavailability of declaration form of visibility methods; #4708Yukihiro "Matz" Matsumoto
2019-09-03Add to `doc/limitations.md` about `nil?` redefinition; ref 4996709 [ci skip]KOBAYASHI Shuji
2019-08-18fix up markdown display in doxygenDavid Siaw
2019-04-04Update version and release date.2.0.1Hiroshi Mimaki
`mruby 2.0.1 (2019-4-4)`
2018-12-11Update release date.2.0.0Hiroshi Mimaki
2018-11-25Update `doc/limitations.md` for argument destructuring.Yukihiro "Matz" Matsumoto
2018-07-31Remove unmatched quotation markKazuhiro NISHIYAMA
2018-07-31Describe the difference of the keyword argument behavior.Yukihiro "Matz" Matsumoto
The implementation of keyword arguments is heavily rely on the prototype made by @take-cheeze in #3629.
2018-06-27Add information about Kernel#bindingW
2018-04-27Set the mruby-1.4.1 release date to `2018-4-27`.1.4.1Hiroshi Mimaki
2018-01-16Set the mruby-1.4.0 release date to `2018-1-16`.1.4.0Hiroshi Mimaki
2017-11-18doc/limitaions.md: Remove infinite recursion entry.Yukihiro "Matz" Matsumoto
It's fixed since 1.3.0
2017-11-18doc/limitaions.md: Remove `Kernel.binding` entry.Yukihiro "Matz" Matsumoto
Since no ISO classes/methods are not provided by mruby, there's no use mentioning `Kernel.binding` here.
2017-07-04Set the mruby-1.3.0 release date to `2017-7-4`.1.3.0Hiroshi Mimaki
2016-09-28Removed trailing spacesNobuyoshi Nakada
2016-09-17Fix a couple typos in limitations.mdBenoit Daloze
2016-02-12Fix formatting again...Daniel Bovensiepen
2016-02-12Add more limitations:Daniel Bovensiepen
- defined? - alias on global variables - Operator modification - Kernel.binding missing
2016-02-12fixed typos in limitations.mdYukihiro "Matz" Matsumoto
2016-02-11Fix formattingDaniel Bovensiepen
2016-02-11Add more limitationsDaniel Bovensiepen
2016-02-11add 1/2 description to limitations.md fileYukihiro "Matz" Matsumoto
2016-02-11Small format fixDaniel Bovensiepen
2016-02-11Add limitation fileDaniel Bovensiepen