RE: Unnest your mess with 'and'

2015-08-22 Thread andreas
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



RE: Unnest your mess with 'and'

2015-08-22 Thread andreas
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



Re: Unnest your mess with 'and'

2015-08-22 Thread Erik Gustafson
Hey Beneroth,

Thanks for the kind words, my pleasure to share with you all.

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.


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


Great idea, I might just make that a sister article, so to speak. I want to
keep these as short as possible, something one could work through in 15 min
or so. Alex Williams also has a nice snippet on using (or) this way in the
EXPLAIN.md of his 'picolisp-json' lib.


 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.


Right, I'll make a note of that when I get a chance to update, along with
any other stumbling points one might encounter when using (and) this way.

Thanks for the feedback :)


pilrc?

2015-08-22 Thread Erik Gustafson
I feel like I've seen the answer to this somewhere in the past when I was
just a baby PicoLisper, but can't seem to find it now. Anyway, what's the
canonical way to customize the default 'pil' environment? I'd like to have
some of my own utilities and other goodies loaded when I start up. Can I
just stick the necessary calls to (load) in .pilrc? :)

Thanks!


RE: pilrc?

2015-08-22 Thread andreas
 what's the canonical way to customize the default 'pil' environment?
 I'd like to have some of my own utilities and other goodies loaded when I 
 start up.
 Can I just stick the necessary calls to (load) in .pilrc? :)

I'm not aware of any .pilrc mechanics, search in mailing list also yields 
nothing, though such a mechanic might exist. I don't think this is the case.

Have a look in your picolisp directory, within @bin/ there are the files 
'picolisp' and 'pil. 'picolisp' is the actual binary generated by building 
picolisp.
You usually start the picolisp repl by executing 'pil', watch it in a text 
editor and you can see it is actually a simple script using the #! mechanism to 
start the 'picolisp' binary, followed by loading a few files from @lib/.
Those files are considered standard, globales and functions defined in those 
files is also mentioned in the official reference, opposite to other 
functionality hiding within the @lib/ directory.

So the answer to your question is probably to just craft a customized variant 
of the pil file, e.g. leaving out @lib/db.l if you don't have any use for the 
whole database functionality.
Of course you could also customize it in a way to load a .pilrc in your home 
folder, e.g.

(let Rc (pack (sys HOME) /.pilrc)
   (when (info Rc)
   (load Rc) ) )

thought this might end in an error when .pilrc happens to exist but is a 
directory, so maybe you want to do:

(let Rc (pack (sys HOME) /.pilrc)
   (when (num? (car (info Rc)))
   (load Rc) ) )


Regards,
beneroth



Unnest your mess with 'and'

2015-08-22 Thread Erik Gustafson
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