-
Notifications
You must be signed in to change notification settings - Fork 17
Use in computer games #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cool. it looks you really worked through the code! the attribution is fine. please tell me when you have a game ready which uses k. |
i made some simplifications for smaller code size recently. e.g. i removed digraph adverbs, over/scan with initial value, and each-prior. your refcard reflects the old behaviour. Longer ago i also had simd versions (simd128 in wasm) and portable vector instructions in c. |
Interesting, I did notice something had changed w.r.t adverbs. I guess this is to implement k7/k9 syntax? FYI I posted a job on freelancer to see if someone is willing to rewrite the parser/interpreter so that it doesn't recursively call exec. This would allow stepping through the byte code, which would be quite useful in my projects. |
the current version uses a very small stack at a fixed address. it can be extended, e.g. by using a normal k list that may grow. that would require a further indirection as the address may change. i think the small k stack is mostly limiting recursive calls, long before the c stack is exceeded. |
i thought about it for a while and wrote down how i would rewrite it: steps.md if you or someone finds a better way it would be interesting to see. |
Thanks for the write up. Not sure if code size would shrink, but code complexity might be decreased somewhat. I'm sure some cases could be faster, but anything involving each or reduce with a lambda would certainly be slowed down. At least I don't think it would be easy to optimize that kind of construct. |
the question is how important vm speed is for a language like k. my guess is that some slowdown in the vm will not be noticed. |
i abandoned the stepping interpreter described in steps.md and found a simpler way for tail calls: bfb9a6e50 we can keep the current exec function mostly, including keeping the stack top in a local variable (accumulator). todo is the monadic case i also store symbols and shadowed variables for lambda calls in a complex vector, which is flat so we don't need to do refcounting. |
I used to treat (guile-) Scheme as my go-to calculator / prototyping language, so tail call optimizations sounds great. About the stepping, I have someone looking into it but no clue if they are getting anywhere. Worst case it's a feature that can live on my TODO list for a few years. |
it should work now for both monadic and n-ary application of lambda functions.
also in the general sense not just tail-recursion but any function with different number of arguments can be called. i'd like to see some examples, e.g. for algorithms that can be nicely expressed with tail calls but are more cumbersome in k without. |
Hi, thanks for creating this!
I have decided to use a small fork of ktye/k in a computer game project.
My fork is here: https://gitlab.com/talas777/spesh
I only plan to use the C-version and I used the LGPLv3+ license (my favorite).
Please let me know if there is some way I can credit you or give attribution.
Perhaps a link to your project?
I added "Copyright (c) 2022,2023 ktye", hope that wasn't too wrong?
Thanks again!
The text was updated successfully, but these errors were encountered: