Skip to content

Commit abd5de4

Browse files
committed
Refactor some examples
1 parent 57aab72 commit abd5de4

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

examples/args.lisp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
;; Alternatively, load a local cl-portable.lisp script.
44
#-quicklisp (load "cl-portable.lisp" :print nil)
55

6-
(use-package 'cl-portable)
6+
(import 'cl-portable::argument-script)
7+
(import 'cl-portable::argument-vector)
8+
(import 'cl-portable::quit-with-status)
79

8-
;; Simulate main function.
10+
;; Simulate a main function.
911
(defun main ()
1012
;; Print out unprocessed arguments.
1113
(write-line "Unprocessed argument vector:")
@@ -17,8 +19,8 @@
1719
(write-line "Processed argument(s) in scripting mode:")
1820
(write-line (princ-to-string (argument-script)))
1921

20-
#+ccl (finish-output) ;; Trick for Clozure CL.
22+
#+ccl (finish-output) ; Trick for Clozure CL.
2123
(quit-with-status))
2224

23-
;; Assume args.lisp runs in scripting mode.
25+
;; Call the main function.
2426
(main)

examples/compile-program.lisp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
;; Alternatively, load a local cl-portable.lisp script.
44
#-quicklisp (load "cl-portable.lisp" :print nil)
55

6-
(use-package 'cl-portable)
6+
(import 'cl-portable::compile-program)
7+
(import 'cl-portable::platform)
8+
(import 'cl-portable::quit-with-status)
79

810
;; Simulate a main function.
911
(defun main ()
1012
(write-line "Hello World")
11-
;; Trick for Clozure CL.
12-
#+ccl (finish-output)
13+
#+ccl (finish-output) ; Trick for Clozure CL.
1314
(quit-with-status 0))
1415

15-
;; Set a proper executable name
16-
;; according to current OS.
16+
;; Set a proper executable name according to current OS.
1717
(if (equal :windows (platform))
1818
(defvar *program* "program.exe")
1919
(defvar *program* "program"))
2020

21+
;; Compile the script into an executable.
2122
(compile-program *program* #'main)
23+
;; Quit the script.
2224
(quit-with-status)

examples/env.lisp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
;; Alternatively, load a local cl-portable.lisp script.
44
#-quicklisp (load "cl-portable.lisp" :print nil)
55

6-
(use-package 'cl-portable)
6+
(import 'cl-portable::env)
7+
(import 'cl-portable::platform)
8+
(import 'cl-portable::quit-with-status)
79

810
;; Simulate a main function.
911
(defun main ()
10-
(if (equal (platform) :windows)
12+
(if (equal :windows (platform))
13+
;; HOME equivalent on Windows
1114
(write-line (env "USERPROFILE"))
1215
(write-line (env "HOME")))
13-
#+ccl (finish-output)
16+
#+ccl (finish-output) ; Trick for Clozure CL.
1417
(quit-with-status 0))
1518

1619
;; Load the main function.

examples/helloworld-cjk.lisp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
;; Alternatively, load a local cl-portable.lisp script.
44
#-quicklisp (load "cl-portable.lisp" :print nil)
55

6-
(use-package 'cl-portable)
6+
(import 'cl-portable::quit-with-status)
77

88
;; Simulate a main function.
99
(defun main ()
1010
(write-line "你好,世界")
1111
(write-line "こんにちは世界")
1212
(write-line "안녕 세상")
13-
;; Trick for Clozure CL.
14-
#+ccl (finish-output)
13+
#+ccl (finish-output) ; Trick for Clozure CL.
1514
(quit-with-status 0))
1615

1716
;; Load the main function.

examples/pwd.lisp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
;; Alternatively, load a local cl-portable.lisp script.
44
#-quicklisp (load "cl-portable.lisp" :print nil)
55

6-
(use-package 'cl-portable)
6+
(import 'cl-portable::pwd)
7+
(import 'cl-portable::quit-with-status)
78

89
;; Simulate a main function.
910
(defun main ()
1011
(write-line (princ-to-string (pwd)))
11-
#+ccl (finish-output)
12+
#+ccl (finish-output) ; Trick for Clozure CL.
1213
(quit-with-status 0))
1314

1415
;; Load the main function.

0 commit comments

Comments
 (0)