beneroth changed the topic of #picolisp to: PicoLisp language | The scalpel of software development | Channel Log: https://libera.irclog.whitequark.org/picolisp | Check www.picolisp.com for more information
<razzy> hmm, why is (history) so convoluted and precompiled?
<aw-> ?
<Regenaxer> razzy: (in '("sh" "-c" "cat .pilrc |fzf") (while (read) (eval @]
<Regenaxer> Hi aw-!
<razzy> aw-: (history) just gives list of previously used lines in repl. I would expect simple list.
<razzy> Good morning everyone!
<Regenaxer> Yes, (history) is a list of strings, one per line
<razzy> no, history is convoluted function that gives list of strings.
<Regenaxer> : (history) ?
<razzy> yep
<Regenaxer> Yes, returns a list of strings. But what is convoluted?
<razzy> I do not get insides of (history). I also do not understand how doc/rc.sample recognise initial history and initial commands
<razzy> *i do not understand insides of (history)
<Regenaxer> the rc.sample can be put into ~/.pil/rc
<Regenaxer> It reads history from the text following, and then looks in the current directory for .pilrc to read that too
<Regenaxer> In this way you get a global and a local history
<razzy> is $./pil rc best way of executing?
<Regenaxer> I don't know. It is a proposal, a sample
<Regenaxer> It is exactly what I have here
<razzy> ok
<razzy> so #Initial history is all executed, yes?
<Regenaxer> I see! What you mean is *not* that 'history' is concoluted, but the *call* to 'history' in the sample?
<Regenaxer> Yes, #Initial history is read as immediate data
<razzy> both work together.
<Regenaxer> no, 'history' is simple
<Regenaxer> just takes a list
<Regenaxer> only a single list argument
<razzy> * so all #Initial history is normally evaluated, yes?
<Regenaxer> N
<Regenaxer> No
<Regenaxer> Not evaluated at all
<Regenaxer> Just *strings*
<Regenaxer> lines
<razzy> right efter that are initial commands
<Regenaxer> Yes, after that it is evaluated
<razzy> that are normally evaluated yes?
<Regenaxer> Try to understand what the 'history' call does
<Regenaxer> (make ...)
<razzy> how do pil recognise that initial history are strings and initial commands need to be evaluated
<Regenaxer> That's the question :)
<razzy> yes. i am asking. I am confused
<Regenaxer> (make ... (line T) ... (eval ...) ...
<Regenaxer> It is even commented
<razzy> i do not know (line) well. so it is using end of line to recognise initial history? seriously?
<Regenaxer> (line) reads a single line, that's all
<Regenaxer> We need lines for the history
<razzy> sure
<razzy> but how do system "know" difference, when system cannot see #comments
<razzy> between initial history and initial comments
<Regenaxer> (while (line T) (link @)) # Global history
<Regenaxer> Note: 'line' returns NIL for an empty line
* razzy is thinking hard
<Regenaxer> good
<razzy> so, empty line is needed between initial history and initial commands to recognise
<Regenaxer> Exactly
<razzy> do i need empty line between initial commands?
<Regenaxer> Check the code please!
<Regenaxer> You are close
razzy has quit [Read error: Connection reset by peer]
razzy has joined #picolisp
* razzy is back to thinking
<Regenaxer> :)
<razzy> i save this problem for later.
<Regenaxer> It is no problem
<razzy> ;)
<Regenaxer> double meaning ;)
<razzy> hmm weird. (in '("sh" "-c" "cat .pilrc | grep doc") (while (read) (print @] is not recorded in history
<razzy> also (in '("sh" "-c" "cat .pilrc | fzf") (while (read) (print @] does not work. because fzf need interaction back and fort with user.
<Regenaxer> History is what you type in readline()
<Regenaxer> Sigh
<Regenaxer> You wanted a pipe!!
<razzy> am I a trouble?
<razzy> I was not sure about a pipe.
<Regenaxer> No trouble ;)
<Regenaxer> ok, what exactly do you want to do?
<Regenaxer> You should understand what a pipe is in Unix, and what a terminal
<razzy> Regenaxer: first thing first. some commands are not recorded in REPL interactive history. is it ok?
<Regenaxer> man readline
hunar has joined #picolisp
<Regenaxer> history is a readline feature
<razzy> soo, either bug or feature of readline, yes? nothing to do with pil
<Regenaxer> Why should it be a bug?
<Regenaxer> readline() reads from the terminal, right?
<razzy> i would expect history to record evrything i write
<Regenaxer> You read from a pipe
<Regenaxer> yes
<razzy> command (+ 1 2) is saved in interactive history and in .pilrc. command (in '("sh" "-c" "cat .pilrc | grep doc") (while (read) (print @] is not saved in interactive history not in .pilrc. I can live with that. I want to know if it is not deeper bug.
<Regenaxer> No bug at all
<Regenaxer> How should readline know what you read from a pipe?
<razzy> lets leave with that. next issue.
<razzy> Regenaxer: fastest way for you to know what i want is "$apt install fzf" than "$cat .pilrc | fzf" and than start typing some function from history than hit enter.
<Regenaxer> No
<Regenaxer> As I understand, fzf reads from terminal. So it is fzf that has a history
<razzy> fzf has no internal history. fzf read standart input, make interaction with user to select one line from standart input, returns this one line.
<razzy> to standart output
<Regenaxer> Please try to understand what that is
<Regenaxer> Processes, stdio, terminals in Unix
<razzy> I will have to study it.
<Regenaxer> A terminal is a very special beast. A tty
<Regenaxer> It is a device with special attributes
<Regenaxer> readline interacts with the terminal
<Regenaxer> stdin and stdout are just files
<razzy> i am working on suboptimal batch/not-interactive version now. maybe could be usefull
<razzy> using pipe as was shown
<razzy> My naive idea was, that linux terminal just print ~60-ish lines with ~60 characters every 50ms and i can read that. and process in picolisp
<Nistur> mornin'
<Regenaxer> Hi Nistur!
<Nistur> o7
razzy has quit [Ping timeout: 252 seconds]
<hunar> Hello everyone :) I forgot what function gives me a portion of a list
<Regenaxer> (head) and (tail)
<Regenaxer> more useful is (member) or (memq)
<Regenaxer> head and tail need a number which is normally not known
<hunar> Is there a function like head but with a custom starting index
<Regenaxer> custom?
<hunar> I want (3 4 5) from (range 1 10)
<hunar> (sublist 3 5) something like this
<Regenaxer> (head 3 (member 3 Lst))
<Regenaxer> (head 3 (tail 3 Lst))
<Regenaxer> (head 3 (cddr Lst))
<Regenaxer> Depends
<hunar> Ah so i need two functions :) I thought there was one function that does this .. no problem though :D thanks
<Regenaxer> There are dozens if ways
<Regenaxer> I think no single function
<Regenaxer> This is very seldom needed
<Regenaxer> especially with numeric access
<Regenaxer> Normally you access a list by content
<hunar> I'm trying to create a pentiTrainer program that introduces the letters one by one, i'm inspired by typing.com which I used to learn touchtyping in a week
<Regenaxer> assoc, member, rank, nth, ...
<Regenaxer> Good idea
<hunar> I'm trying to get this: there is a list (1 2 3 4 5 6 etc...) i want to loop through them and each time get batches of three along with the last three, so first iteration (1 2 3) (1 2 3) next iteration (1 2 3 4 5 6) (4 5 6)
<Regenaxer> Is it numbers? Why not generate them?
<hunar> They are letters
<Regenaxer> I do net understand "batches of three along with the last three"
<Regenaxer> (for (L Lst L (cdd L)) ... ?
<hunar> My English is not very clear sorry :/ ... (setq L (chop "abcdefghijklmnopqrstuvwxyz")) first iteration i want ("a" "b" "c") second iteration i want ("a" "b" "c" "d" "e" "f") etc...
<Regenaxer> So always 'head'?
<Regenaxer> (head 3 L) (head 6 L)
<Regenaxer> You can also cut
<Regenaxer> and conc
<Regenaxer> but head is better I think
<hunar> I think I got how i should do it, I'll write it and come back
<Regenaxer> ok
<hunar> (for I (range 3 10 3) (println (head I (chop "abcdefghi")))) this outputted what i want, the chop here is only for the example, i don't calculate it everytime
<Regenaxer> I would not use 'range', it is a waste
<Regenaxer> creates a garbage list
<Regenaxer> (for (I 3 (>= 9 I) (+ 3 I)) (head I
<Regenaxer> or
<Regenaxer> (for I 3 (head (* 3 I) ...
<hunar> (for (I 3 (>= 9 I) (+ 3 I)) (head I this one looks fine to me :D
<hunar> It looks like C style loops
<Regenaxer> yes
<Regenaxer> Looks wrong in Lisp
<Regenaxer> Numeric loops are seldom
<hunar> But I personally hate the (>= 9 I) notation, i prefer (<= I 9) It takes me more thinking to understand
<Regenaxer> Better prepare the data in another way
<Regenaxer> I avoid (<= and (< because the < is easily confused with another (
<Regenaxer> (>= is just visually better
<Regenaxer> but otherwise <= is fine
<hunar> Ah, that's the reason then :)
<Regenaxer> Yes, depends on the font
<hunar> Which font are you using, It didn't occur to me
<hunar> I have one more small question, I only looked at database a little bit, did you document the file format of the .db file and how it's structured? Before I opened it I expected to see an ASCII file but it was binary (I think)
<Regenaxer> Termux
<Regenaxer> or xterm
<Regenaxer> It is the so-called PLIO format
<Regenaxer> it is what (pr) and (rd) use
<Regenaxer> (out "a" (pr 123 'abc "def" '(g 7 h)))
<Regenaxer> (hd "a")
<Regenaxer> It is a byte-stream
<hunar> Thanks :D
<Regenaxer> No docs I'm afraid ;)
razzy has joined #picolisp
<hunar> No problem :) I sometimes find questions in the log of this chat through google search too
<Regenaxer> ok :)
hunar46 has joined #picolisp
hunar46 has quit [Client Quit]
hunar17 has joined #picolisp
<hunar17> I opened this chat through web.libera.chat and suddenly got disconnected, now when i reconnect it said my name is already in use :/ weird
<Regenaxer> It takes some time for the old session to time out
<Regenaxer> 256 secs I think
<hunar17> Ah, no problem then :D By the way, how can i set my real name
<Regenaxer> Oh, I never did, no idea
hunar has quit [Ping timeout: 256 seconds]
<hunar17> Yours is set to (Baldur Regenaxer )
<Regenaxer> oh
<hunar17> I got confused :/ Is it Baldur Regenaxer or Alexander Burger
<Regenaxer> both :)
<Regenaxer> It is an anagram
<Regenaxer> I set the name on the command line
<Regenaxer> in my irc clien
<Regenaxer> t
<Regenaxer> And my client passes it as host:name it seems
<hunar17> How is it an anagram :)
<Regenaxer> I use also Gerard Belnareux
<hunar17> :/
hunar17 is now known as hunar
<hunar> Ahaaa, I googled anagram and mistakenly understood it as Palindrome, my bad
<Regenaxer> :)
<hunar> Which one is the actual passport name
<Regenaxer> Alexander Burger
<hunar> :)
<hunar> I wasted enough time :D I'll go back to programming, let's see if I can finish it before tomorrow
<Regenaxer> No waste :)
razzy has quit [Ping timeout: 252 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 252 seconds]
hunar has quit [Ping timeout: 256 seconds]
razzy has joined #picolisp
wineroots has joined #picolisp
razzy has quit [Ping timeout: 252 seconds]
hunar has joined #picolisp
razzy has joined #picolisp
hunar has quit [Quit: Client closed]
razzy has quit [Ping timeout: 245 seconds]
hunar has joined #picolisp
<hunar> I finished creating the first version of pentiTrainer http://ix.io/3xQD currently only the lowercase letters, I'll add all the other keys in the future, this first version is not very dynamic and will change alot in the next version
<Regenaxer> Congratulation! :)
<Regenaxer> May I suggest simplifications?
<Regenaxer> (for C Text (prin C)) -> (mapc prin Text) -> (prin Text)
<Regenaxer> So just (prinl Text)
<Regenaxer> The for loops in beginner, they have no effect?
<hunar> Thanks :D
<hunar> wait, there is an extra beginner function which i didn't use
<hunar> (beginner)
<Regenaxer> yes
<hunar> Oh, I didn't realize (prin Text) works
<Regenaxer> Yeah, prin works practically with any kind of argument
<Regenaxer> like 'pack'
hunar has quit [Quit: Client closed]
hunar has joined #picolisp
<hunar> I also needed to remove the last element of a list and couldn't find (butlast) so i (cdr (flip ed it
<Regenaxer> yes, that's fine
<Regenaxer> or (cdr (rot ..))
<hunar> Did you run it :D do you think the training method is good?
<Regenaxer> I have not tried
<Regenaxer> it suggest "a aaaa"
<hunar> Yeat, it trains 3 letters at a time by repeating it, then mixes them to learn finger transition.. then the next 3 letters
<hunar> Yeah*
<Regenaxer> if I hit 'a' nothing happens (?)
<hunar> really :/
<hunar> It should start printing the same a aaaa below the printed one as you type
<hunar> Mine works on computer and termux
<Regenaxer> How do you start it?
<hunar> just pil perniTrainer.l
<hunar> pentiTrainer.l *
<Regenaxer> same here
<Regenaxer> but it hangs
<hunar> Does escape close it?
<Regenaxer> yes
<Regenaxer> or ^C
<Regenaxer> so it waits in (key)
<hunar> Yes, waits forever for either escape or the correct letter
<Regenaxer> if I do (trace 'key)
<Regenaxer> a aaaa
<Regenaxer> key = "a"
<Regenaxer> key :
<Regenaxer> key :
<Regenaxer> a
<Regenaxer> after hitting 'a'
<Regenaxer> 'ask' does not succeed
<Regenaxer> I traced also 'ask'
<Regenaxer> ask : ("a" " " "a" "a" "a" "a")
<Regenaxer> a aaaa
<Regenaxer> key :
<Regenaxer> key = "a"
hunar has quit [Quit: Client closed]
hunar has joined #picolisp
<Regenaxer> Strange, (T (= Key C) (prin C)))))
<Regenaxer> (= Key C) seems to succeed
<Regenaxer> but the loop does not terminate?
<hunar> I'm not sure whats happening at your side, can you try the (pkg install pil) version in termux?
<hunar> sorry (pkg install picolisp)
<Regenaxer> The termux version is very old
<Regenaxer> I have in the global install
<Regenaxer> but would not recommend to use it
<Regenaxer> it is pil64
<hunar> My PC uses the latest version and works, but I failed the installation on termux
<Regenaxer> that explains it, pil21 uses readline()
<Regenaxer> Termux is easy I think
<Regenaxer> You need to install make clang llvm readline libffi openssl pkg-config
<Regenaxer> But the script works on pil21 on a PC?
<hunar> I'll try installing those
<hunar> Yes works on PC
<Regenaxer> So not a pil21 issue
<Regenaxer> In 'ask', the loop should wait for 3 keys?
<Regenaxer> (for C Text
<Regenaxer> Text is ("a" " " "a" "a" "a" "a")
<Regenaxer> So you need to type these letters?
<hunar> If you run (ask ("a")) then it waits for one key press a and stops
<Regenaxer> It works if I press exactl a, space and 4 a's
<Regenaxer> So I misunderstood the usage
<hunar> Yes :) you press what's printed above the cursor, wrong keys are ignored
<Regenaxer> I get:
<Regenaxer> Press Esc (or - #-#-) to exit at any time
<Regenaxer> Hint: a is # --#-
<Regenaxer> a aaaa
<Regenaxer> Hint: SPACE is # ----
<Regenaxer> a aaaa
<Regenaxer> b bbbb
<Regenaxer> Hint: b is # -##-
<Regenaxer> b bbbb
<Regenaxer> Hint: c is - #-#-
<Regenaxer> c cccc
<Regenaxer> ok, sorry :)
<hunar> No Problem :D I should add a sentence before it begins to explain it :)
<Regenaxer> :)
<Regenaxer> Ah, I have a penti trainer too
<Regenaxer> but did not use it a long time
<Regenaxer> It is for advanced users, as it also asks for punctuation
<hunar> Really, I made it before i couldn't find anything else
<Regenaxer> I did not publish
<Regenaxer> just for fun
<Regenaxer> I measures the time
<Regenaxer> http://ix.io/3xQQ
<hunar> I'll organize them in levels, the first level is the lowercase alphabet, next will be upercase + cotrol etc.. hopefully everything in the future
<hunar> Aaah I figured out how to use it.. its a very compact code :)
<hunar> I don't know how to share the error message from termu when make ing in src/
<Regenaxer> I recommend to use tmux in termux
<hunar> undefined reference to `natRetBuf`
<Regenaxer> Then copy/past from tmux
<Regenaxer> oh
<Regenaxer> did you extract pil21.tgz and then (cd src; make)?
<hunar> Yes
<Regenaxer> `natRetBuf` is in the pre-built base.ll
<Regenaxer> define i64 @natRetBuf(i64, i8**) align 8 {
<hunar> pastebin.com/3ujnJfcx
<Regenaxer> hmm
<hunar> I'll re-download it
<hunar> It worked :/
<Regenaxer> It is not the tarball, it must be the libs
<Regenaxer> crtbegin.c
<Regenaxer> oh!
<Regenaxer> how that?
<hunar> Maybe it was an old one, but i don't remember downloading an old one
<Regenaxer> Perhaps some garbage left over?
<Regenaxer> ok, anyway :)
<hunar> As long as it's fixed :)
<Regenaxer> yes, lets see it pragmatically
<Regenaxer> It is a pity that PicoLisp is no longer updated on Termux
<Regenaxer> Fredrik Fornwall, the maintainer of Termux, used to update it always very quickly
<Regenaxer> But then the Google trouble started
<Regenaxer> and Termux is available only on F-Droid
<Regenaxer> and Fredrik never upgraded to pil21 :(
<Regenaxer> He used to answer my mails alway fast
<Regenaxer> but now he dropped completely silent
<Regenaxer> Did not answer my last 8 mails
<hunar> What is the reason :/
<Regenaxer> I don't know. Perhaps he is frustrated
<hunar> :(
<Regenaxer> I understand that. Termux is practically forbidden by Google
<hunar> Is there a website where people submit picolisp libraries?
<Regenaxer> tankf33der has one
<Regenaxer> But I don't know of any "libraries"
<Regenaxer> I feel libraries are often not needed, as you can call native C and external programs so easily
<hunar> Thanks :) Is there a reason that you dont use github or gitlab, how different is git.envs.net
<Regenaxer> I dislike git and similar source systems because they destroy the file meta data
<Regenaxer> My work style completely depends on e.g. time stamps
<Regenaxer> And they are lost when you check out a file
<Regenaxer> So no option for me
<hunar> I'm not familiar with metadata, do you mean the creation/edited dates?
<Regenaxer> yes
<Regenaxer> most of all modificatio date
<Regenaxer> Try this : (vi "pil21")
<Regenaxer> and go to the end
<Regenaxer> pil21/src/balance.c (3) 2005-07-06 05:29:49
<Regenaxer> I edit all directories this way, always the newest on top
<Regenaxer> And my source management is all based on mod timestamp
<Regenaxer> i.e. replication between machines, incremental backups
<Regenaxer> 'make' of course too
<hunar> Aaaaa
<hunar> Now I get it
<Regenaxer> tar preserves the mod time
<Regenaxer> scp -p too
<Regenaxer> and rsync
<Regenaxer> but *not* get at al
<Regenaxer> Very strange, as the stamps are sooo important
<Regenaxer> "but *not* get at al" -> I mean "not git"
<hunar> Strange :/
<Regenaxer> yeah
<Regenaxer> all of them, sccs, rcs, mercury and whatnot
<Regenaxer> I used them all if needed
<Regenaxer> but *never* for my own files
<hunar> Do you use the Release section? https://git.envs.net/mpech/pil21/releases .. people may want to download old versions ;)
<Regenaxer> Mike Pechkin takes care of it
<Regenaxer> His site checks for a new pil21.tgz every 10 mins or so, and downloads it
<hunar> What is the address :o
<hunar> Ah, so the Commit s are each different releases from your pil21.tgz
<Regenaxer> right :)
<hunar> Cool :D
<Regenaxer> It chages every day on the average
<hunar> By the way, i saw this _PI_co Lisp is not _CO_mmon Lisp is that the original idea behind the name pico?
<Regenaxer> haha, no, this word play was later
<hunar> :D
<Regenaxer> pico is just for "small"
<hunar> :)
<hunar> Is operator overloading possible in Pil? or you consider it unnecessary ;)
<Regenaxer> Sometimes it is useful, sure
<Regenaxer> I do overload usually by inheriting and overriding methods
<Regenaxer> Many built-in functions *are* overloaded
<Regenaxer> eg the above 'prin'
alexshendi has joined #picolisp
<Regenaxer> most functions take many types and do something with them
<hunar> Do you have a very small example :)
<Regenaxer> (fifo 'X Val) puts Val into a fifo, (fifo 'X) retrieves from the fifo
<Regenaxer> so it is both put and get
<Regenaxer> I think the majority of the built-ins are overloaded this way
<Regenaxer> Not the majority, but many
<Regenaxer> Look at 'for' or 'let'
<hunar> Is that function overload? I mean the function name is different
<hunar> Ah, you mean how (for has three forms
<Regenaxer> I understand overload as if e.g. '+' also concabnenates strings (this is not in }il)
<Regenaxer> yes
<Regenaxer> depending on the arg it behaves differently
<Regenaxer> (formay 'num) -> sym
<Regenaxer> (formay 'sym) -> num
<Regenaxer> that is overloading, no?
<hunar> Yeah
<Regenaxer> Basically two conversion functions
<Regenaxer> (format 'sym) -> num
<Regenaxer> t and y are close :)
<hunar> Great :)
<hunar> Last question :) what function is used like C's printf, i'm currently using (println "a = " a) style for joining strings and variables..
<Regenaxer> 'println' is not usefcl here, it prints Lisp data
<Regenaxer> better 'prinl'
<hunar> Right, It shows quotes around the final text
<Regenaxer> (prinl "This is " (+ 3 4) " or " (format 123 2))
<Regenaxer> yes
<Regenaxer> print is so that (read) gets it back
<Regenaxer> print, printsp, println
<Regenaxer> vs prin and prinl
<Regenaxer> (pr ..) is PLIO output
<Regenaxer> used in DB and RPC or IPC
<Regenaxer> PLIO is used a lot internally
<Regenaxer> e.g. 'tell' and 'hear'
<Regenaxer> or in 'later'
<Regenaxer> also 'udp'
<hunar> :)
<Regenaxer> the canvas.js lib also uses it in one direction
<Regenaxer> There is PLIO for Java, Js and C
<Regenaxer> the reflection in PilBox uses PLIO
<Regenaxer> So I think pr/rd is more often used than print/read
<hunar> I haven't heard of plio prior to this conversation so i'm a little bit lost :)
<Regenaxer> It is often not so visible
<Regenaxer> not used on the application level so much
<Regenaxer> But internally lots of places in Pil use it
<hunar> I remembered another question :/ I ask too many questions sorry .. I read somewhere where you said (picolisp wasn't designed to performance) or something like that .. does that mean there is still room for improving the performance after all those years?
<Regenaxer> No problem!
<Regenaxer> yes, the interpreter has some overhead
<Regenaxer> You can improve by writing critical functions in PilSrc and compile them
<hunar> What is PilSrc :)
<Regenaxer> In fact, pil21 is a *little* slower than pil64
<Regenaxer> pil64 was hand-optimized assembly
<Regenaxer> PilSrc is the source Pil21 is written in
<Regenaxer> pil21/src/*.l
<hunar> Aha
<Regenaxer> in pil64 it was assembly in src64/*.l
<hunar> I thought It's something like PilAsm (which I didn't find too much information about it)
<Regenaxer> yes, pilAsm is the lang for pil64
<Regenaxer> PilSrc is compiled to LLVM code
<Regenaxer> src/*.ll
<hunar> I want to take a peek at pil64 :) where can i find it
<Regenaxer> The last version is software-lab.de/picoLisp.tgz
<Regenaxer> or, I think you have it already in PilOS
<hunar> Yes :)
<hunar> Thanks for all the answers :D Good Night Regenaxer
<Regenaxer> Welcome! Good night :)
hunar has quit [Quit: Client closed]
alexshendi has quit [Quit: -a- Connection Timed Out]
alexshendi has joined #picolisp
alexshendi has quit [Quit: -a- Connection Timed Out]
alexshendi has joined #picolisp
peterhil has joined #picolisp
alexshendi has quit [Quit: -a- Connection Timed Out]
alexshendi has joined #picolisp
alexshendi has quit [Quit: -a- Connection Timed Out]
alexshendi has joined #picolisp