Skip to content

S38.1[WIP]#25

Open
echawk wants to merge 4 commits intodeech:masterfrom
echawk:S38.1
Open

S38.1[WIP]#25
echawk wants to merge 4 commits intodeech:masterfrom
echawk:S38.1

Conversation

@echawk
Copy link
Copy Markdown

@echawk echawk commented Mar 20, 2024

This is the new branch for working on updating to S38.1

Still the same issues as the previous pr, but much tidier.

You can run the following to test out the branch:

emacs --load run.el

@joelmccracken
Copy link
Copy Markdown
Collaborator

This is cool to see. I've been thinking about doing this myself - there are some things that I've been struggling with as I use this project, and the big difference between kernel versions is always something that makes me wonder.

However, if I was going to do this, I would also do the following:

  • download the new kernel
  • run the standard tests with the new kernel, run them.
  • download the benchmarks, see if comparison is possible.
    I may pick up from where you left off here, unless you have more that I don't see. TY!

@echawk
Copy link
Copy Markdown
Author

echawk commented Sep 2, 2024

@joelmccracken From what I've read on the shen google group, the biggest change is between the S and non-S kernel series. Once we get the port to work with one S series kernel, the rest should be trivial to maintain (at least that is my impression).

Let me know if you get it to work!

@joelmccracken
Copy link
Copy Markdown
Collaborator

btw @echawk do you have any interesting shen-elisp code to share? I'm still pretty new in the overall process, but here's mine:

#+begin_src emacs-lisp
(let ((shen-dir "~/Projects/shen-elisp"))
  (add-to-list 'load-path shen-dir)
  (require 'shen-elisp)
  (require 'shen-repl)
  (byte-recompile-directory shen-dir 0 t)
  )
#+end_src

#+RESULTS:
: Done (Total of 7 files compiled)

#+begin_src emacs-lisp
(defun shen-eval-string (codestr)
  (with-current-buffer "*shen-repl*"
    (goto-char (point-max))
    (let ((response
           (let ((before (point-max)))
             (insert codestr)
             (shen/repl-send-input)
             (buffer-substring before (point-max)))))
        (message response))))
#+end_src

#+RESULTS:
: shen-eval-string

#+begin_src emacs-lisp :results raw replace
(defun shen/shen.emacs-eval (code)
  (eval code))
#+end_src

#+RESULTS:
shen/shen.emacs-eval
shen/shen.emacs-eval

#+begin_src emacs-lisp
(shen-eval-string "(tc -)")

(shen-eval-string "
(define emacs.point
  -> (shen.emacs-eval [point]))
")
(shen-eval-string "(declare emacs.point [--> number])")
(shen-eval-string "(tc +)")
(shen-eval-string "(emacs.point)")
#+end_src

#+RESULTS:
: (point)
: 317 : number
: (5+)

@joelmccracken
Copy link
Copy Markdown
Collaborator

Well at this point there are just a ton of changes, and given I don't really know how @deech built it in the first place, its hard for me to trace. @deech how would you feel if I basically started a fresh port, lifting what I can from this port? I'd give you credit of course

Otherwise I could also keep poking at it, just hard to make progress. I know that like at one point I looked at the official sources for the version of shen that this port supports, and it clarified why certain things look so different, but still, not too sure how to move forward.

@echawk
Copy link
Copy Markdown
Author

echawk commented Sep 10, 2024

@joelmccracken let me know if/when you start this project since I'd be happy to help get a port up and running

I also wonder if it would be easier to try and port the CL version of shen to elisp?

@joelmccracken
Copy link
Copy Markdown
Collaborator

yeah @echawk ill let you know if/when I do. And same here, if you decide to work on it yourself, lmk. And yea the common lisp one may be eaiser, or at least a good inspiration. I'll say tho that the CL version makes heavy use of saving itself in a lisp image, which isn't whats needed for emacs; but at least some of the ideas may help.

@joelmccracken
Copy link
Copy Markdown
Collaborator

Hmm, tho, so I see that the shenlanguage.org site doesn't contain the kernel versions before 31, though the open source repo does still host those versions; perhaps it would be possible to do an upgrade bit by bit? I need to think a little bit about it. And for that matter, the OS kernel for 21 also contains tests, so maybe a feasible way to go about this would be try to change this one from official 21 to OS 21, get OS 21 tests running, and go from there.

It would also give me a good reason to get the tests running w/ github actions etc, which I've been wanting to do.

I need to think about this a bit, but I think it might be easier

@echawk
Copy link
Copy Markdown
Author

echawk commented Sep 11, 2024

If I have some time in the next couple of weeks, I'll try to take a stab at it.

@echawk
Copy link
Copy Markdown
Author

echawk commented Sep 14, 2024

@joelmccracken I've got the start of a KLambda interpreter - it's currently far from being able to run shen code, but so far it's pretty promising ~180 lines of code.

Should I make a repo?

@joelmccracken
Copy link
Copy Markdown
Collaborator

sure. Though, just FYI, I kinda spent some more time on the upgrade path, and I think I had m ore success? but having a second WIP would be great too

@echawk
Copy link
Copy Markdown
Author

echawk commented Sep 15, 2024

@joelmccracken do you have a link to your updated stuff? does it actually drop you into a working repl?

@joelmccracken
Copy link
Copy Markdown
Collaborator

joelmccracken commented Sep 15, 2024 via email

@echawk
Copy link
Copy Markdown
Author

echawk commented Apr 22, 2026

@joelmccracken Apologies for necrobumping this thread, but I now have a working KLambda interpreter which can run Shen in my repo https://github.com/echawk/kl.el - use emacs to load 'shen.el' and run shen/repl - it will take about 30-40 seconds but it will drop you into (albeit slow) Shen repl. I'd like to improve the ergonomics, and make the implementation much faster (ideally using some techniques from here), but the overall codebase is ~1k lines.

The hope is to keep the interpreter around for anyone else who wants to write a KL interpreter, but move kl.el to be effectively a macroexpander/compiler from KL to emacs lisp; My impression is that by depending on emacs' compiler (and native backend) we can get quite good performance.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants