Re: (= code data)

2017-03-06 Thread Danilo Kordic
# Sorry for a long delay.  I found this message in my Spam folder.  Your
# previous message in this thread was also classified as spam.

# I made an error with the order of parameters for `help:'.

# Main motivation is clarity.  I have to think about it alot more.

# At the moment speed is not a problem at all.

# I don't see the point of `hde' at all.  It is just complicated.  I would
# rather use `def' directly.

[de help: [Txt Sym]
  [if *Dbg
[def Sym 'help: Txt]
Sym ] ]

[help:
  '[txt
 [p "At the moment it is hardly better than using "'def" directly.  "] ]
  'help: ]

[help: 'RTFC
  [de help [Sym]
[get Sym 'help:] ] ]

[de rem: [Txt . "Prg"]
  [run "Prg"] ]
[de FixMe: . rem:]
[de TBD . !]

[FixMe: "Useful definitions.  "
  [help: '[txt "In the worst case "'let" it be "'pack" or "'prin".  "]
[de txt . Data] ]

  [de p . txt] ]

[de Data []
  [up] ]
[de fun . Data]
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (= code data)

2017-02-17 Thread Rowan Thorpe
On 6 February 2017 at 20:03, Danilo Kordic  wrote:
> ..[snip]..
>
> Hi Rowan.
>
> [de help: [Sym Txt]
>   [def Sym 'help: Txt] ]
>
> [help: "`prop'erty is clearly better than a txt in `prg' if it should
> be extracted by a procedure.  "
>   [de help [Sym]
> "I prefer even this over Reader Comments (``#'').  "
> [get Sym 'help:] ] ]

Thanks for that, Danilo. I was a bit confused for a while though
because (I think?) there is a typo in it - it doesn't work for me
as-is. Anyway, your pointing out the use of a property on the function
made sense. I managed to get a version of it working which I like (see
below), particularly because it makes passing in "lambdas" trivial as
a single arg, and is easy to visually parse with that in mind). I
guess the main benefit of using the property-approach is that it won't
have any speed impact on the function when it runs, whereas including
a "docstring" like I was doing will cause the string to be silently
"evaluated" every time the function is run... Just out of curiosity,
is that the main/only reason? or are there other reasons I haven't
thought of? BTW: The version I came up with is:

8<

(de hde (Sym Txt Fn)
   (def Sym Fn)
   (def Sym 'help: Txt) )
-> hde

(hde 'help "This is the help function"
   '((X) (get X 'help:)) )
-> help

(hde 'tester "This is the tester function"
   '((X) (println X)) )
-> tester

(help 'tester)
-> "This is the tester function"

(tester 123)
123
-> 123

8<

-- 
Rowan Thorpe

"A riot is the language of the unheard." - Dr. Martin Luther King
"There is a great difference between worry and concern. A
worried person sees a problem, and a concerned person solves a
problem." - Harold Stephens
"Ignorance requires no apologies when it presents questions
rather than assertions." - Michael Sierchio (OpenSSL mailing list)
"What we need more than an end to wars is an end to the
beginning of all wars." - Franklin Roosevelt
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (= code data)

2017-02-06 Thread Lindsay John Lawrence
Very interesting! It will take me a while to digest all of that though =)
/Lindsay

Side note: I had to look up the square bracket use. I did not realize you
could do that in picolisp. The semantics are different but it reminded me
of the code in the "Lisp 1.5 Programmer's Manual" (
http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf).
I've only worked through the first 3 sections of that in detail, but it
really helped me to get a handle on some key lisp concepts. At least to me,
the functions the author defines there for manipulating sets are
brilliantly succinct.

On Mon, Feb 6, 2017 at 10:03 AM, Danilo Kordic 
wrote:

> Hi Lindsay.
>
> What do You think about:
>   : [load "frac.l"]  #
> https://gist.github.com/DKordic/6016d743c4c124a1c04fc12accf7ef17 Not
> usable yet :) .
>   : (/ 10 -15)
>   -> (/ -2 3)
>
> Maybe `recur' should also be mentioned in ``Jump anywhere'' task.
>
>
> Hi Rowan.
>
> [de help: [Sym Txt]
>   [def Sym 'help: Txt] ]
>
> [help: "`prop'erty is clearly better than a txt in `prg' if it should
> be extracted by a procedure.  "
>   [de help [Sym]
> "I prefer even this over Reader Comments (``#'').  "
> [get Sym 'help:] ] ]
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: (= code data)

2017-02-06 Thread Danilo Kordic
Hi Lindsay.

What do You think about:
  : [load "frac.l"]  #
https://gist.github.com/DKordic/6016d743c4c124a1c04fc12accf7ef17 Not
usable yet :) .
  : (/ 10 -15)
  -> (/ -2 3)

Maybe `recur' should also be mentioned in ``Jump anywhere'' task.


Hi Rowan.

[de help: [Sym Txt]
  [def Sym 'help: Txt] ]

[help: "`prop'erty is clearly better than a txt in `prg' if it should
be extracted by a procedure.  "
  [de help [Sym]
"I prefer even this over Reader Comments (``#'').  "
[get Sym 'help:] ] ]
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (= code data)

2016-12-27 Thread Rowan Thorpe
On 27 December 2016 at 20:03, Lindsay John Lawrence
 wrote:
> This little gem was an epiphany in my understanding of the equivalence
> of code and data in lisp.
>
> https://rosettacode.org/wiki/Jump_anywhere#PicoLisp

:-) Another nice/simple way to demo Picolisp's homoiconicity is by
implementing "docstrings"
within a small function :-) See here for an example:

 
https://github.com/rowanthorpe/taskwrangle/blob/b14e2fe47a9e03f025442941b2867eb122cefa8b/lib/libtaskwrangle.l#L252

-- 
Rowan Thorpe
PGP fingerprint:
 BB0A 0787 C0EE BDD8 7F97  3D30 49F2 13A5 265D CCBD
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (= code data)

2016-12-27 Thread Joh-Tob Schäg
Classic
Am 27.12.2016 19:08 schrieb "Lindsay John Lawrence" <
lawrence.lindsayj...@gmail.com>:

> I've been working my way through the Rosetta code examples as a way to
> build fluency in picolisp. This little gem was an epiphany in my
> understanding of the equivalence of code and data in lisp.
>
> https://rosettacode.org/wiki/Jump_anywhere#PicoLisp
>
> (de foo (N)
>(prinl "This is 'foo'")
>(printsp N)
>(or (=0 (dec 'N)) (run (cddr foo))) )
>
>
> /Lindsay
> p.s. studying the rosetta code examples has been time well spent.
>
>