Pondering the philosophy behind the language
hsmyers
Posts: 104 Joined: Wed Feb 20, 2008 4:06 pm
Location: Boise, ID, USA
Contact:
Post
by hsmyers » Sat Jul 11, 2009 4:03 am
In CL and scheme empty version of values and void are used to indicate nothing is returned.
Code: Select all
(define (f)
(print 5)
(newline)
(void))
or
Code: Select all
(defun f ()
(format #t "~d~%" 5)
(values))
Is there a newLISP equivalent? If not could there be?
--hsm
"Censeo Toto nos in Kansa esse decisse."—D. Gale "ℑ♥λ "—Toto
Lutz
Posts: 5289 Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:
Post
by Lutz » Sat Jul 11, 2009 6:14 pm
Something is always returned, but there is 'silent' function to suppress the return value being sent to the console.
hsmyers
Posts: 104 Joined: Wed Feb 20, 2008 4:06 pm
Location: Boise, ID, USA
Contact:
Post
by hsmyers » Sun Jul 12, 2009 8:21 am
Of course. So could we have one--- pretty please?
--hsm
"Censeo Toto nos in Kansa esse decisse."—D. Gale "ℑ♥λ "—Toto
Lutz
Posts: 5289 Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:
Post
by Lutz » Sun Jul 12, 2009 11:55 am
hsmyers
Posts: 104 Joined: Wed Feb 20, 2008 4:06 pm
Location: Boise, ID, USA
Contact:
Post
by hsmyers » Sun Jul 12, 2009 8:11 pm
Ah! Bad me for not RTFM-ing!! 'silent' will do quite nicely. Thanks!
--hsm
"Censeo Toto nos in Kansa esse decisse."—D. Gale "ℑ♥λ "—Toto
ale870
Posts: 297 Joined: Mon Nov 26, 2007 8:01 pm
Location: Italy
Post
by ale870 » Sun Jul 12, 2009 9:04 pm
But don't forget that (silent) has a strange side-effect: it will ask to press enter key to "finalize" the output, if used in the console (I didn't check the most recent version, but older newLisp versions do that).
Try this:
After the output test "ok" there is an empty line: it is similar a (read-line).
--
m i c h a e l
Posts: 394 Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:
Post
by m i c h a e l » Tue Jul 14, 2009 2:59 am
I usually always end my
silent expressions this way:
Code: Select all
> (silent (println "ok?") (print "> ")) ; notice the space after '>'
ok?
> _
silent is merely suppressing the prompt newlisp usually prints. Hitting enter on an empty line prints the prompt again (what you are experiencing).
(print "> ") at the end of a
silent expression restores the normal prompt.
Or if you get tired of doing that every time, you could put this in your init.lsp file:
Code: Select all
(set (global 'quiet) (fn ()
(eval (cons silent (args)))
(print "> ")
))
And use it like this:
This still won't fool
readline , but it does the job.
m i c h a e l
ale870
Posts: 297 Joined: Mon Nov 26, 2007 8:01 pm
Location: Italy
Post
by ale870 » Tue Jul 14, 2009 6:12 am
wow, this is a news for me, since I didn't notice that, even if prompt is suppressed, it is ready to accept new commands! Thank you for this trick!!
--
m i c h a e l
Posts: 394 Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:
Post
by m i c h a e l » Tue Jul 14, 2009 2:51 pm
You're welcome. Glad I could be of help.
m i c h a e l