Re: Future of PicoLisp?
Just a lurker passing by: Personally I'm much less excited about things like pip or node.js packages. While I get their appeal often times you end up with quite a nonses like node.js left-pad issue of year or so ago. In my eyes it promotes a kinda of "shatered into milion pieces" situation. I'm much more keen on how things are in C land - go get stuff yourself :). Which somewhat prevents "dependacny creep". On Fri, Feb 24, 2017 at 09:02:57AM +0100, Jakob Eriksson wrote: > And I would be interested in working on a package or module system similar to > "pip" for Python. > > I must confess that most discussions about namespaces etc on this list is way > over my head... however could I be on the right track if I were to assume > that using "local" in such modules would be a good start, so as to only > export deliberately exposed symbols from a package? > > > > > > 24 feb. 2017 kl. 08:45 skrev Alexander Burger: > > > > Hi Erik, > > > > thanks for the long post! > > > > Just in short: > > > >> 'Learn PicoLisp the Hard Way' > > > > I totally agree. This would be a great project, I'm ready to join. > > Same for Stack Overflow support. > > > > > >> And let's make sure said landing page is served over HTTPS. It's 2017. > > > > Yes, yes, I know ;) In fact, it is on my todo list since half a year. > > > > I want to use Let's Encrypt, as I already do on another server. However, the > > picolisp.com server is currently a mix of Wheezy, Jessie and Stretch, and > > whatever I tried to get the certbot running resulted in a storm of Python > > package mismatch error messages. No way .. I gave up, and decided to wait > > until > > Debian Stretch is stable and thus available from my provider. > > > > ♪♫ Alex > > -- > > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe > > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Copy/Clone a 'job
Thanks for the suggestion Joe. Other than copy-paste examples, I haven't played much with either #oop and #dbase in picolisp. It is definitely on my list ;) I've been trying to get a good understanding of variable scope, state and lifetime. Especially with functions that have the side-effect of manipulating globals, or lists, 'destructively'. Once I have that, I think the symbol management in picolisp's oop and db facets should be easy enough to grasp. My hex digit example was a bit contrived... I was actually working through this https://rosettacode.org/wiki/Pi#PicoLisp, and after reading the referenced source at http://www.cs.ox.ac.uk/jeremy.gibbons/publications/spigot.pdf, tweaked it to return the digits in hexadecimal (see code below). To get off-topic a bit, philosophically I am a proponent of minimalism in coding and algorithms/tools that make it easy to generate, manipulate or filter 'streams. Hence.. picolisp! https://en.wikipedia.org/wiki/Unix_philosophy: "Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface." --- Doug Mcllroy I think what Mcllroy could have said there, instead of text streams, was 'symbol lists' ;) /Lindsay # From https://rosettacode.org/wiki/Pi#PicoLisp # But, return the digits in hexadecimal and provide a way to 'reset' the spigot. (de makeHexaPi () (curry ((Q . 1) (R . 0) (S . 1) (K . 1) (N . 3) (L . 3)) () (while (>= (- (+ R (* 4 Q)) S) (* N S)) (mapc set '(Q R S K N L) (list (* Q K) (* L (+ R (* 2 Q))) (* S L) (inc K) (/ (+ (* Q (+ 2 (* 7 K))) (* R L)) (* S L)) (+ 2 L) ) ) ) (prog1 N (let M (- (/ (* 16 (+ R (* 3 Q))) S) (* 16 N)) (setq Q (* 16 Q) R (* 16 (- R (* N S))) N M) ) ) ) ) : (def 'pi16Digit (makeHexaPi)) -> pi16Digit : (pack (make (do 8 (link (hex (pi16Digit)) -> "3243F6A8" : (pack (make (do 8 (link (hex (pi16Digit)) -> "885A308D" : (off pi16Digit) -> NIL : (def 'pi16Digit (makeHexaPi)) -> pi16Digit : (pack (make (do 16 (link (hex (pi16Digit)) -> "3243F6A8885A308D" On Sun, Feb 26, 2017 at 4:30 AM, Joe Bognerwrote: > Hi Lindsay, > > It looks like you are using job primarily to retain the value of N > between invocations. Is that true? Just curious, why not move the loop > inside of hexSpigot instead of looping outside of it? Another option > to consider if you want the behavior of being able to increment the > hexSpigot at any point - use a pil class > (http://software-lab.de/doc/ref.html#oop) > > > > Thanks, > Joe >
Re: BBWT
On Sun, Feb 26, 2017 at 06:00:28PM +0100, Joh-Tob Schäg wrote: > > Yes, gotta love lisp for the ability to do this (and other things). :) > > > But more often than not this features are not required in practice. Sadly > it is just cool and not significant. :( I would say it is very significant. Factoring the code gives shorter, faster and more readable programs by avoiding duplicated code and redundancies. ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Lifespan of memory of parameters
Thanks for the quick reply, and the great info I get on this list. Maybe more to the point would be a function like so: (de foo (Lst) # some kind of escape condition usually here (foo (modified-copy Lst)) ) Where modified-copy is a function that returns a *new* list. After, say, the tenth time foo is called, are there now ten lists in memory? Rationale: In some cases it feels safer and more natural to implement the algorithm as a recursive algorithm where you are always passing around modified copies of the data. Or do we have to use loops and set a variable each iteration? On 02/25/2017 11:06 PM, Alexander Burger wrote: > On Sun, Feb 26, 2017 at 08:31:37AM +0100, Alexander Burger wrote: >> (let A (bar (copy Lst)) >> (off Lst) >> (doSomethingWithTheCopy) >> ... >> >> With (off Lst) *one* refernce to the list is cleared, but the list will be >> garbage collected only when the *last* reference is gone, which is not under >> control of 'foo'. > > Of course, if you *know* that 'Lst' is not owned by anybody else, i.e. it was > freshly created by reading or list manipulations etc., you don't need to copy > it > at all in the first place. 'copy' is used rather seldom, in cases where you > want > to do destructive operations on list that might be owned by someone else. > > ♪♫ Alex > -- https://qlfiles.net -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: BBWT
> Yes, gotta love lisp for the ability to do this (and other things). :) > But more often than not this features are not required in practice. Sadly it is just cool and not significant. :( 2017-02-26 17:06 GMT+01:00 Rick Hanson: > A bit off-topic, but I like how this transformation > > On 25 Feb 2017, 09:40:43 +0100, Alexander Burger wrote: > >(if (not (cdr W)) > > (Put C (car W)) > > (Put (car (cdr W)) (car W)) ) > > -> > >(Put > > (ifn (cdr W) C (cadr W)) > > (car W) ) > > reminds me of factoring in high school algebra. > >xy + xz > -> >x(y + z) > > Yes, gotta love lisp for the ability to do this (and other things). :) > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >
Re: BBWT
A bit off-topic, but I like how this transformation On 25 Feb 2017, 09:40:43 +0100, Alexander Burger wrote: >(if (not (cdr W)) > (Put C (car W)) > (Put (car (cdr W)) (car W)) ) > -> >(Put > (ifn (cdr W) C (cadr W)) > (car W) ) reminds me of factoring in high school algebra. xy + xz -> x(y + z) Yes, gotta love lisp for the ability to do this (and other things). :) -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Copy/Clone a 'job
Hi Lindsay, It looks like you are using job primarily to retain the value of N between invocations. Is that true? Just curious, why not move the loop inside of hexSpigot instead of looping outside of it? Another option to consider if you want the behavior of being able to increment the hexSpigot at any point - use a pil class (http://software-lab.de/doc/ref.html#oop) Thanks, Joe On Sun, Feb 26, 2017 at 5:03 AM, Lindsay John Lawrencewrote: > Thanks Alex, > > I'll have to play with your solution a bit. I don't quite follow how the > global is working there in conjunction with 'job and 'off. > > However, after banging around on this for a couple of hours, trying 'copy', > various auxillary functions to return the quoted 'job, etc I was at my wits > end...when just a few minutes ago, I remembered where the mail list had > discussed 'job most recently... over 'curry! > > This seems to do what I want as well... > > : (pp 'getHexSpigot) > (de getHexSpigot NIL >(curry > ((N)) > NIL > (default N '(0)) > (prog1 > (hex (% (car N) 16)) > (setq N (cons (+ 1 (car N)) N)) ) ) ) > -> getHexSpigot > > Now I can do this... > > : (def 'hexSpigot1 (getHexSpigot)) > -> hexSpigot1 > : (def 'hexSpigot2 (getHexSpigot)) > -> hexSpigot2 > > : (do 8 (prin (hexSpigot1))) > 01234567-> "7" > : (do 16 (prin (hexSpigot2))) > 0123456789ABCDEF-> "F" > > : hexSpigot1 > -> (NIL (job '((N 8 7 6 5 4 3 2 1 0)) (default N '(0)) (prog1 (hex (% (car > N) 16)) (setq N (cons (+ 1 (car N)) N) > : hexSpigot2 > -> (NIL (job '((N 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0)) (default N > '(0)) (prog1 (hex (% (car N) 16)) (setq N (cons (+ 1 (car N)) N) > > : (off hexSpigot1) > : (off hexSpigot2) > > > /Lindsay > > > > > On Sun, Feb 26, 2017 at 1:19 AM, Alexander Burger > wrote: >> >> Hi Lindsay, >> >> > (de hexSpigot NIL >> >(job '((N)) >> > ... >> > : (do 32 (prin (hexSpigot))) >> > ... >> > 0123456789ABCDEF0123456789ABCDEF-> "F" >> > ... >> > : (pp 'hexSpigot) >> > (de hexSpigot NIL >> >(job >> > '((N 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 >> > 12 >> > 11 10 9 8 7 6 5 4 3 2 1 0 ) ) >> > ... >> > The job vars are being modified and the list N is growing.. using ever >> > greater amounts of memory. If I want to reset the spigot, or even clone >> > it >> > to have more than one, how would I do that? >> >> The simplest is to use a global: >> >>(setq *HexSpigot '((N))) >> >>(de hexSpigot NIL >> (job *HexSpigot >> ... >> >> and later just do the 'setq' again. >> >> >> BTW, for an expression like >> >>(ifn N (setq N (0))) >> >> there is 'default' >> >>(default N (0)) >> >> So the above could be made a bit easier: >> >>(off *HexSpigot) >> >>(de hexSpigot NIL >> (job (default *HexSpigot '((N . (0 >> (prog1 >> (hex (% (car N) 16)) >> (setq N (cons (+ 1 (car N)) N)) ) ) ) >> >>(do 32 (prin (hexSpigot))) >>(off *HexSpigot) >>(do 32 (prin (hexSpigot))) >> >> i.e. just call 'off' to reset it :) >> >> ♪♫ Alex >> -- >> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe > > -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Copy/Clone a 'job
Hi Lindsay, > I'll have to play with your solution a bit. I don't quite follow how the > global is working there in conjunction with 'job and 'off. There is nothing mysterious about it. 'job' evaluates its first argument. So there is absolutely no difference whether you quote that argument (job '((N)) ... or pass it in a variable (setq Var '((N))) (job Var ... ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Copy/Clone a 'job
Thanks Alex, I'll have to play with your solution a bit. I don't quite follow how the global is working there in conjunction with 'job and 'off. However, after banging around on this for a couple of hours, trying 'copy', various auxillary functions to return the quoted 'job, etc I was at my wits end...when just a few minutes ago, I remembered where the mail list had discussed 'job most recently... over 'curry! This seems to do what I want as well... : (pp 'getHexSpigot) (de getHexSpigot NIL (curry ((N)) NIL (default N '(0)) (prog1 (hex (% (car N) 16)) (setq N (cons (+ 1 (car N)) N)) ) ) ) -> getHexSpigot Now I can do this... : (def 'hexSpigot1 (getHexSpigot)) -> hexSpigot1 : (def 'hexSpigot2 (getHexSpigot)) -> hexSpigot2 : (do 8 (prin (hexSpigot1))) 01234567-> "7" : (do 16 (prin (hexSpigot2))) 0123456789ABCDEF-> "F" : hexSpigot1 -> (NIL (job '((N 8 7 6 5 4 3 2 1 0)) (default N '(0)) (prog1 (hex (% (car N) 16)) (setq N (cons (+ 1 (car N)) N) : hexSpigot2 -> (NIL (job '((N 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0)) (default N '(0)) (prog1 (hex (% (car N) 16)) (setq N (cons (+ 1 (car N)) N) : (off hexSpigot1) : (off hexSpigot2) /Lindsay On Sun, Feb 26, 2017 at 1:19 AM, Alexander Burgerwrote: > Hi Lindsay, > > > (de hexSpigot NIL > >(job '((N)) > > ... > > : (do 32 (prin (hexSpigot))) > > ... > > 0123456789ABCDEF0123456789ABCDEF-> "F" > > ... > > : (pp 'hexSpigot) > > (de hexSpigot NIL > >(job > > '((N 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 > > 11 10 9 8 7 6 5 4 3 2 1 0 ) ) > > ... > > The job vars are being modified and the list N is growing.. using ever > > greater amounts of memory. If I want to reset the spigot, or even clone > it > > to have more than one, how would I do that? > > The simplest is to use a global: > >(setq *HexSpigot '((N))) > >(de hexSpigot NIL > (job *HexSpigot > ... > > and later just do the 'setq' again. > > > BTW, for an expression like > >(ifn N (setq N (0))) > > there is 'default' > >(default N (0)) > > So the above could be made a bit easier: > >(off *HexSpigot) > >(de hexSpigot NIL > (job (default *HexSpigot '((N . (0 > (prog1 > (hex (% (car N) 16)) > (setq N (cons (+ 1 (car N)) N)) ) ) ) > >(do 32 (prin (hexSpigot))) >(off *HexSpigot) >(do 32 (prin (hexSpigot))) > > i.e. just call 'off' to reset it :) > > ♪♫ Alex > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >
Re: Copy/Clone a 'job
Hi Lindsay, > (de hexSpigot NIL >(job '((N)) > ... > : (do 32 (prin (hexSpigot))) > ... > 0123456789ABCDEF0123456789ABCDEF-> "F" > ... > : (pp 'hexSpigot) > (de hexSpigot NIL >(job > '((N 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 > 11 10 9 8 7 6 5 4 3 2 1 0 ) ) > ... > The job vars are being modified and the list N is growing.. using ever > greater amounts of memory. If I want to reset the spigot, or even clone it > to have more than one, how would I do that? The simplest is to use a global: (setq *HexSpigot '((N))) (de hexSpigot NIL (job *HexSpigot ... and later just do the 'setq' again. BTW, for an expression like (ifn N (setq N (0))) there is 'default' (default N (0)) So the above could be made a bit easier: (off *HexSpigot) (de hexSpigot NIL (job (default *HexSpigot '((N . (0 (prog1 (hex (% (car N) 16)) (setq N (cons (+ 1 (car N)) N)) ) ) ) (do 32 (prin (hexSpigot))) (off *HexSpigot) (do 32 (prin (hexSpigot))) i.e. just call 'off' to reset it :) ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Copy/Clone a 'job
Hi, How would I copy|clone, reinitialize or dispose of a 'job' function? For example, given (de hexSpigot NIL (job '((N)) (ifn N (setq N '(0))) (prog1 (hex (% (car N) 16)) (setq N (cons (+ 1 (car N)) N)) ) ) ) I can then do.. : (do 32 (prin (hexSpigot))) 0123456789ABCDEF0123456789ABCDEF-> "F" Now, hexSpigot something like this... : (pp 'hexSpigot) (de hexSpigot NIL (job '((N 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ) ) (ifn N (setq N '(0))) (prog1 (hex (% (car N) 16)) (setq N (cons (+ 1 (car N)) N)) ) ) ) The job vars are being modified and the list N is growing.. using ever greater amounts of memory. If I want to reset the spigot, or even clone it to have more than one, how would I do that? /Lindsay
Re: Lifespan of memory of parameters
On Sun, Feb 26, 2017 at 08:31:37AM +0100, Alexander Burger wrote: > (let A (bar (copy Lst)) > (off Lst) > (doSomethingWithTheCopy) > ... > > With (off Lst) *one* refernce to the list is cleared, but the list will be > garbage collected only when the *last* reference is gone, which is not under > control of 'foo'. Of course, if you *know* that 'Lst' is not owned by anybody else, i.e. it was freshly created by reading or list manipulations etc., you don't need to copy it at all in the first place. 'copy' is used rather seldom, in cases where you want to do destructive operations on list that might be owned by someone else. ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe