• SBCL: help; loading a file

    From steve@21:1/5 to All on Thu Jul 29 19:05:44 2021
    ARG!

    How does one load a file into sbcl from the command line; when I load everything from emacs/slime it's find but with the (load "file") it does
    not.

    This is the file. How do I I load these sexps into sbcl short of dumping
    an image? It's driving me crazy... No loading it in as a file with
    `load' does not work. I must load it by hand at the terminal. I am
    missing something stupid or is the repl in a different thread or
    something?


    (require :sb-posix)
    (load "packages")
    (load-shared-object "./tty_modes.so" )
    (load "local")
    (load "termdata")
    (load "terminfo")
    (terminfo:set-termtype "linux3.0")
    (load "screen")
    (screen:tty-device-open "/dev/tty")
    (in-package :screen)
    (load "display")
    (load "motion")
    ;;(tty-device-termios-set :packet)
    (dprompt)


    I do not know how to use defsystem or asdf; that never seems to work for
    me. I have the c file, so I just use makefiles. I also do not have quick
    lisp. Does this make a difference?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From steve@21:1/5 to All on Thu Jul 29 20:03:05 2021
    steve <steve@loft.i-did-not-set--mail-host-address--so-tickle-me>
    writes:

    ARG!

    How does one load a file into sbcl from the command line; when I load everything from emacs/slime it's find but with the (load "file") it does
    not.

    This is the file. How do I I load these sexps into sbcl short of dumping
    an image? It's driving me crazy... No loading it in as a file with
    `load' does not work. I must load it by hand at the terminal. I am
    missing something stupid or is the repl in a different thread or
    something?


    (require :sb-posix)
    (load "packages")
    (load-shared-object "./tty_modes.so" )
    (load "local")
    (load "termdata")
    (load "terminfo")
    (terminfo:set-termtype "linux3.0")
    (load "screen")
    (screen:tty-device-open "/dev/tty")
    (in-package :screen)

    The `in-package' does not work. I am I in the right thread? Should I try
    and put SBCL into interp mode. It's like it won't stop...


    (load "display")
    (load "motion")
    ;;(tty-device-termios-set :packet)

    (dprompt)

    Even (screen::dpromp)

    Driving me nuts. All this code works and I get stuck here - ahh nothing new.


    I do not know how to use defsystem or asdf; that never seems to work for

    Maybe so? Does defsystem do c files with a c compiler?

    me. I have the c file, so I just use makefiles. I also do not have quick lisp. Does this make a difference?

    Any info/tutorials on the defsystem would be helpful...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tom Russ@21:1/5 to steve on Thu Jul 29 23:35:36 2021
    On Thursday, July 29, 2021 at 4:06:02 PM UTC-7, steve wrote:
    ARG!

    How does one load a file into sbcl from the command line; when I load everything from emacs/slime it's find but with the (load "file") it does
    not.

    This is the file. How do I I load these sexps into sbcl short of dumping
    an image? It's driving me crazy... No loading it in as a file with
    `load' does not work. I must load it by hand at the terminal. I am
    missing something stupid or is the repl in a different thread or
    something?


    (require :sb-posix)
    (load "packages")
    (load-shared-object "./tty_modes.so" )
    (load "local")
    (load "termdata")
    (load "terminfo")
    (terminfo:set-termtype "linux3.0")
    (load "screen")
    (screen:tty-device-open "/dev/tty")
    (in-package :screen)
    (load "display")
    (load "motion")
    ;;(tty-device-termios-set :packet)
    (dprompt)


    I do not know how to use defsystem or asdf; that never seems to work for
    me. I have the c file, so I just use makefiles. I also do not have quick lisp. Does this make a difference?

    What goes wrong when you try this?

    One thing that will happen, however, is that LOAD will see to it that certain things in a loaded file are scoped to that file.
    In particular, *PACKAGE* is bound whie loading the file, so if you try to
    use IN-PACKAGE it will only apply during the file that is being loaded but
    the package will then revert to its value from before calling LOAD.

    It seems to work when I do the following simple test from my command line with sbcl:

    $ cat >/tmp/foo.lisp <<END
    (print "foo file loaded")
    END
    $ cat >/tmp/bar.lisp <<END
    (print "bar file loaded")
    END
    $ cat >/tmp/baz.lisp <<END
    (load "/tmp/foo.lisp")
    (load "/tmp/bar.lisp")
    END
    $ sbcl
    This is SBCL 2.1.1.debian, an implementation of ANSI Common Lisp.
    More information about SBCL is available at <http://www.sbcl.org/>.

    SBCL is free software, provided as is, with absolutely no warranty.
    It is mostly in the public domain; some portions are provided under
    BSD-style licenses. See the CREDITS and COPYING files in the
    distribution for more information.
    * (load "/tmp/baz")

    "foo file loaded"
    "bar file loaded"
    T
    *

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tom Russ@21:1/5 to steve on Thu Jul 29 23:43:49 2021
    On Thursday, July 29, 2021 at 5:03:17 PM UTC-7, steve wrote:
    steve <st...@loft.i-did-not-set--mail-host-address--so-tickle-me>
    writes:
    ARG!

    How does one load a file into sbcl from the command line; when I load everything from emacs/slime it's find but with the (load "file") it does not.

    This is the file. How do I I load these sexps into sbcl short of dumping
    an image? It's driving me crazy... No loading it in as a file with
    `load' does not work. I must load it by hand at the terminal. I am
    missing something stupid or is the repl in a different thread or
    something?


    (require :sb-posix)
    (load "packages")
    (load-shared-object "./tty_modes.so" )
    (load "local")
    (load "termdata")
    (load "terminfo")

    What type of files are these?
    Lisp source code (with extension .lisp?)
    Compiled code? This can make a difference.

    (terminfo:set-termtype "linux3.0")
    (load "screen")
    (screen:tty-device-open "/dev/tty")
    (in-package :screen)
    The `in-package' does not work. I am I in the right thread? Should I try
    and put SBCL into interp mode. It's like it won't stop...

    How does IN-PACKAGE not work?
    It should cause the current package to be :SCREEN (assuming such a package exists. I would guess this should have been created in the file "packages") This will only be true for the remainder of the file that you are loading.

    (load "display")
    (load "motion")
    ;;(tty-device-termios-set :packet)

    (dprompt)
    Even (screen::dpromp)
    Are these function calls inside the file you are loading?
    Or do they come after the loading finishes?
    What is the value of *PACKAGE* before you call these functions?

    It seems, then, that the problem is not with loading the files, necessarily, but something else in how


    Driving me nuts. All this code works and I get stuck here - ahh nothing new.
    I do not know how to use defsystem or asdf; that never seems to work for
    Maybe so? Does defsystem do c files with a c compiler?

    I'm not sure about this. It's been a while since I looked at DEFSYSTEM
    in detail.

    me. I have the c file, so I just use makefiles. I also do not have quick lisp. Does this make a difference?

    These tools can make managing systems, especially large ones easier.
    But they aren't required to load files if you want to manage those dependencies on your own.

    Any info/tutorials on the defsystem would be helpful...
    The DEFSYSTEM code should be commented. In any case there is documentation available.
    You could start here: https://common-lisp.net/project/asdf/asdf/index.html

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From steve@21:1/5 to steve on Mon Aug 2 20:27:20 2021
    On 7/29/21 7:05 PM, steve wrote:

    ARG!

    How does one load a file into sbcl from the command line; when I load everything from emacs/slime it's find but with the (load "file") it does
    not.

    This is the file. How do I I load these sexps into sbcl short of dumping
    an image? It's driving me crazy... No loading it in as a file with
    `load' does not work. I must load it by hand at the terminal. I am
    missing something stupid or is the repl in a different thread or
    something?


    (require :sb-posix)
    (load "packages")
    (load-shared-object "./tty_modes.so" )
    (load "local")
    (load "termdata")
    (load "terminfo")
    (terminfo:set-termtype "linux3.0")
    (load "screen")
    (screen:tty-device-open "/dev/tty")
    (in-package :screen)
    (load "display")
    (load "motion")
    ;;(tty-device-termios-set :packet)
    (dprompt)




    You big dummy - you left out the pty number! It was working - like duh.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From steve@21:1/5 to Tom Russ on Thu Aug 5 23:56:23 2021
    Tom Russ <taruss@google.com> writes:


    What goes wrong when you try this?

    Nothing! ARG! Did I turn off the echo handling or something?

    One thing that will happen, however, is that LOAD will see to it that certain things in a loaded file are scoped to that file.
    In particular, *PACKAGE* is bound whie loading the file, so if you try to
    use IN-PACKAGE it will only apply during the file that is being loaded but

    Yes; the functions are all defined as exports in the file packages.lisp.
    I do not see the sence in compiling this file.

    the package will then revert to its value from before calling LOAD.

    It seems to work when I do the following simple test from my command line with sbcl:

    $ cat >/tmp/foo.lisp <<END
    (print "foo file loaded")
    END
    $ cat >/tmp/bar.lisp <<END
    (print "bar file loaded")
    END
    $ cat >/tmp/baz.lisp <<END
    (load "/tmp/foo.lisp")
    (load "/tmp/bar.lisp")
    END
    $ sbcl
    This is SBCL 2.1.1.debian, an implementation of ANSI Common Lisp.
    More information about SBCL is available at <http://www.sbcl.org/>.

    SBCL is free software, provided as is, with absolutely no warranty.
    It is mostly in the public domain; some portions are provided under
    BSD-style licenses. See the CREDITS and COPYING files in the
    distribution for more information.
    * (load "/tmp/baz")

    "foo file loaded"
    "bar file loaded"
    T
    *

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From steve@21:1/5 to Tom Russ on Thu Aug 5 23:36:08 2021
    Tom Russ <taruss@google.com> writes:


    (require :sb-posix)
    (load "packages")
    (load-shared-object "./tty_modes.so" )
    (load "local")
    (load "termdata")
    (load "terminfo")

    What type of files are these?
    Lisp source code (with extension .lisp?)
    Compiled code? This can make a difference.


    Yes, they are compiled fasl files. I trimmded it a bit today. still have
    to use gpm to cut and paste the following code in. I have tried running
    as a script --load

    I know that I am not supposed to import posix package whole sale; but
    I'm still working on the program. What is the difference between the
    sb-posix: and sb-unix: packages? I am using the sb-posix. It working
    well for me. Better than trying to rewrite C in lisp.

    #!/opt/sbcl/bin/sbcl --script

    (load "packages")
    (load "local")
    (load "termdata")
    (load "terminfo")
    (terminfo:set-termtype "linux3.0")
    (in-package :screen)
    (load "screen")
    (screen:tty-device-open "/dev/tty")
    (load "motion")

    (define-symbol-macro *cm-in* (screen-input (current-screen))) (define-symbol-macro *cm-out* (screen-output (current-screen)))

    (defvar *res*)
    (setq *res* nil)

    (defun prompt-close ()
    (tty-device-termios-set :reset)
    (cm-cursor-normal)
    (tty-device-close))

    (defun display-buffer (str)
    (cm-cursor-home)
    (cm-parm-ich (length str))
    (write-string str *cm-out*))

    (defun display-prompt ()
    (cm-cursor-to-ll)
    (CM-ENTER-STANDOUT-MODE)
    (write-string "Prompt: >" *cm-out*)
    (cm-exit-standout-mode)
    (cm-insert-character)
    (cm-clr-eol))

    (defun display-prompt-loop ()
    (do ((ch (read-char *cm-in* nil 'eof)
    (read-char *cm-in* nil 'eof)))
    ((or (eql ch #\x ) (eql ch 'eof))
    (prompt-close)
    (terpri)
    (pprint (reverse *res*)))
    (push ch *res*)
    (display-buffer (format nil "[~d]" (char-code ch)))
    (display-prompt) ))

    (defun dprompt ()
    (cm-clear-screen)
    (tty-device-termios-set :packet)
    (cm-cursor-invisible)
    (cm-cursor-to-ll)
    (display-prompt-loop))

    (dprompt)


    # EOF


    If I cut and paste it between terminals with gpm it works fine! Is this
    a tpl thing? I just made a dot-sbcl,rc

    ;;; -*- Mode: common-lisp; -*-
    ;;; sbcl.rc
    ;;; Date: 2021-08-05 18:44:36-05:00

    (setq *evaluator-mode* :interpret)
    (setq *read-default-float-format* 'rational)
    (setq *read-default-float-format* 'rational)
    (setq *PRINT-CIRCLE* t)
    (setq *print-escape* nil)
    (setq SB-INT:*PRINT-IR-NODES-PRETTY* t)
    (setq *print-radix* nil)
    (setq *DISASSEMBLE-ANNOTATE* t)
    (setq *print-right-margin* 80)


    I'm thinking that I might need an setq-toplevel or defglobal or _NOP()
    or something? Dunno,..

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From steve@21:1/5 to All on Fri Aug 6 00:44:55 2021
    steve <steve@loft.i-did-not-set--mail-host-address--so-tickle-me>
    writes:

    steve <steve@loft.i-did-not-set--mail-host-address--so-tickle-me>
    writes:

    ARG!

    How does one load a file into sbcl from the command line; when I load
    everything from emacs/slime it's find but with the (load "file") it does
    not.

    This is the file. How do I I load these sexps into sbcl short of dumping
    an image? It's driving me crazy... No loading it in as a file with
    `load' does not work. I must load it by hand at the terminal. I am
    missing something stupid or is the repl in a different thread or
    something?


    (require :sb-posix)
    (load "packages")
    (load-shared-object "./tty_modes.so" )
    (load "local")
    (load "termdata")
    (load "terminfo")
    (terminfo:set-termtype "linux3.0")
    (load "screen")
    (screen:tty-device-open "/dev/tty")
    (in-package :screen)

    The `in-package' does not work. I am I in the right thread? Should I try
    and put SBCL into interp mode. It's like it won't stop...


    I fixed it. It was the shebagn, I removed the #!/opt/sbbcl/bin --script
    and it works fine, thax 4 the emotional support :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)