Skip to content
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

exposing eval_in_lisp via jscl.evaluateString in prelude.js #315

Merged
merged 1 commit into from
May 4, 2018

Conversation

HenryS1
Copy link
Contributor

@HenryS1 HenryS1 commented May 4, 2018

issue #265

@davazp
Copy link
Member

davazp commented May 4, 2018

Somehow I thought we had this already! Good one.

By the way, you can mention the issues in the commit messages like

This closes #265 . or This fixes #265. They issue will be automatically closed as we merge it and it will make easier for people to track changes.

https://help.github.com/articles/closing-issues-using-keywords/#

@davazp davazp merged commit a6576cc into jscl-project:master May 4, 2018
@davazp davazp mentioned this pull request May 4, 2018
@viebel
Copy link

viebel commented May 5, 2018

That is awesome @davazp and @HenryS1 !
Can you provide the full instructions in order to be able to use jscl.evaluateString in a standalone mode.
What I need is a (single) javascript file that I can include in a webpage (e.g jsfiddle) and being able to call jscl.evaluateString in this webpage

@t-cool
Copy link
Member

t-cool commented May 5, 2018

@viebel

Hi.
You need to download the src code and compile it.
I use sbcl for its compiler.
After compiling the src, you can use jscl.evaluateString method.

I'll write down the steps as bellow:

# on your Terminal
$ git clone https://github.com/jscl-project/jscl.git
$ cd jscl
$ sbcl

# then sbcl starts
(load "jscl.lisp")
(jscl:bootstrap)

After doing (jscl:bootstrap), jscl.html is geberated in jscl directory.
You can open the file by Firefox and open the JavaScript console.
Then you can use jscl.evaluateString and change the Lisp environment by JavaScript.

In the example bellow, I defined the function in the console using jscl.evaluateString and eval it on Lisp REPL.

example

@t-cool
Copy link
Member

t-cool commented May 5, 2018

@viebel
I made a toy app using JSCL.
If you want to use JSCL like Jsfiddle, it would be useful.

jscl

You can play with JSCL in this Github Pages:
https://t-cool.github.io/jscl-playground

The src is here:

Normal version

https://github.com/t-cool/jscl-playground/tree/master

React version

https://github.com/t-cool/jscl-playground

Regards.
Hiroki

@viebel
Copy link

viebel commented May 6, 2018

@t-cool when I execute (jscl:bootstrap) in jscl, I am getting this error:

Compiling src/misc.lisp...
Compiling src/symbol.lisp...
Compiling src/package.lisp...
Compiling src/ansiloop/ansi-loop.lisp...
Compiling src/read.lisp...
Compiling src/conditions.lisp...
Compiling src/backquote.lisp...
Compiling src/compiler/codegen.lisp...
Compiling src/compiler/compiler.lisp...
Compiling src/documentation.lisp...
Compiling src/worker.lisp...
Compiling src/toplevel.lisp...

debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "main thread" RUNNING {10005505B3}>:
  The name `"SB-POSIX"' does not designate any package.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(FIND-PACKAGE-OR-FAIL "SB-POSIX")
   source: (ERROR "The name `~S' does not designate any package."
                  PACKAGE-DESIGNATOR)
0]

@t-cool
Copy link
Member

t-cool commented May 6, 2018

@viebel
Please check your sbcl version.
I compiled JSCL using SBCL 1.4.3.

You can get sbcl from its official website:
http://www.sbcl.org/platform-table.html

$ sbcl --version
SBCL 1.4.3

@HenryS1
Copy link
Contributor Author

HenryS1 commented May 6, 2018

@viebel There is some non portable lisp in the source so compilation will only work with SBCL. Which lisp implementation are you using? I've created issue #317 to make JSCL portable between implementations. In the mean time you'll need to use SBCL.

@viebel
Copy link

viebel commented May 6, 2018

@t-cool
I installed sbcl via homebrew (MacOS) and I got version 1.4.7

$ sbcl --version
SBCL 1.4.7

@viebel
Copy link

viebel commented May 6, 2018

@HenryS1 Could you compile the code on your side and provide a standalone javascript file (maybe upload to github) that can exectute jscl.evaluateString ?

@t-cool
Copy link
Member

t-cool commented May 6, 2018

@viebel

I upgraded sbcl to 1.4.7 on my macbook and I could compiled jscl.
I made a repository and upload the compiled files.
If you need, please use these files.
https://github.com/t-cool/jscl

@viebel
Copy link

viebel commented May 7, 2018

That's awesome @t-cool.
It allowed me to integrate JSCL into Klispe.
Now we can have Common Lisp code snippets in any web page. See demo here.
@HenryS1 @davazp

@t-cool
Copy link
Member

t-cool commented May 7, 2018

@viebel
Wow! That's awesome!
I'll try to make something using Klispe.

@viebel
Copy link

viebel commented May 7, 2018

what do you have in mind @t-cool ?

@davazp
Copy link
Member

davazp commented May 7, 2018

@viebel . I love it :-) that is really cool indeed.

If it helps, notice that jscl is also under a npm package

https://www.npmjs.com/package/jscl

if your integration with klipse doesn't require custom CL code, you can use that package to help you keep jscl up-to-date.

Thanks for the demo

@t-cool
Copy link
Member

t-cool commented May 7, 2018

@viebel
I wrote jscl-playground for my students a few month ago.
https://t-cool.github.io/jscl-playground/

The image is similar to jscl-playground, an educational app.
Af the beginning, a ball is bouncing in the canvas and students write some cl codes to put the ball into the goal.
When the ball arrives to the goal, the prompt says "Success!!", and they can proceed to the next chapter...something like that.

@davazp
Copy link
Member

davazp commented May 7, 2018

@viebel A colleague reported me that (loop would hang klipse. Probably the same EOF error on reading than @HenryS1 was trying to solve? In case you aren't aware of it.

@HenryS1
Copy link
Contributor Author

HenryS1 commented May 7, 2018

@viebel Fantastic :)
@t-cool JSCL-playground looks really cool too!

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.

4 participants