guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using guile-scmutils with REPL and compilation


From: Viacheslav Dushin
Subject: Using guile-scmutils with REPL and compilation
Date: Sat, 20 Jun 2020 02:43:00 +0300

Hello all

I have a couple of questions about guile-scmutils.

First one:
I run into a similar problem that is described here:
https://lists.gnu.org/archive/html/guile-user/2008-04/msg00007.html
Turns out the solution is to modify top-repl as said here:
https://lists.gnu.org/archive/html/guile-user/2008-04/msg00021.html

Since I'm new to Lisp I decided to work on the ice-9 source code
directly. I'm going to create my own scmutils-top-repl after I resolve
all problems.

Here is how my top-repl from top-repl.scm looks like:

(define (top-repl)
  (let ((guile-user-module (resolve-module '(guile-user))))

    (add-to-load-path "/Users/slava/.guile.d/")
    (load  (%search-load-path  "guile-scmutils/src/load.scm"))
    (set-current-module generic-environment)
    ;; Use some convenient modules (in reverse order)

    (set-current-module guile-user-module)
    (process-use-modules
     (append
      '(((ice-9 r5rs))
        ((ice-9 session)))
      (if (provided? 'regex)
          '(((ice-9 regex)))
          '())
      (if (provided? 'threads)
          '(((ice-9 threads)))
          '())))

    (call-with-sigint
     (lambda ()
       (and (defined? 'setlocale)
            (catch 'system-error
              (lambda ()
                (setlocale LC_ALL ""))
              (lambda (key subr fmt args errno)
                (format (current-error-port)
                        "warning: failed to install locale: ~a~%"
                        (strerror (car errno))))))

       (let ((status (start-repl (current-language))))
         (run-hook exit-hook)
         status)))
    )
  )

I simply added these three lines:
    (add-to-load-path "/Users/slava/.guile.d/")
    (load  (%search-load-path  "guile-scmutils/src/load.scm"))
    (set-current-module generic-environment)

When I run it I get the following error:

;;; note: source file
/usr/local/Cellar/guile/2.2.7_2/share/guile/2.2/ice-9/boot-9.scm
;;;       newer than compiled
/usr/local/Cellar/guile/2.2.7_2/lib/guile/2.2/ccache/ice-9/boot-9.go
;;; note: source file
/usr/local/Cellar/guile/2.2.7_2/share/guile/2.2/ice-9/top-repl.scm
;;;       newer than compiled
/usr/local/Cellar/guile/2.2.7_2/lib/guile/2.2/ccache/ice-9/top-repl.go
;;; note: source file
/usr/local/Cellar/guile/2.2.7_2/share/guile/2.2/ice-9/top-repl.scm
;;;       newer than compiled
/Users/slava/.cache/guile/ccache/2.2-LE-8-3.A/usr/local/Cellar/guile/2.2.7_2/share/guile/2.2/ice-9/top-repl.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /usr/local/Cellar/guile/2.2.7_2/share/guile/2.2/ice-9/top-repl.scm
;;; ice-9/top-repl.scm:53:4: warning: possibly unbound variable
`generic-environment'
;;; compiled 
/Users/slava/.cache/guile/ccache/2.2-LE-8-3.A/usr/local/Cellar/guile/2.2.7_2/share/guile/2.2/ice-9/top-repl.scm.go
Backtrace:
           3 (apply-smob/1 #<catch-closure 10eabcee0>)
In ice-9/eval.scm:
   657:36  2 (_ _)
In ice-9/top-repl.scm:
     52:4  1 (top-repl)
In unknown file:
           0 (_ #<procedure 10e617440 at ice-9/eval.scm:330:13 ()> # #)

ERROR: In procedure module-lookup: Unbound variable: generic-environment

If I remove (set-current-module guile-user-module), then it runs OK
and I even have access to the scmutils functions, e.g.:

(define h (compose cube sin))
(h 2)

outputs:

.7518269446689928

What am I missing?

Second one:
There is also a problem with code compilation:

(load  (%search-load-path  "guile-scmutils/src/load.scm"))
(set-current-module generic-environment)

(define ((Gamma w) t)
  (up t (w t) ((D w) t)))

works fine in the REPL, but fails to compile (guile code.scm) with the
following error:

;;; note: source file
/usr/local/Cellar/guile/2.2.7_2/share/guile/2.2/ice-9/boot-9.scm
;;;       newer than compiled
/usr/local/Cellar/guile/2.2.7_2/lib/guile/2.2/ccache/ice-9/boot-9.go
;;; note: source file
/Users/slava/Documents/work/func-diff-geometry/prologue/code.scm
;;;       newer than compiled
/Users/slava/.cache/guile/ccache/2.2-LE-8-3.A/Users/slava/Documents/work/func-diff-geometry/prologue/code.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /Users/slava/Documents/work/func-diff-geometry/prologue/code.scm
;;; WARNING: compilation of
/Users/slava/Documents/work/func-diff-geometry/prologue/code.scm
failed:
;;; Syntax error:
;;; /Users/slava/Documents/work/func-diff-geometry/prologue/code.scm:4:0:
source expression failed to match any pattern in form (define ((Gamma
w) t) (up t (w t) ((D w) t)))
Backtrace:
           6 (primitive-load "/Users/slava/Documents/work/func-diff-…")
           5 (_ #<procedure 102790fe0 at ice-9/eval.scm:330:13 ()> # #)
           4 (_ #<procedure 102790ec0 at ice-9/eval.scm:330:13 ()> # #)
           3 (_ #<procedure 102790de0 at ice-9/eval.scm:330:13 ()> # #)
In ice-9/eval.scm:
   245:16  2 (_ #(#(#<module (guile) 102695dc0> #f #<variable 10…> …)))
In unknown file:
           1 (string-prefix? "/" #f #<undefined> #<undefined> #<und…> …)
           0 (_ #<procedure 102790b20 at ice-9/eval.scm:330:13 ()> # #)

ERROR: In procedure string-prefix?: Wrong type argument in position 2
(expecting string): #f

Thanks, Slava



reply via email to

[Prev in Thread] Current Thread [Next in Thread]