(load filename) vs sbcl filename?

Discussion of Common Lisp
Post Reply
anta40
Posts: 19
Joined: Fri Oct 10, 2008 10:27 pm
Contact:

(load filename) vs sbcl filename?

Post by anta40 » Fri Jan 30, 2009 11:03 pm

Here's a simple code I wrote while learning loop, foo.lisp:

Code: Select all

(defun foo-bar (m)
	(setq aa 1)
	(loop until (> aa m) do
	(write-line "foobar...")
	(setq aa (+ aa 1))
	)
)
First thing I do is run SBCL, then (load "foo.lisp")

Code: Select all

* (foo-bar 4)
foobar...
foobar...
foobar...
foobar...
NIL
Works OK. But when I do : sbcl foo.lisp, then (foo-bar 4):

Code: Select all

* (foo-bar 4)

; in: LAMBDA NIL
;     (FOO-BAR 4)
;
; caught STYLE-WARNING:
;   undefined function: FOO-BAR

;
; caught STYLE-WARNING:
;   This function is undefined:
;     FOO-BAR
;
; compilation unit finished
;   caught 2 STYLE-WARNING conditions

debugger invoked on a UNDEFINED-FUNCTION: The function FOO-BAR is undefined.

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

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

("bogus stack frame")
0]
What's the difference anyway, between loading file using (load ...) and calling them directly as SBCL's argument.
I thought both do the same thing? :?

nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: (load filename) vs sbcl filename?

Post by nuntius » Sat Jan 31, 2009 1:22 am

You are calling SBCL with the wrong command line. Try "sbcl --load file" or "sbcl --script file" (newer sbcl only).

See the manual for more details.
http://www.sbcl.org/manual/Command-Line-Options.html

Post Reply