ref: 35f0f61cc9bfa2fa4d4830666dafe1c2c7894c74
parent: f145d7d6f8ab2a77c1e4093374c3bb1b62eb8087
author: cancel <cancel@cancel.fm>
date: Wed Nov 11 03:18:07 EST 2020
Add chaining behavior to J and Y J and Y and now be chained (like YYYYYY) to copy a glyph across the 'wire' they form. This is a simple implementation of the feature. This changes both J and Y to have loops in their definitions, instead of being single reads and writes, which will make them heavier and have a adverse effect on benchmarks. It also makes it harder to explain how orca's VM works, since these operators are now non-trivial and can't be used as examples of trivial operators. But we've decided it's worth it.
--- a/sim.c
+++ b/sim.c
@@ -499,8 +499,15 @@
BEGIN_OPERATOR(jump)
LOWERCASE_REQUIRES_BANG;
PORT(-1, 0, IN);
- PORT(1, 0, OUT);
- POKE(1, 0, PEEK(-1, 0));
+ Glyph g = PEEK(-1, 0);
+ for (Isz i = 1;; ++i) {
+ if (PEEK(i, 0) != This_oper_char) {
+ PORT(i, 0, OUT);
+ POKE(i, 0, g);
+ break;
+ }
+ STUN(i, 0);
+ }
END_OPERATOR
// Note: this is merged from a pull request without being fully tested or
@@ -700,8 +707,15 @@
BEGIN_OPERATOR(yump)
LOWERCASE_REQUIRES_BANG;
PORT(0, -1, IN);
- PORT(0, 1, OUT);
- POKE(0, 1, PEEK(0, -1));
+ Glyph g = PEEK(0, -1);
+ for (Isz i = 1;; ++i) {
+ if (PEEK(0, i) != This_oper_char) {
+ PORT(0, i, OUT);
+ POKE(0, i, g);
+ break;
+ }
+ STUN(0, i);
+ }
END_OPERATOR
BEGIN_OPERATOR(lerp)
--
⑨