Of course you can also use (or) to achieve the opposite - stop when a call or 
evaluation returns something (not NIL).
This way you have actually a very cheap implementation of the Design Pattern 
(GoF) 'chain of responsibility', when one function successfully handles the 
required case, stop there, else try the next function.
Here too you can see the baffling elegance of PicoLisp: Regenaxer surely had 
this usage of  (or) in mind as (or) returns the result of the last expression, 
and not merely T which would limit its usability a lot.

Maybe you should mention the appliance of this technique with (or) at the end 
of article.


----- Original Message -----
From: andr...@itship.ch [mailto:andr...@itship.ch]
To: picolisp@software-lab.de
Sent: Sat, 22 Aug 2015 21:11:45 +0200
Subject:

Hi Erik

Thanks for writing this awesome article, your humour made it a very joyful read!

I actually found that technique myself too, and used it in certain cases, its 
just perfect when you have multiple sequential things to do but you want to 
cancel execution when one of it fails.
When using this technique, one is actually not interested in the return value 
of (and), just in the fact that it evaluates its arguments one after another 
and stops when it gets NIL the first time.

I think this is fully in the spirit of PicoLisp and you will get an extra skill 
point in "Software Surgery" for using it.
I actually didn't realise this was something to tell the mailing list, but it 
absolutely is, thank you for caring and for your time, Erik!
Extra points for the telling wording and illustration.

Cheers and claps,
beneroth


----- Original Message -----
From: Erik Gustafson [mailto:erik.d.gustaf...@gmail.com]
To: picolisp@software-lab.de
Sent: Sat, 22 Aug 2015 13:29:00 -0500
Subject:

Hi list,

I was thinking about some of the things brought up in the last thread, 'The
`if-let` construct', notably Mike's comment about certain idioms being
useless within the PicoLisp feature set. Now I like Clojure's '->' just as
much as the next Clojure enthusiast, but I agree we don't need it in
PicoLisp.

I wrote a little tutorial explaining how we can use 'and' to accomplish the
same thing as '->' and friends. It can be found here,

https://github.com/erdg/learning-picolisp/blob/master/unnest-your-mess-with-and.md

What do you all think of this technique? Any feedback would be great.

I plan to add a bunch more mini-tutorials to this repo in the coming months
to help those new to the language start to feel more at home.

Cheers,
Erik

Reply via email to