Returning "nothing at all" or a

Started by starseed, August 03, 2006, 02:19:24 PM

Previous topic - Next topic

starseed

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 ...

cormullion

#1
I've always used println... !

HPW

#2
What about:



(silent(test 5) )
Hans-Peter

starseed

#3
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

Lutz

#4
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