Awesome I knew it had to be something that was a change from SC. Yeah sometimes I just put in a function so I can see it better but yes I don’t need it
That would be a general REPL feature that works with any interpreted language. Is that correct? Or is it something else?
I’m trying to write a basic mode with a REPL in emacs. For my first attempt, I’m trying comint
to see how that works. Basic syntax color and REPL do not seem super complicated. I got it working soon after I compiled SAPF for the first time in my machine.
It is working. But, of course, it needs improvements and much more work:
@julian I’m also thinking about what you said about what text editors could do, and wondering how this could be done.
I’m checking some code for other Postfix languages, and it seems there is something we could borrow.
For example, one idea (that would work for postscript):
100 200
dup
add
3 mul
The stack visualization could , for example, as one possibility, update following the cursor:
cursor after 100 200:
| 200 |
| 100 |
cursor after dup:
| 200 |
| 200 |
| 100 |
cursor after add:
| 300 |
| 100 |
cursor after 3 mul:
| 300 |
I wonder how a “stack visualization” would work with SAPF. (Just brainstorming right now…)
Would def be a helpful tool to see stacks printed and result returned back in a simple visual way either color, line beak, indent …or whatever is thought to work best.
also see value in the visual que method @julian had sketched. Personally I rely a lot on the sc’s input args being provided as you code. Side note is it just me or does sapf sound really really good, really loving it. Thanks for your generosity @asynth
Awesome 29 characters
Nice! Perhaps some extra syntax highlighting might depend on the cursor position, giving you information about the context. So in something like:
.5 2X brown .49 - 0 | 20 * 5k 1 rhpf play
At first sight, you don’t see where the 20
“belongs”. To indicate “belonging” for all tokens at the same time might be a bit much, so just showing it for where you are could reduce this overload.
((.5 2X brown .49 - 0 |) (20) *) 5k 1 rhpf play
instead of
(((((((.5 2X) brown) .49 -) (0) |) (20) *) (5k) (1) rhpf) play)
(I don’t suggest that this should happen with parens, just indicating the structure that one could highlight in some way),
That’s a good idea,it should be a very well known challenge, given how long this syntactic tradition goes back.
That would require some emacs-lisp skills, but it seems possible.
re: editor integration, i want to point out some existing work
emacs:
neovim:
- GitHub - vasilymilovidov/sapf.nvim: nvim plugin for sapf
- GitHub - salkin-mada/sapf.nvim: Interact with the sapf interpreter thru Neovim
lsp:
some syntax discussion:
It’s kind of the direction I was taking (in the important part, at least).
Does it do syntax colorize?
Also, we need to check the LSP before anything.
Thank you!
not yet. i was thinking that it might be nice to implement that as a tree-sitter grammar, since it would be more widely useful and it seems to be the direction many modes are moving. i havent tried the lsp yet, but generally i think it would be good to have highlighting also without it.
I did old-style, but since there is a group effort behind this, and there are better ideas out there that can be helpful for many editors at the same time (LSP, etc), let’s think about the tasks together, it makes a lot of sense
by the way, if anyone has a better understanding of lsp and the best practices of implementing one, feel free to correct my mistakes or re-implement it, because I have no prior experience with it. i just wanted something to help me find my way around sapf
I’m reading the README and don’t understand this example
[2 aa 3 ba] --> [2 3 2]
Could anyone help me ?
aa
duplicates and ba
swaps position of what’s been stacked
so aa is giving you two 2’s and then ba swapping the last two to make 2 3 2
Thanks Mike, I had not understood they were functions !!
sapf> `aa help
(a --> a a) push the top item on stack again.
2 3 3 3
sapf> `ba help
(a b --> b a) swap top two items.
Do you know if there’s something in SAPF to play snippets of audio files, like PlayBuf in SC ?
Hmm not that I’ve come across…I’m guessing you’ve seen the helpall…even with sc I don’t explore sample base approaches unfortunately
I think you want sf> (filename -->) read channels from an audio file. not real time.
I find myself using sapf frequently. I believe due to the syntax and the limited number of ugens. My personal opinion only but it feels closer to a modular synth due its restrictions. Im very novice and not doing anything tricky or sophisticated with it (yet). Just curious if others are also working in it and if so dose it warrant its own dedicated forum…? I feel rude to highjack this SC one. I think a simple discourse site is 20 bucks a month? I could cover that… might be slow at setting it up. Im not so savvy lol.