newLISP Fan Club

Forum => Anything else we might add? => Topic started by: starseed on August 03, 2006, 02:19:24 PM

Title: Returning "nothing at all" or a
Post by: starseed on August 03, 2006, 02:19:24 PM
I like to play at the console.



One thing I noticed at the newLisp console, is that prints and returns frequently run into each other, e.g.


> (define (test a) (print a))
(lambda (a) (print a))
> (test 5)
55


Why the hell is it printing 55??? Well, I found out quite fast, but with a little more complicated values, it may pose a problem.



Right now, I do return a nonintrusive symbol at the end of functions, which are solely meant to be used at the console:


> (define (test a) (print a) '-)
(lambda (a) (print a) '-)
> (test 5)
5-


What I would like to have, would be either

- an automatic return value marker, like
> (define (test a) (print a))
(lambda (a) (print a))
> (test 5)
5
== 5

- or a way to return something, that isn't printed at all, e.g.
> (define (test a) (print a) '-)
(lambda (a) (print a) no-print)
> (test 5)
5


Well, I can live without it ...





Ingo



P.S.: Edited, to get the bbcode markup ...
Title:
Post by: cormullion on August 03, 2006, 02:42:00 PM
I've always used println... !
Title:
Post by: HPW on August 03, 2006, 10:28:30 PM
What about:



(silent(test 5) )
Title:
Post by: starseed on August 04, 2006, 02:49:36 AM
Hi Peter,



hmm, silent should work ... it looks a little funny, maybe I need a better name ...


(def (.) "Just to end interactive funcs, put it at the last place in your func"
   (silent (print "n> ")))

(def (src "Prints the source of a lambda expression"
      of-func "function, to get source of")
   (println (source of-func))
   (.))


So you get the next prompt, but no return value. Of course, this makes the func only usable at the console.





Ingo
Title:
Post by: Lutz on August 04, 2006, 07:13:02 AM
QuoteOf course, this makes the func only usable at the console.


'silent' only silences the output, the return value would still be available to another function receiving it. 'silent' is mainly used when controlling newLISP from other programs tu suppress return value being sent back to the caller.



Lutz