Skip to content

Instantly share code, notes, and snippets.

@RickCarlino
Created July 30, 2022 22:51
Show Gist options
  • Save RickCarlino/da70a5377683ea9133a0d7d3ed94cfe5 to your computer and use it in GitHub Desktop.
Save RickCarlino/da70a5377683ea9133a0d7d3ed94cfe5 to your computer and use it in GitHub Desktop.
Less-than-ideal API with `mem:*` words

Problem

Below I am using a mem:inspect word. It is not defined here, but it has the following signature: :mem:inspect (aa-) ... ;.

How I wish it worked

The following example would be nice, but in the real world, it causes a segfault:

#100 mem:alloc 'memory double:const
memory mem:inspect
memory #1 + mem:inspect
memory #2 + mem:inspect
memory #3 + mem:inspect

How it actually works

The example below works, but the API is less than ideal:

#100 mem:alloc 'memory double:const
memory mem:inspect
memory swap #1 + swap mem:inspect
memory swap #2 + swap mem:inspect
memory swap #3 + swap mem:inspect

How To Fix It

I have the MSW/LSW swapped on the mem: device words, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment