cl-cookbook icon indicating copy to clipboard operation
cl-cookbook copied to clipboard

Getting Started: a three-step process for obtaining a basic REPL

Open digikar99 opened this issue 4 years ago • 7 comments

The new page is up here - let me know if there are any changes to be made; or you can cherry-pick the commit.

In particular, 2 of the 3 steps are:

sudo apt-get install sbcl cl-quicklisp rlwrap
sbcl --load /usr/share/cl-quicklisp/quicklisp.lisp \
     --eval '(quicklisp-quickstart:install)' \
     --eval '(ql:add-to-init-file)' \
     --quit

The 3rd step is to append the following to ~/.bashrc, which too can be automated though:

alias sbcl-run="rlwrap sbcl --load $HOME/quicklisp/setup.lisp --eval '(setq *debugger-hook* (lambda (condition hook) 
                    (declare (ignore hook))
                    (princ condition)
                    (abort)))'"

My queries include:

  • On what distros other than Ubuntu 18.04, does the above code work?
  • In order to support other implementations, should we simply write a bash script and distribute that script?
  • I find the interative debugger to be a learning curve; and may be newbies shouldn't deal with it upfront; so either that code should be removed, or a clarification should be added somewhere.

digikar99 avatar Dec 07 '19 07:12 digikar99

Quick feedback and more questions (I'll have a deeper look in a couple of days)

On what distros other than Ubuntu 18.04, does the above code work?

I think all distros, but not Windows nor Mac. We should make them more apparent.

+1 for the automation of installing quicklisp, we should reference it.

I agree with the interactive debugger learning curve. Where do you put the following projects in the picture? (is introducing sbcl-run (which is nice) justified?)

  • sbcli (https://github.com/hellerve/sbcli)
  • cl-repl, that should be "the one repl" on steroïds
  • lem-docker, which has a REPL a M-x start-lisp-repl away (which has the debugger, but we can at least use q)
  • the CLISP repl which is already readline-friendly (no need of rlwrap) and has basic symbols completion?

vindarel avatar Dec 09 '19 14:12 vindarel

I'm not sure about the benefit of lem over Emacs + SLIME or Portacle. For someone not into Emacs and just starting with CL, I think I'd stick with CLISP / sbcl-run / sbcli. But, again, all the three fail for multiline editing. Or so I had thought - just discovered a fork of cl-repl - seems good!

For this, the first two steps stay as they are; and an additional step:

git clone https://github.com/fstamour/cl-repl.git ~/quicklisp/local-projects

And the alias:

alias cl-repl="sbcl --eval '(ql:quickload :cl-repl)' --eval '(cl-repl:main)' --quit"

I don't care about the exact sbcl-run, as much as to suggest aliasing the long command - it is painful to see sbcl --script crash without quicklisp, as a beginner.

In conclusion, I'd be with cl-repl if there is a way to disable debugger; or just the sbcl-run unless the portability matches installation overhead. For anything more advanced, Emacs+SLIME / Portacle / Lem / LispWorks / full-IDE.

PS: SublimeREPL also fails for a multiline REPL.

digikar99 avatar Dec 10 '19 10:12 digikar99

TIL:

$ sbcl
* (require 'sb-aclrepl)

digikar99 avatar Jun 19 '20 10:06 digikar99

The sb-aclrepl module offers an Allegro CL-style Read-Eval-Print Loop for SBCL, with integrated inspector. Adding a debugger interface is planned.

http://www.sbcl.org/manual/#sb_002daclrepl

but what does it actually do?

vindarel avatar Jun 23 '20 10:06 vindarel

Hmm, okay that led to nowhere. For one I missed the "debugger interface is planned". And two, I was still playing around wrapped in rlwrap. Combined, those two gave me an illusion that that provided a useable / beginner-friendly REPL. But, nope.

digikar99 avatar Jun 23 '20 19:06 digikar99

About writing a bash script: there's a fairly complete one here: https://github.com/memleaks/clbuild It can install Quicklisp, and do more things:

Commands are:

  Software installation and quicklisp interaction:

    quickload SYSTEM        ensure that SYSTEM has been downloaded
    system-list             list systems available through quicklisp
    system-apropos FOO      list systems matching FOO
    update-all-dists        update all dists downloaded using quicklisp
    update-dist DIST        update this dist
    update-client           update the quicklisp client

  Software installation from version control (overrides quicklisp):

    install-from-upstream PROJECT...   install projects from upstream
    upstream-list           list projects available from upstream
    upstream-apropos FOO    list projects matching FOO
    trash PROJECT...        remove project

  Lisp invocation:

    prepl                   run Lisp on the terminal (with line editing)
    lisp                    run Lisp on the terminal (raw)
    slime                   run Lisp (using Emacs and SLIME)
    ed [PATHNAME|SYMBOL]    run the CL function ED (uses usercore.conf)

  Housekeeping and utilities:

    rm-cores                clean out previously dumped core files
    slime-configuration     show information on how clbuild starts slime
    help                    this help
    compile-implementation  compile SBCL

Important configuration files:

  clbuild.conf  (make a copy of  clbuild.conf.example and edit it)
  conf.lisp     (make a copy of     conf.lisp.example and edit it)
  usercore.conf (make a copy of usercore.conf.example and edit it)

It seems worth exploring.

vindarel avatar Jul 15 '20 16:07 vindarel

This does look really neat!

digikar99 avatar Jul 16 '20 12:07 digikar99