Don't break reverse backwards compat.

Breaking backwards compatibiliy here is not worth it.
Also update changelog.
This commit is contained in:
Calvin Rose 2020-07-03 10:13:55 -05:00
parent b89f0fac7b
commit 55cf9f5e1c
3 changed files with 12 additions and 4 deletions

View File

@ -2,11 +2,16 @@
All notable changes to this project will be documented in this file.
## Unreleased - ???
- The gc interval is now autotuned, to prevent very bad gc behavior.
- Improvements to the bytecode compiler, Janet will now generate more efficient bytecode.
- Add `peg/find`, `peg/find-all`, `peg/replace`, and `peg/replace-all`
- Add `math/nan`
- Add `forv` macro
- Add `symbol/slice`
- Add `keyword/slice`
- Allow cross compilation with Makefile.
- Change `compare-primitve` to `cmp` and make it more efficient.
- Change `reverse` to `reversed`, reverse now mutates the backing array
- Add `reverse!` for reversing an array or buffer in place.
- `janet_dobytes` and `janet_dostring` return parse errors in \*out
- Add `repeat` macro for iterating something n times.
- Add `eachy` (each yield) macro for iterating a fiber.

View File

@ -1202,13 +1202,13 @@
(if x nil (set res x)))
res)
(defn reverse
(defn reverse!
"Reverses the order of the elements in a given array or buffer and returns it
mutated."
[t]
(def len-1 (- (length t) 1))
(def half (/ len-1 2))
(for i 0 half
(forv i 0 half
(def j (- len-1 i))
(def l (in t i))
(def r (in t j))
@ -1216,7 +1216,7 @@
(put t j l))
t)
(defn reversed
(defn reverse
"Reverses the order of the elements in a given array or tuple and returns
a new array. If string or buffer is provided function returns array of chars reversed."
[t]

View File

@ -26,6 +26,9 @@
#include "util.h"
#include "state.h"
#include "gc.h"
#ifdef JANET_WINDOWS
#include <windows.h>
#endif
#endif
#include <inttypes.h>