Returning "nothing at all" or a

For the Compleat Fan
Locked
starseed
Posts: 38
Joined: Thu Jul 27, 2006 8:45 pm

Returning "nothing at all" or a

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

Code: Select all

> (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:

Code: Select all

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

Code: Select all

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

Code: Select all

> (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 ...
Last edited by starseed on Fri Aug 04, 2006 9:03 am, edited 1 time in total.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

I've always used println... !

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

What about:

(silent(test 5) )
Hans-Peter

starseed
Posts: 38
Joined: Thu Jul 27, 2006 8:45 pm

Post by starseed »

Hi Peter,

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

Code: Select all

(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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Of 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

Locked