• 0 Posts
  • 2 Comments
Joined 10 months ago
cake
Cake day: November 24th, 2023

help-circle
  • Patrick-Poitras@alien.topBtoLispvariable binding
    link
    fedilink
    English
    arrow-up
    1
    ·
    10 months ago

    My understanding was that the first example should give 20 on SBCL. I tried it and it gave me 20.

    On your second example, on SBCL, I got 20 for foo and 10 for bar.

    * (defvar *x* 10)
    *X*
    * (defun foo ()
         (let ((*x* 20))
             (bar)))
    ; in: DEFUN FOO
    ;     (BAR)
    ; 
    ; caught STYLE-WARNING:
    ;   undefined function: COMMON-LISP-USER::BAR
    ; 
    ; compilation unit finished
    ;   Undefined function:
    ;     BAR
    ;   caught 1 STYLE-WARNING condition
    FOO
    * (defun bar ()
         (print *x*))
    BAR
    * (foo)
    
    20 
    20
    * (bar)
    
    10 
    10
    

    Not sure if that’s helpful in any way. Is there some context we’re missing?


  • In learning emacs, I found it easier to spend a few hours customizing emacs so that it does exactly what I wanted rather than learning how to do things the emacs way. (yay CUA mode!) If the thing holding you back is that the defaults are garbage, or you prefer Vim bindings, there’s some packages that handle that. Maybe there’s a glimmer of hope there.

    That being said, if you’ve given those a try, or are just plain out done with emacs, you can use SBCL like an interpreter and have it produce the output you want. The experience you’ll get from that is similar to other languages that run on the “Write -> Compile -> Run -> Read output” cycle, like C++ or Rust.

    REPL-style, interactive workflow is going to be more difficult. The UX in REPL mode with default SBCL is bad enough that if I had to use that, I’d probably copy-paste code in and out of the REPL window from another editor. Slimv and Vlime are probably better than that.