ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Picolisp latest found at http://www.software-lab.de/down.html | check also http://www.picolisp.com for more information
orivej has quit [Ping timeout: 265 seconds]
alexshendi has quit [Read error: Connection reset by peer]
aw- has joined #picolisp
<aw-> rick42: haha thanks, i'll be happy to write more if there's interest to cover certain topics
<aw-> oh man, is bene at 34C3? i'd love to go there.. maybe next year
orivej has joined #picolisp
orivej has quit [Ping timeout: 260 seconds]
orivej has joined #picolisp
Regenaxer has left #picolisp [#picolisp]
Regenaxer has joined #picolisp
<aw-> hi all
<aw-> Regenaxer: if I (load "mylib.l") which contains something like: [de my-fun () ... ] ... is it "safe" to do test for my-fun with: (when my-fun ....) ?
<Regenaxer> Hi aw-
<Regenaxer> yes, you can test the value
<aw-> ok good
<aw-> because if i just run (my-fun) and it's not loaded, then it produces an error
<Regenaxer> if you want to avoid loading multiple times, you can just write `my-fun
<aw-> same as eval?
<Regenaxer> I mean to read NIL
<Regenaxer> In the system you find often `*Dbg
<aw-> oh, it's running without debug loaded
<Regenaxer> ie a read-macro returining NIL or not
<aw-> hmmm
<Regenaxer> and NIL terminates (read)
<Regenaxer> Or do you want to do (unless my-fun (load "my-lib.l?)) ?
<Regenaxer> any method is fine
<Regenaxer> Usually I don't worry and just load all always
<Regenaxer> as it is so fast
<aw-> no
<aw-> i want to avoid doing (my-fun) if "my-lib.l" wasn't loaded
<Regenaxer> Ok, yes
<Regenaxer> or catch the error
<aw-> (when my-fun (my-fun)) # essentially
<Regenaxer> (catch '("undefined") (my-fun))
<Regenaxer> But yes, 'when' is more efficient here than 'catch'
<Regenaxer> 'catch' would be good if there may be many such functions
<aw-> right right
<Regenaxer> btw, must be "Undefined" (upper case)
<aw-> ok thanks!
orivej has quit [Ping timeout: 260 seconds]
orivej has joined #picolisp
<tankfeeder> code for advent is rolling, several days left
<Regenaxer> Which advent? For the orthodox Christmas on 9th of January?
<Regenaxer> ui
<aw-> Regenaxer:
<aw-> i can't figure out why this doesn't work: (case (key) ((format 3) (prinl "pressed 3")))
<aw-> is (format 3) unevaluated?
<Regenaxer> The CARs of the 'case' clauses are not evaluated
<aw-> ok ok
<aw-> i got it, thanks
<Regenaxer> Better 'cond' then
<Regenaxer> :)
<aw-> another question
<aw-> I have a (task -5000 0 (prg)) ... from within (prg) how can I end that task?
<aw-> i tried (task -5000) but nothing happened
<Regenaxer> (task -5000) is correct
<Regenaxer> Can you show 'prg'?
<aw-> oh it's much too long
<aw-> but i think i found the issue
<Regenaxer> ok
<Regenaxer> I tried (task -5000 0 (msg 1) (task -5000))
<aw-> i have a (key) .. doesnt that block all timers etc
<Regenaxer> hmm, should not block them
<Regenaxer> not sure atm, as nested tasks do something special
<Regenaxer> In any case, after (key) returns the task should be removed
<aw-> right
<aw-> i found my problem.. it's because i had a (task) and then a (key) and then another (key)
<aw-> and a (loop)
<aw-> everything was blocked hahaa
<Regenaxer> ok :)
<aw-> i just noticed i can do (key timeout)
orivej has quit [Ping timeout: 256 seconds]
<aw-> Regenaxer: if a (task) has a timeout, ex: 5 seconds, is there a way to make it timeout sooner?
<Regenaxer> yes, you can also call (task -5000) from somewhere else
<Regenaxer> or destructively modify the value of *Run
<Regenaxer> The CADR of the clause contains the remaining time
<Regenaxer> (set (cdr (assoc -5000 *Run)) <newValue>)
<aw-> ohhh lovely
<aw-> why did you choose to make the key == timeout?
<aw-> less code/variables?
<Regenaxer> What else would you choose?
<Regenaxer> The key in the CAR is a re-init here
<aw-> well, this approach prevents you from having multiple tasks with the same timeout value
<Regenaxer> and the CADR is the timeout
<Regenaxer> yes, the CARs must be unique
<Regenaxer> to address the clause
<Regenaxer> (fd or ms)
<aw-> so ican't do (task -5000 0 (prg1)) and then (task -5000 (prg2))
<Regenaxer> You can always put multiple code pieces into a single task body
<aw-> two tasks with 5000ms timeout
<Regenaxer> right
<aw-> it's not a big issue, since i can just do 5000 and 5001
<Regenaxer> So (task -5000 0 (prg1) (prg2))
<aw-> or that
<Regenaxer> With 5000 and 5001 you can stop each of them individually
orivej has joined #picolisp
<aw-> right
rgrau has joined #picolisp
<aw-> hmmm
<aw-> (read) doesn't echo to the console
<Regenaxer> T
<aw-> how can I do that?
<aw-> loop over (char) until (eol) ?
<Regenaxer> (while (msg (read)) (doSomething @]
<Regenaxer> or pipe through 'tee'
<aw-> ohhh (msg)
<aw-> because that goes to console
<Regenaxer> to stderr to be precise
<aw-> oh
<aw-> haven't used that in a while, completely forgot about it
<aw-> isn't there another way?
<Regenaxer> You can inter
<Regenaxer> cept on several levels
<aw-> hmm
<Regenaxer> eg pipe through 'tee', or intercept 'char'
<Regenaxer> or just 'trace' something
<Regenaxer> Depends on the situation
<aw-> i'm trying to do something like this:
<aw-> (prin "Enter a value" (read))
<Regenaxer> Needs a flush
<aw-> no
<aw-> i want to see the characters as they're typed
<Regenaxer> ok, right, here the console read flushes
<Regenaxer> Should be echoed by 'read' or 'line' unless you switched to raw mode
<Regenaxer> ie stdin generally
<Regenaxer> btw, (prin "Enter a value" (read)) needs no (flush) only when already in raw mode (line editor in debug mode)
<Regenaxer> Else better: (prin "Enter a value") (flush) (read)
<Regenaxer> Also, in a running program you probably need (in NIL (read))
<Regenaxer> as the current input channel may be on something else (eg. current file)
<aw-> i'm not in debug/line editor mode
<aw-> yes that's what i'm doing
<aw-> (in NIL (read) (flush) ...
rgrau has quit [Ping timeout: 264 seconds]
<Regenaxer> ok
<aw-> but it's not displaying the characters as I type
<Regenaxer> here it does
<aw-> it does directly in pil +
<aw-> but not when i run ./myscript.l
<Regenaxer> I tried without +
<Regenaxer> Stdout is not redirected?
<aw-> no
<Regenaxer> Then stdin is not raw and should echo everything ...
<Regenaxer> stdout I mean
<Regenaxer> stdin is on the script of course
<aw-> (out NIL (in NIL (while (char) (prin @) (flush))))
<aw-> seems to work
<aw-> hmm.. misses the first char
<Regenaxer> this script works:
<Regenaxer> #!/data/data/com.termux/files/usr/bin/pil
<Regenaxer> (prin "? ")
<Regenaxer> (flush)
<Regenaxer> (in NIL (read))
<Regenaxer> (bye)
<Regenaxer>
<Regenaxer> or:
<Regenaxer> #!/data/data/com.termux/files/usr/bin/pil
<Regenaxer> (prin "? ")
<Regenaxer> (flush)
<Regenaxer> (msg (in NIL (read)))
<Regenaxer> (bye)
<Regenaxer>
<Regenaxer> to see the result with msg
<Regenaxer> tankfeeder: Wow
<aw-> why do you flush before?
<Regenaxer> To see the "? "
<aw-> yes
<Regenaxer> As I said above, it is needed usually
<Regenaxer> if prin and not prinl
<Regenaxer> 'prinl' flushes automatically
<Regenaxer> (or stdout to be exact)
<aw-> weird
<aw-> your code works fine
<aw-> but it doesn't work when i copy it into mine
<Regenaxer> Must be something in the setup
<aw-> must be..
<Regenaxer> It does not echo then?
<Regenaxer> looks like raw mode
<Regenaxer> Probably because you call (key) before?
<aw-> ah
<aw-> yes
<aw-> i got it just as you typed it
<Regenaxer> :)
<aw-> damnit
<Regenaxer> You can call (raw NIL)
<aw-> yeah i confirmed with (raw)
<aw-> it output T
<aw-> ahhh i knew it was something weird going on
<aw-> thanks!
<Regenaxer> :)
<Regenaxer> And with (raw NIL) you can reset it after (key) or before (read)
orivej has quit [Remote host closed the connection]
<aw-> yes i set it after (key) to ensure it doesn't hit me again
<Regenaxer> ok
rgrau has joined #picolisp
orivej has joined #picolisp
orivej has quit [Ping timeout: 268 seconds]
<aw-> Regenaxer: recently i was thinking about the pil documentation..
<aw-> (function ref)
<aw-> a few things: i'm wondering if we could generate a listing of each function with a simple 1-line description
<aw-> probably require a different set of docs for that
<aw-> ex: Mapping section, list of every function under 'Mapping' (sorted alphabetically), with 1-line underneath the function name
<aw-> when I look at the list of keywords: apply by cnt extract filter... it doesn't say enough, so i'm forced to click on each one, which leads me to the full description of the function
<aw-> makes it difficult to quickly scan everything that's available
<aw-> not sure if that makes sense
<aw-> what i'm thinking is something along the lines of like: mapping.html, which lists all the mapping functions and their description / usage
<aw-> that would probably be best for quickly scanning all the mapping functions (as you've categorized them)
<Regenaxer> true
<Regenaxer> But looks like a lot of work
<aw-> you use a script to generate the docs, right?
<Regenaxer> make, and also to maintain
<Regenaxer> no
<Regenaxer> Written in Vip manually
<aw-> ohhhhh
<Regenaxer> Extracting an meaningful line automatically sounds difficult
<aw-> well i guess we found a project for beneroth ;)
<Regenaxer> haha
<tankfeeder> Regenaxer: question again:
<Regenaxer> Needs an AI program
<aw-> well, it would be fine if it displayed the full ref
<tankfeeder> i think about create list of bridges like recur-recurise+mapping function
<tankfeeder> is it ok ?
<Regenaxer> I don't fully grasp the task, but recursion and mapping is a typical way. What else would you think of?
<tankfeeder> manual recursion
<Regenaxer> Manual in which way? Calling functions by name?
<tankfeeder> yeap
<Regenaxer> yes, I'd first go with recur/recurse
<Regenaxer> no need to think up names ;)
<tankfeeder> like this:
rgrau has quit [Ping timeout: 260 seconds]
<Regenaxer> yes, good
orivej has joined #picolisp
rgrau has joined #picolisp
rgrau has quit [Ping timeout: 272 seconds]
karswell has joined #picolisp
<aw-> Regenaxer: still here?
<Regenaxer> yes
<aw-> one last thing
<aw-> going back to my example earlier
<aw-> or, you're example
<Regenaxer> ok
<aw-> (prin "? default")
<aw-> (in NIL (read))
<aw-> how can I delete the word 'default' ?
<Regenaxer> Hmm, does (prin "^H^H^H^H^H^H^H^H") work?
<Regenaxer> or does it not backspace beyond the current start position?
<aw-> no, backspace doesn't work before 't'
<aw-> exactly
<Regenaxer> I suspected so
<Regenaxer> Then there is no way, as it was sent to stdout
<Regenaxer> Perhaps with ncurses or so
<Regenaxer> tput etc
<aw-> hmmm
<aw-> yeah.. i'm using that for colour
<aw-> since it was flushed, it can't be deleted?
<Regenaxer> yes
<Regenaxer> only screen manipulations might overwrite it again
orivej has quit [Ping timeout: 276 seconds]
<aw-> yep
<aw-> ok then i'll use tput
<aw-> thanks
<Regenaxer> good
<Regenaxer> I hope it works this way
<aw-> or maybe 'read'
<Regenaxer> ?
<aw-> ohh... 'read' is a bash builtin
<aw-> tput is fine
<Regenaxer> ok
<aw-> hmmm
<aw-> backspace is ^H
<aw-> but my terminal is seeing it as ^?
<aw-> (key) is seeing "^?" ...
<aw-> linux & mac.. i guess it's fine
<aw-> found in io.l
<aw-> ld B (char "\^") # Print ^?
<aw-> cmp B 127 # DEL?
<aw-> if eq # Yes
<aw-> call (PutB)
<aw-> ld B (char "?")
<Regenaxer> ^? is DEL (ASCII 127) in PicoLisp
<Regenaxer> ^H is correct
<aw-> yeah
orivej has joined #picolisp
<rick42> sup folks
<aw-> hey rick42
<aw-> Regenaxer: ok one final question,
<rick42> aw-: hey
<aw-> for today
<aw-> why does (read) ignore (char 13) ?
<rick42> aw-; does printing a carriage return (but no line feed) and then some characters, overwrite the "? default"?
<Regenaxer> Hi rick42!
<rick42> Hi Reg!
<Regenaxer> aw-, it ignores all white space
<Regenaxer> except in strings
<Regenaxer> rick42, carriage return is a good idea perhaps
<aw-> rick42: no
<rick42> ok
<aw-> ignores all white space...
<Regenaxer> well, as delimiter
<Regenaxer> (line) accepts LF and CR+LF as line-end
<Regenaxer> ah, also just CR like in MacOS
<aw-> oh right
<aw-> haha ok thanks
orivej has quit [Ping timeout: 240 seconds]
<aw-> good night
<aw-> Regenaxer: thanks for the help today
<Regenaxer> Sleep well!
<Regenaxer> welcome :)
<rick42> aw-: gnite!
aw- has quit [Quit: Leaving.]
beneroth has joined #picolisp
orivej has joined #picolisp
<beneroth> hi all
orivej has quit [Ping timeout: 240 seconds]
<beneroth> bbl
beneroth has quit [Quit: Farewell]
alexshendi has joined #picolisp
alexshendi has quit [Ping timeout: 240 seconds]
chuckJ has joined #picolisp
chuckJ has quit [Ping timeout: 252 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 264 seconds]
tankfeeder has quit [Quit: Connection closed for inactivity]
miskatonic has joined #picolisp
C-Keen has quit [Quit: WeeChat 1.9.1]
alexshendi has joined #picolisp
rgrau has joined #picolisp
orivej has joined #picolisp
C-Keen has joined #picolisp
alexshendi has quit [Read error: Connection reset by peer]
miskatonic has quit [Remote host closed the connection]
alexshendi has joined #picolisp
chuckJ has joined #picolisp
alexshendi has quit [Ping timeout: 246 seconds]
chuckJ has quit [Ping timeout: 256 seconds]
klntsky has joined #picolisp
klntsky has quit [Quit: WeeChat 2.0.1]
rgrau has quit [Read error: Connection reset by peer]
rgrau` has joined #picolisp
groovy2shoes has quit [Remote host closed the connection]
groovy2shoes has joined #picolisp
rgrau` has quit [Quit: ERC (IRC client for Emacs 26.0.50.1)]
rgrau has joined #picolisp
rgrau has quit [Quit: ZNC 1.6.3+deb1 - http://znc.in]
rgrau has joined #picolisp
rgrau has quit [Remote host closed the connection]
rgrau has joined #picolisp