Commit Graph

47 Commits

Author SHA1 Message Date
John Bampton e76525568a doc/limitations.md: remove whitespace, add code block languages 2023-04-01 07:52:29 +10:00
Yukihiro "Matz" Matsumoto feabcfe29e doc/limitations.md: remove an entry regarding binding
Since it's no longer a limitation.
2023-03-22 15:26:29 +09:00
Yukihiro "Matz" Matsumoto 800cb15fc3 limitation.md: describe mruby limitation for keyword arguments; #5952 2023-03-17 18:58:04 +09:00
Sergey Ukrainskiy 872f01ddef Fix typo in doc/limitations.md 2022-12-25 13:33:11 +09:00
John Bampton 696226a60e docs: standardize Markdown lists
Previously for lists we were using both `*` and `-` to start the list items.

This pr changes all lists to use `-`.
2022-10-26 13:09:41 +10:00
Yuki Kurihara 9d6cb6ecff Fix doc for limitation
`binding` has been supported since 3.1.0.
2022-09-05 12:12:37 +09:00
mimaki 1bec339230 Update version and release date. (mruby 3.1.0 (2022-05-12)) 2022-05-12 12:19:10 +09:00
Yukihiro "Matz" Matsumoto dccd66f9ef Support Ruby3.0 keyword arguments.
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
<matz@ruby.or.jp> or `@yukihiro_matz`. I can help you.
2021-10-12 20:16:36 +09:00
John Bampton dab5502e8a Run pre-commit with GitHub Actions
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-06-16 08:34:54 +10:00
Yukihiro "Matz" Matsumoto 23019213b7 doc/limitation.md: update the limitation.
- `puts` behavior changed as CRuby
- fix wrong behavior in re-raising in `rescue`
2021-05-10 17:39:50 +09:00
John Bampton 3c1ce680a3 chore: fix grammar 2021-03-09 04:35:03 +10:00
mimaki 0f45836b59 Update version and release date. (mruby 3.0.0 (2021-03-05)) 2021-03-05 17:07:35 +09:00
Yukihiro "Matz" Matsumoto 1c05764ba3 Update limitation.md for integer division change in 3.0. 2021-01-28 17:08:30 +09:00
John Bampton 97eed4493f feat(CI): add a GitHub Action to lint the Markdown
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-12-19 18:22:08 +10:00
Yukihiro "Matz" Matsumoto 2a92fb2516 Make division by zero cause ZeroDivisionError.
As described in ISO 15.2.30.
2020-10-12 16:21:48 +09:00
dearblue 80fe9838d2 Integrate Fixnum class into Integer class
* 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-12 16:21:44 +09:00
Yukihiro "Matz" Matsumoto 10b1a52bb8 Small updates on documents:
- README.md
- CONTRIBUTING.md
- doc/limitations.md
2020-10-12 16:20:48 +09:00
Hiroshi Mimaki 1a9bdfcde5 Update release date. 2020-08-06 12:45:59 +09:00
Hiroshi Mimaki b6b9c57f24 Update version to 2.1.2. (mruby 2.1.2 RC) 2020-07-01 16:49:21 +09:00
Hiroshi Mimaki f9d113f764 Update release date. 2020-06-04 17:20:46 +09:00
Hiroshi Mimaki 3d46f1b620 Update version to 2.1.1. (mruby 2.1.1 RC) 2020-04-10 13:05:23 +09:00
Hiroshi Mimaki 57a56ddaa2 Release mruby 2.1.0. 2019-11-19 18:58:11 +09:00
Hiroshi Mimaki 4c91adc4b2 Update version to 2.1.0. (mruby 2.1.0 RC) 2019-10-18 14:59:27 +09:00
Yukihiro "Matz" Matsumoto 76355dee68 Add unavailability of declaration form of visibility methods; #4708 2019-09-14 23:21:44 +09:00
KOBAYASHI Shuji 74e7c4aa0b Add to doc/limitations.md about nil? redefinition; ref 4996709 [ci skip] 2019-09-03 21:51:15 +09:00
David Siaw 2c86895468 fix up markdown display in doxygen 2019-08-18 13:59:29 +09:00
Hiroshi Mimaki 7c91efc1ff Update version and release date.
`mruby 2.0.1 (2019-4-4)`
2019-04-04 09:26:40 +09:00
Hiroshi Mimaki 1c09046c13 Update release date. 2018-12-11 10:52:20 +09:00
Yukihiro "Matz" Matsumoto 26475d0a78 Update doc/limitations.md for argument destructuring. 2018-11-25 18:03:27 +09:00
Kazuhiro NISHIYAMA 64748691de Remove unmatched quotation mark 2018-07-31 22:09:45 +09:00
Yukihiro "Matz" Matsumoto 4ce9058f64 Describe the difference of the keyword argument behavior.
The implementation of keyword arguments is heavily rely on the prototype
made by @take-cheeze in #3629.
2018-07-31 03:26:53 +09:00
W 3116d06003 Add information about Kernel#binding 2018-06-27 12:20:24 +00:00
Hiroshi Mimaki 023070a639 Set the mruby-1.4.1 release date to 2018-4-27. 2018-04-27 11:30:30 +09:00
Hiroshi Mimaki 58fb6f421a Set the mruby-1.4.0 release date to 2018-1-16. 2018-01-16 10:15:19 +09:00
Yukihiro "Matz" Matsumoto 7405821f5a doc/limitaions.md: Remove infinite recursion entry.
It's fixed since 1.3.0
2017-11-18 21:16:22 +09:00
Yukihiro "Matz" Matsumoto 86f9254df0 doc/limitaions.md: Remove Kernel.binding entry.
Since no ISO classes/methods are not provided by mruby, there's
no use mentioning `Kernel.binding` here.
2017-11-18 21:14:19 +09:00
Hiroshi Mimaki 277391e1b2 Set the mruby-1.3.0 release date to 2017-7-4. 2017-07-04 09:15:16 +09:00
Nobuyoshi Nakada 6511bfd79a Removed trailing spaces 2016-09-28 12:29:41 +09:00
Benoit Daloze 5f37d8bd89 Fix a couple typos in limitations.md 2016-09-17 23:14:55 +02:00
Daniel Bovensiepen 299cb5a7b9 Fix formatting again... 2016-02-12 03:37:36 +08:00
Daniel Bovensiepen 46fbd5349b Add more limitations:
- defined?
  - alias on global variables
  - Operator modification
  - Kernel.binding missing
2016-02-12 03:32:41 +08:00
Yukihiro "Matz" Matsumoto 37344ecaad fixed typos in limitations.md 2016-02-12 00:54:07 +09:00
Daniel Bovensiepen e7eb40f9d6 Fix formatting 2016-02-11 21:23:29 +08:00
Daniel Bovensiepen 44d26dd994 Add more limitations 2016-02-11 21:19:48 +08:00
Yukihiro "Matz" Matsumoto 18870428bc add 1/2 description to limitations.md file 2016-02-11 16:50:01 +09:00
Daniel Bovensiepen 983948c5be Small format fix 2016-02-11 04:48:57 +08:00
Daniel Bovensiepen 3bbc486cf9 Add limitation file 2016-02-11 04:38:29 +08:00