Page 1 of 1
Values and void
Posted: Sat Jul 11, 2009 4:03 am
by hsmyers
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
Posted: Sat Jul 11, 2009 6:14 pm
by Lutz
Something is always returned, but there is 'silent' function to suppress the return value being sent to the console.
Posted: Sun Jul 12, 2009 8:21 am
by hsmyers
Of course. So could we have one--- pretty please?
--hsm
Posted: Sun Jul 12, 2009 11:55 am
by Lutz
Posted: Sun Jul 12, 2009 8:11 pm
by hsmyers
Ah! Bad me for not RTFM-ing!! 'silent' will do quite nicely. Thanks!
--hsm
Posted: Sun Jul 12, 2009 9:04 pm
by ale870
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).
Posted: Tue Jul 14, 2009 2:59 am
by m i c h a e l
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
Posted: Tue Jul 14, 2009 6:12 am
by ale870
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!!
Posted: Tue Jul 14, 2009 2:51 pm
by m i c h a e l
You're welcome. Glad I could be of help.
m i c h a e l