Commit Graph

548 Commits

Author SHA1 Message Date
Kartik K. Agaram 9ae724e1ec preserve indentation of the sandbox 2021-06-20 23:07:23 -07:00
Kartik K. Agaram 7045af7a4e 'with' lets us drop a few more parens 2021-06-20 22:33:05 -07:00
Kartik K. Agaram fa26249931 new macro: with 2021-06-20 22:32:03 -07:00
Kartik K. Agaram ecc763f092 new macro: ret
http://arclanguage.org/item?id=11068
2021-06-20 22:32:03 -07:00
Kartik K. Agaram deb610367f start dropping parens everywhere 2021-06-20 21:29:33 -07:00
Kartik K. Agaram 6e1aa99a00 start guessing parentheses based on indentation 2021-06-20 21:18:38 -07:00
Kartik K. Agaram 9d7d99fe6c snapshot
This is going better than expected; just 3 failing tests among the new
ones.
2021-06-20 20:36:47 -07:00
Kartik K. Agaram 29795a0db4 start emitting indent tokens 2021-06-18 21:42:01 -07:00
Kartik K. Agaram e5cf570890 redo next-token in more high-level terms 2021-06-18 20:39:33 -07:00
Kartik K. Agaram 80fb9ca9f4 . 2021-06-18 20:12:32 -07:00
Kartik K. Agaram c6cb360544 . 2021-06-18 20:08:19 -07:00
Kartik K. Agaram 93e2e3f934 start emitting token for newline 2021-06-18 20:00:29 -07:00
Kartik K. Agaram 24275c3828 newlines are now a token 2021-06-18 19:54:01 -07:00
Kartik K. Agaram dd133c2a09 start implementing indent-sensitivity
General plan:
  stop skipping newlines during tokenization
  introduce a new indent token, initially skip it transparently
  start doing cleverer things
2021-06-18 19:52:54 -07:00
Kartik K. Agaram b5306cabd3 . 2021-06-18 19:40:35 -07:00
Kartik K. Agaram 2acc00f9b9 . 2021-06-18 07:54:24 -07:00
Kartik K. Agaram c22dbbea39 make code in Readme easier to copy
Thanks Sumeet Agarwal for the suggestion.
2021-06-18 07:11:36 -07:00
Kartik K. Agaram 0f2d0d6abe shell: stop punning tokens as cells 2021-06-18 06:53:55 -07:00
Sumeet Agarwal f36f022b08 change precision when loading sandbox code 2021-06-17 21:24:41 -07:00
Kartik Agaram 3a3fe4addb shell: better screenshot 2021-06-15 15:54:56 -07:00
Kartik K. Agaram 6280749410 always print black pixels when rendering screens
This is an old 'optimization' that turns out to not actually matter.
2021-06-15 15:37:37 -07:00
Kartik Agaram 0138b000a1 shell: improve docs 2021-06-15 14:48:52 -07:00
Kartik Agaram 88378503c4 . 2021-06-15 14:46:27 -07:00
Kartik K. Agaram bc21fe0baf document responsiveness trade-off 2021-06-15 13:02:15 -07:00
Kartik K. Agaram 2bf7cb83ba do more work per fake-screen refresh
Refreshing the fake screen is still a heavyweight operation. Double-buffering
makes it less obvious but doesn't actually reduce the amount of work. We
need to ensure that we do enough work between refreshes to make them economic.
2021-06-15 12:36:38 -07:00
Kartik K. Agaram 8068b8450f more precisely track count of calls to eval
Before I only separately counted calls at each stack depth. I don't remember
if that seemed good enough or was just an oversight.
2021-06-15 12:28:52 -07:00
Kartik K. Agaram c2c6f4c7ab flickerlessly render fake screens in environment
Font rendering now happens off the real screen, which provides the effect
of double-buffering.

Apps can now also use convert-graphemes-to-pixels for more traditional
double-buffering.
2021-06-15 10:33:18 -07:00
Kartik K. Agaram f99cd767a4 periodic run of misc_checks
I should really stop using /disp8 jumps at the top-level given how inconvenient
it is to check for overly large offsets.
2021-06-12 22:34:22 -07:00
Kartik K. Agaram 0dda332ce3 .
Roll back to commit 70919b45f0. Recent commits add lots of extra function
args for dubious benefit.
2021-06-12 21:11:22 -07:00
Kartik K. Agaram 82fdf176c1 snapshot
Looks like what's slowing down screen rendering is in fact _font_ rendering.
2021-06-12 21:11:03 -07:00
Kartik K. Agaram 85bcf050e7 . 2021-06-12 17:50:30 -07:00
Kartik K. Agaram 9b5b3bccd1 trying to eliminate flicker when rendering screen
Two interesting things:
- We don't really need double-buffering for rendering the screen on the
  sandbox as a progress indicator. Everything else is untouched, and render-screen
  should be doing that as well.

- Rendering just pixels of the fake screen is buttery smooth. It's the
  _graphemes_ that are slowing things down. Even though there's so many
  fewer of them!

As a result, drawing the fake screen less frequently in `evaluate` doesn't
actually help with flicker. Even though it'll make the debug cycle shorter.
So my current plan is to attack flicker in isolation before I mess with
the render frequency.

In this commit I optimized away the cursor handling. Still doesn't seem
to be helping. In fact it actually seems _worse_.
2021-06-12 17:40:53 -07:00
Kartik K. Agaram 286819685e eliminate some implicit writes to real screen 2021-06-12 16:24:27 -07:00
Kartik K. Agaram 70919b45f0 .
Rename cells containing screens to screen vars because of the ambiguity
that each grapheme in fake screens is represented by a type screen-cell.
While we're at it, we also analogously rename keyboard vars.
2021-06-12 15:16:50 -07:00
Kartik K. Agaram 4bd1785c86 shell: larger fake screen 2021-06-12 10:46:28 -07:00
Kartik Agaram 662e6b7177 . 2021-06-11 23:02:12 -07:00
Kartik K. Agaram d4968adbc9 . 2021-06-11 23:00:00 -07:00
Kartik K. Agaram af2e837787 try to abolish NULL from primitives 2021-06-11 22:48:14 -07:00
Kartik K. Agaram 952fb9a677 car/cdr of nil is now nil 2021-06-11 21:46:59 -07:00
Kartik K. Agaram 0dc4f9c62b hacky bugfix: support floats in nth
Needed because we don't yet have a primitive in the shell to truncate/round
non-integers to integers.

Before:
  (nth (/ 31 10)    # we don't have float literals yet
       '(1 2 3 4))
  => NULL

..with an unpleasant abort likely later on.

Really the correct thing to do is ensure none of my primitives ever returns
NULL. Start with car/cdr.
2021-06-11 21:36:12 -07:00
Kartik K. Agaram 3191861242 better name 2021-06-11 20:11:16 -07:00
Kartik K. Agaram ef29fcdc91 cancel pending test
After all that, I'm not sure this is the desired behavior. If a function
defines multiple bindings, we shouldn't rename all their keys. So how to
choose?

Perhaps it's not so bad to have "symlinks" in this "file system". To unlink
two bindings you now need to define one of them in the sandbox.

All the refactoring is still useful, though.
2021-06-11 19:33:08 -07:00
Kartik K. Agaram cbf3de0f08 back to the pending test
I'm ready again to take on commit 6169ec59c after lots of refactoring.
2021-06-11 19:26:20 -07:00
Kartik K. Agaram 040b60bc6e .
Save a single trace to potentially multiple globals just like a gap buffer
(if say we have a single let binding defining multiple functions).

I don't have a strong use for this yet, but it seems cleaner. Maybe it's
redundant or wrong.
2021-06-11 19:17:08 -07:00
Kartik K. Agaram 6f64f5d3b6 . 2021-06-11 18:20:47 -07:00
Kartik K. Agaram 8257825468 . 2021-06-11 18:20:30 -07:00
Kartik K. Agaram c1e5ddfa54 . 2021-06-11 18:20:25 -07:00
Kartik K. Agaram 18c8e8c82f . 2021-06-11 17:54:04 -07:00
Kartik K. Agaram 4de136fb85 . 2021-06-11 17:50:34 -07:00
Kartik K. Agaram 177fa96a93 . 2021-06-11 17:48:12 -07:00
Kartik K. Agaram c6e3bce981 . 2021-06-11 17:37:28 -07:00
Kartik K. Agaram 14f00ab369 . 2021-06-11 17:34:45 -07:00
Kartik K. Agaram 6cc2cd6cb5 . 2021-06-11 17:32:22 -07:00
Kartik K. Agaram d5ae556a0c . 2021-06-11 17:31:29 -07:00
Kartik K. Agaram 9487b2dde7 . 2021-06-11 17:19:48 -07:00
Kartik K. Agaram f8c5b63cb9 . 2021-06-11 17:17:13 -07:00
Kartik K. Agaram c29a10ac37 .
Inline a function by patching a few variable names. I don't even have to
worry about `return` statements if there's a single call and it's in tail
position in the caller.
2021-06-11 15:37:03 -07:00
Kartik K. Agaram cc679f4234 . 2021-06-11 15:34:02 -07:00
Kartik K. Agaram 995ff89c8e start showing parse errors under definitions
We don't have support for browsing them yet. Just errors for now, which
should only be a line or two. Larger traces might be useful for inspecting
results of macroexpansion.
2021-06-11 11:32:27 -07:00
Kartik K. Agaram 0b055331bc . 2021-06-11 11:24:49 -07:00
Kartik K. Agaram f6808302e5 . 2021-06-11 11:16:26 -07:00
Kartik K. Agaram 3e32a1b808 . 2021-06-09 21:52:07 -07:00
Kartik K. Agaram eb8260b227 . 2021-06-09 21:38:30 -07:00
Kartik K. Agaram a2d4e41583 . 2021-06-09 21:28:45 -07:00
Kartik K. Agaram 117229ae17 . 2021-06-09 21:21:47 -07:00
Kartik K. Agaram be9fa3780a .
Add argument to a few functions.
2021-06-09 21:05:29 -07:00
Kartik K. Agaram 0aed24e222 . 2021-06-09 20:50:19 -07:00
Kartik K. Agaram 6169ec59c0 make tests pass again
I'm temporarily disabling the pending state. I'm also providing a clearer
error message when we encounter the bug.
2021-06-09 16:05:09 -07:00
Kartik K. Agaram b7e8c2810a snapshot: attempt at modifying a function name
It turns out there's another problem, and it predates the ability to create
new definitions:

  ctrl-s triggers a call to `evaluate`, which inserts a new definition
  into globals. which has a null gap buffer.

All this happens long before the new code in this commit, resulting in a
null gap buffer by the time we get to word-at-cursor.

Which in turn happens because we perform a raw `evaluate`, which doesn't
update the gap buffer like `run` does (using `maybe-stash-gap-buffer-to-global`).

And arguably `evaluate` shouldn't mess with the gap buffer. Gap buffers
are a UI concern.

The hardest version of this immediate scenario: It's unclear how to guarantee
that every definition have a gap buffer, when two definitions may share
one (closures sharing a lexical environment).

New plan:
  - improve the logic for detecting definitions. Looking at the outermost
    layer isn't enough. And a single expression can create multiple definitions.
  - extract a helper to attach a single gap buffer to multiple definitions.
  - have the UI detect conflicts in gap buffers and prompt the user for
    a decision if a different gap buffer already exists for a definition.
2021-06-09 09:16:52 -07:00
Kartik K. Agaram d0d8fc7b04 . 2021-06-08 21:25:58 -07:00
Kartik K. Agaram 206493b5e1 . 2021-06-08 21:09:05 -07:00
Kartik K. Agaram 139620e3d2 shell: function modal now also creates functions 2021-06-08 20:47:07 -07:00
Kartik K. Agaram e375f0104c shell: expand set of possible errors
Requires a change to mu.subx, to unify literal strings with generic
  (addr array _)
2021-06-08 20:21:39 -07:00
Kartik K. Agaram d2f2ac59b6 . 2021-06-08 19:33:51 -07:00
Kartik K. Agaram 0b56336ba8 a place for error messages in the function modal
Probably not ideal, but it's a start.
2021-06-08 19:28:34 -07:00
Kartik K. Agaram de013be794 ok, function modal now has full coverage 2021-06-08 18:09:17 -07:00
Kartik K. Agaram 25803914b3 . 2021-06-08 17:01:56 -07:00
Kartik K. Agaram 9b13d8858a first test for function modal 2021-06-08 16:47:23 -07:00
Kartik K. Agaram 1150170da0 . 2021-06-08 16:31:20 -07:00
Kartik K. Agaram 67aeff8934 .
I wrote a comment about how some code was not covered by tests, and then
promptly forgot what it was for. This is why we need tests.

Now the hack is gone.
2021-06-08 15:06:08 -07:00
Kartik K. Agaram 227d18f8a2 shell: first test for entire environment
This introduces some ergonomic issues. But we have to start somewhere.
2021-06-08 11:57:03 -07:00
Kartik K. Agaram 9d2c64455a fizz-buzz take 2 2021-06-06 23:22:57 -07:00
Kartik K. Agaram 4ec95d54ce reverse-video for cursor 2021-06-06 23:08:40 -07:00
Kartik K. Agaram c546987a07 fizz-buzz exercise 2021-06-06 22:53:46 -07:00
Kartik K. Agaram b6e1cffd9b shell: concept of palettes 2021-06-06 22:38:56 -07:00
Kartik K. Agaram 32487eb00c growing disenamored with up and down 2021-06-06 22:25:07 -07:00
Kartik K. Agaram 3efbe5bf56 . 2021-06-06 22:14:24 -07:00
Kartik K. Agaram 9922e558a3 handle navigating to a non-existent function
We need a place to show error messages. Maybe on the top row?
2021-06-06 21:46:42 -07:00
Kartik Agaram e941dd505c . 2021-06-06 19:03:41 -07:00
Kartik K. Agaram 9fd3111ea9 shell: more foundations from Lisp 2021-06-06 16:41:37 -07:00
Kartik K. Agaram f79ae9ea54 . 2021-06-06 16:40:35 -07:00
Kartik K. Agaram 86f9744257 . 2021-06-06 16:39:07 -07:00
Kartik K. Agaram c1fff5ec14 shell: fleshing out the 'standard library'
Based loosely on Arc's arc.arc:
  http://arclanguage.org
  https://github.com/arclanguage/anarki/blob/official/arc.arc
2021-06-06 12:55:06 -07:00
Kartik K. Agaram 44c53fa572 . 2021-06-06 12:50:25 -07:00
Kartik K. Agaram 8014210316 shell: support negative integer literals
We still don't support _any_ fractional literals, positive or negative.
2021-06-06 12:39:03 -07:00
Kartik K. Agaram 3bdf3b1a7f shell: remainder operation 2021-06-06 12:11:14 -07:00
Kartik K. Agaram d555a71cb3 . 2021-06-06 11:53:25 -07:00
Kartik K. Agaram c4cf38773f more space for definitions 2021-06-06 10:54:50 -07:00
Kartik K. Agaram b5d3095c92 shell: cool new stress-test 2021-06-05 23:12:13 -07:00
Kartik K. Agaram 79a80f7774 . 2021-06-05 23:12:13 -07:00
Kartik K. Agaram 6d67e1bf14 . 2021-06-05 20:50:06 -07:00
Kartik K. Agaram 0b3d456f2c clean up a large memory leak
It turns out (bowboard screen 128) on a real screen massively slowed down
and ran out of memory since commit e2ab1b30b1 on May 19. The culprit was
these changes, which created memory allocations for a new trace on every
recursive call.

I originally had some vague desire to isolate these calls from the user-visible
trace. That's expensive enough that I'll wait until it becomes a concern
before trying to isolate again.
2021-06-05 20:43:39 -07:00
Kartik K. Agaram b012fba1bc . 2021-06-05 18:04:05 -07:00
Kartik K. Agaram 3ac99829c7 shell: moar macros 2021-06-05 17:49:03 -07:00
Kartik K. Agaram f3ee7be683 . 2021-06-05 17:39:56 -07:00
Kartik K. Agaram 48522591f8 refresh edited definitions on ctrl-s 2021-06-05 11:56:13 -07:00
Kartik K. Agaram 99523f654f . 2021-06-05 10:02:44 -07:00
Kartik K. Agaram 6897177137 go-to dialog starts with word at cursor by default 2021-06-05 09:53:15 -07:00
Kartik K. Agaram 3d4e1b8b28 working on jumping to word at cursor
I had a nice clean definition for word-at-cursor, but it's wrong and I'm
going to have to mangle it.
2021-06-05 09:35:37 -07:00
Kartik K. Agaram 5a066f8dda start editing function definitions 2021-06-04 22:11:41 -07:00
Kartik K. Agaram 65e414911f run sandbox even when cursor in function 2021-06-04 22:05:51 -07:00
Kartik K. Agaram 4975bc82df bugfix: show functions after ctrl-g, enter 2021-06-04 22:05:02 -07:00
Kartik K. Agaram 7de9d457eb .
Menu when cursor is within a function.
2021-06-04 21:59:01 -07:00
Kartik K. Agaram 73bbe731c5 select function to render first 2021-06-04 21:56:43 -07:00
Kartik K. Agaram 7531bc2124 always render functions starting at the cursor
For now we just never render definitions above it. That will improve.
2021-06-04 21:48:35 -07:00
Kartik K. Agaram 11e8d83d61 record the definition the cursor is currently at 2021-06-04 21:48:29 -07:00
Kartik K. Agaram 2177b38a68 conditionally display cursor on function side
Always shows at top-most function.
Can't actually do any editing yet.
2021-06-04 21:47:59 -07:00
Kartik K. Agaram 1f05bdcc34 conditionally display cursor in sandbox 2021-06-04 21:47:53 -07:00
Kartik K. Agaram d40dfea3ed modal dialog for function name to jump to 2021-06-04 21:47:36 -07:00
Kartik K. Agaram 846664c4dd . 2021-06-04 20:15:11 -07:00
Kartik K. Agaram 1aba9c6f8e . 2021-06-04 20:14:45 -07:00
Kartik K. Agaram 55001994ef .
Keyboard state machine for jumping to function definition.
2021-06-04 20:13:38 -07:00
Kartik K. Agaram 6f7846ebc4 .
Menu shortcut for jumping to function definition.
2021-06-04 20:13:13 -07:00
Kartik K. Agaram f47051ae57 . 2021-06-04 20:08:29 -07:00
Kartik K. Agaram cd4d0ae5b6 .
Keep hotkeys stable when different elements are in focus.
2021-06-04 20:07:10 -07:00
Kartik K. Agaram 81b3f72fb8 . 2021-06-04 19:58:20 -07:00
Kartik K. Agaram eb6758c61f . 2021-06-04 19:41:27 -07:00
Kartik K. Agaram 30745be5b5 . 2021-06-04 19:41:05 -07:00
Kartik K. Agaram 84bc03ab39 . 2021-06-04 19:40:06 -07:00
Kartik K. Agaram 4dd08c268d . 2021-06-04 16:46:20 -07:00
Kartik K. Agaram 224e264a65 . 2021-06-04 16:43:19 -07:00
Kartik K. Agaram cfb5dbce59 . 2021-06-04 16:41:18 -07:00
Kartik K. Agaram e683a3fdee . 2021-06-04 16:39:05 -07:00
Kartik K. Agaram 380837ac2a more convenient 'def' 2021-06-04 16:12:30 -07:00
Kartik K. Agaram bb1ccae27f rename the definition primitive to 'def' 2021-06-04 16:07:07 -07:00
Kartik K. Agaram 4bb826b40e . 2021-06-03 20:55:42 -07:00
Kartik K. Agaram 1c6b965a7f starting to support function editing 2021-06-03 20:49:24 -07:00
Kartik K. Agaram d00f8dc6ca . 2021-06-03 20:37:51 -07:00
Kartik K. Agaram 3ef69a05b0 . 2021-06-03 20:29:37 -07:00
Kartik K. Agaram 6b34a1c9bf . 2021-06-03 14:55:33 -07:00
Kartik K. Agaram b9ad848cff . 2021-06-03 14:49:49 -07:00
Kartik K. Agaram 63cd30d806 . 2021-06-03 14:42:07 -07:00
Kartik K. Agaram 9446e7e594 .
Drop some low-entropy trace lines.
2021-06-03 00:03:20 -07:00
Kartik K. Agaram bd49d5c35c shell: more stable trace when rerunning 2021-06-02 23:57:23 -07:00
Kartik K. Agaram 60872b2b77 . 2021-06-02 23:36:34 -07:00
Kartik Agaram 35336a5f64 .
State as of https://archive.org/details/akkartik-mu-2021-05-31
2021-05-31 23:13:10 -07:00
Kartik Agaram ccadba5b95 .
Until we get scrolling on functions, it's a little cleaner to draw the
primitives on top.
2021-05-31 20:40:08 -07:00
Kartik K. Agaram 7640a77c5f interrupt repl on keypress 2021-05-31 15:18:25 -07:00
Kartik K. Agaram 0c0541d709 . 2021-05-31 15:18:25 -07:00
Kartik K. Agaram ee536ff3e8 . 2021-05-31 15:18:25 -07:00