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: 260 seconds]
jibanes has quit [Ping timeout: 240 seconds]
jibanes has joined #picolisp
jibanes has quit [Ping timeout: 268 seconds]
jibanes has joined #picolisp
orivej has joined #picolisp
rob_w has joined #picolisp
<aw-> hi all
<Regenaxer> Hi aw-
<aw-> hi
<aw-> Regenaxer: question regarding (throw)
<aw-> in Error Handling docs, it says the last error should appear in *Msg global
<aw-> but if I do (catch 'something (throw 'something)) then there's nothing in *Msg
<aw-> or even (throw 'something "an error occured")
<aw-> how do I get "an error occured" in *Msg ?
<aw-> other than (setq *Msg "an error occured")
<Regenaxer> Only for errors
<Regenaxer> (quit ..) instead of (throw )
<Regenaxer> or some runtime error
<aw-> no (quit) is bad
mtsd has joined #picolisp
<aw-> i can't quit my program if it fails, it needs to recover cleanly
<Regenaxer> : (/ 3 0)
<Regenaxer> !? (/ 3 0)
<Regenaxer> Div/0
<Regenaxer> ? *Msg
<Regenaxer> -> "Div/0"
<aw-> yes i know
<Regenaxer> yes, so you 'catch' errors
<aw-> is it safe to manually (setq *Msg "my error") ?
<Regenaxer> Why do you need *Msg?
<Regenaxer> It does not help to recover
<Regenaxer> (catch '("Div/0") ... (/ ... 0]
<aw-> i know.. just for external programs which do error handling, if they see *Msg they can print it to output
<Regenaxer> right
<Regenaxer> eg PilBox uses it
<Regenaxer> or logging on servers
<aw-> right
<Regenaxer> I usually let the process terminate on errors
<aw-> i'm using catch, but i just want a place to put the error message which was caught
<aw-> i can do it in (finally
<Regenaxer> It may be dangerous to continue
<Regenaxer> hmm, there is no simple way to detect that there was an error after catch
orivej has quit [Ping timeout: 240 seconds]
<aw-> yes i know
<Regenaxer> you need to install a handler in *Err
<Regenaxer> This is where @lib/app.l prints errors before exit
<aw-> oh interesting
<aw-> does that work even if there's a (catch ?
<aw-> hmm.. doesn't seem like it
<Regenaxer> I think it does
<Regenaxer> *Err is evaluated before
<Regenaxer> hmm, maybe not
<Regenaxer> have you tried?
<aw-> yes
<aw-> i tried (de *Err (prinl *Msg)) .. and then (catch 'mytag (throw 'mytag "my error"))
<Regenaxer> No, it works
<Regenaxer> ah, no, you are right
<Regenaxer> But you can check *Msg
<aw-> *Msg is empty
<Regenaxer> I just tried
<Regenaxer> : (catch '("Div") (/ 3 0))
<Regenaxer> -> "Div"
<Regenaxer> : *Msg
<Regenaxer> -> "Div/0"
<Regenaxer> btw, (catch 'mytag does not catch errors
<Regenaxer> it catches (throw 'mytag
<Regenaxer> To catch errors you must pass a list
<Regenaxer> (catch '(NIL) catches *all* errors
<Regenaxer> same as (catch '("")
<Regenaxer> Still, continuing with the process after an error may be dangerous
<Regenaxer> The env may be corrupted
<Regenaxer> or stack overflown
<Regenaxer> Safest is to terminate the (child)process
<Regenaxer> So I would say do (off *Msg) if necessary, then check it after 'catch'
<aw-> right, i see
<aw-> ok thanks!
<Regenaxer> :)
<tankf33der> hi all
<tankf33der> Regenaxer:
<tankf33der> testing new pil64 with atomic
<tankf33der> check out how they run with and without (wait 1)
<Regenaxer> Hi tankf33der
<Regenaxer> Hmm, is it correct?
<tankf33der> seems ok
<Regenaxer> There are so many zeroes ...
<tankf33der> i cant show but solaris 11 run the same
<Regenaxer> ok
<tankf33der> but on the next 2 secs zeros dissapears
<tankf33der> with numbers
<tankf33der> and after several loops again and again
<Regenaxer> I see
<tankf33der> i've finished tests for pil64
<tankf33der> look at this list
<tankf33der> :
<tankf33der> some os failed show numbers without wait 1
<Regenaxer> owl Linux
<tankf33der> just like redhat 5
<tankf33der> or centos 5
<Regenaxer> are they pil64?
<tankf33der> yeap
<Regenaxer> "fail" means it does not print, right?
<tankf33der> right
<Regenaxer> No idea
<tankf33der> maybe kernel 2.6
<Regenaxer> What might be different?
<Regenaxer> ah
<Regenaxer> not microseconds resolution perhaps?
<Regenaxer> I have no real idea
<tankf33der> its ok
<Regenaxer> T
<Regenaxer> It is an extreme test case, ok I think
<Regenaxer> Thanks for testing!
<aw-> I published one of my tools today, for working with AWS (Amazon)
<Regenaxer> What does the tool do?
<aw-> if it interests anyone: https://github.com/aw/picolisp-awscurl
<aw-> Regenaxer: it makes calls to the AWS API
<aw-> it handles all the request signing stuff before being able to make an API call
<Regenaxer> Nice
<Regenaxer> I cannot judge as I have never looked at AWS
<aw-> Regenaxer: lucky for you ;)
<Regenaxer> :)
<Regenaxer> The source looks good at first sight.
<Regenaxer> Perhaps a minor optim: (if (=0 (length (argv))) -> (ifn (argv)
<Regenaxer> Taking the length is a bit costly
<Regenaxer> Even better is (opt) to avoid bilding the list
<aw-> hmmm
<Regenaxer> I almost never use (argv) any more
<aw-> that reads the first option right?
<Regenaxer> it is heavy
<Regenaxer> yes
<Regenaxer> (while (opt) ...
<Regenaxer> But this stops at "" args or course, may be not wanted in some cases
<aw-> what do you mean "stops" ?
<aw-> "" is considered an arg?
<Regenaxer> yes, an empty arg
<Regenaxer> so (opt) returns NIL despite there may be further args
<aw-> oh that should be fine though
<Regenaxer> In that case (argv 'A 'Foo ... is better
<aw-> wait i'll test
<Regenaxer> ok
<Regenaxer> No big thing anyway. Not critical in scripts
<aw-> hmmm.. it takes away my first (opt)
<aw-> (ifn (opt) ... (while (opt) .. ??
<Regenaxer> yes, you want to check for "no args"
<aw-> confused
<Regenaxer> Perhaps: (let A (opt) (ifn A (...) (loop (procees A) (NIL (setq A (opt]
<Regenaxer> or, use (argv) but then do not throw away the list:
<Regenaxer> (ifn (argv) (usage) (for A @ (process A]
<aw-> yeah.. it's a script.. not very critical for performance
<Regenaxer> exactly
<aw-> the bottleneck is the web server communication
<aw-> AWS so slow
<Regenaxer> I believe so
<aw-> thanks Regenaxer
<Regenaxer> np :)
<Regenaxer> I'm just pedantic ;)
<Regenaxer> BTW, you know that there is a very elegant way in pil for such command line args via functions?
<Regenaxer> eg (de -verbose () (on *Aws_verbose))
<Regenaxer> then no further parsing is needed
<Regenaxer> (de -request () (setq *Aws_method (opt)))
<Regenaxer> and so on
<Regenaxer> then --verbose and --requesw arg calls these functions
<Regenaxer> --unknown gives an error
<aw-> hmmm
<aw-> oh cool
<aw-> but then i need a function for each ?
<tankf33der> FYI
<tankf33der> # pil awscurl.l --verbose --query --host
<tankf33der> # pil awscurl.l --verbose --host
<aw-> tankf33der: try --help
<aw-> ;)
<aw-> --host <host>
<tankf33der> they behave differently
<aw-> yes it doesn't validate arguments
<tankf33der> you dont want handle this, right ?
<tankf33der> ok then
<aw-> no i don't care
<aw-> it's version 0.2 haha
<aw-> eventually i'll get around to it, now i just needed something that works when given the correct values
<aw-> tankf33der: thanks for testing :)
<Regenaxer> In general, symbols with a leading '-' are reserved for command line args
<Regenaxer> Saves a *lot* of coding for this kind of scripts
<tankf33der> aw-: check how i did in signify
<Regenaxer> You just need (load T) to parse all command line args
<aw-> fixing a bug
mtsd has quit [Quit: Leaving]
rob_w has quit [Quit: Leaving]
<aw-> (de gen NIL (unless (=1 (length (argv))) (quit "Wrong usage"))
<aw-> ?
<aw-> Regenaxer: "just need (load T)"
<aw-> but i still need to write a function for each argument
<aw-> i can't see what's the difference
<aw-> between that and (while (opt) (case
<aw-> also, this (while (opt) (case is taken directly from PicoLisp docs
<aw-> so arguments starting with - are evaluated?
<aw-> what if I don't want to evaluate them?
<aw-> Regenaxer: ok i tried changing it all to functions
<aw-> but now if I do ./awscurl.l --nonexistant
<aw-> i get an error
<aw-> this is terrible
<aw-> $ ./awscurl.l --nonexistant
<aw-> [./awscurl.l:146] !? (-nonexistant)
<aw-> ?
<aw-> -nonexistant -- Undefined
<Regenaxer> Mom, tel
<Regenaxer> You did (de -nonexistant () (...)) ?
<Regenaxer> then no further (opt) processing is required
<Regenaxer> The functions are executed one after the other
<aw-> no
<aw-> there's no function named -nonexistant
<Regenaxer> right
<Regenaxer> you need to define
<aw-> no
<aw-> it's nonexistant
<Regenaxer> eg (de -verbose () (on *Aws_verbose))
<aw-> yes i did that
<Regenaxer> ok
<aw-> previously with the (while) loop, it would catch arguments which don't exist
<aw-> and it would show the help output
<aw-> cleanly
<aw-> (T (tc-show-help)..
<aw-> (load T) just accepts EVERYTHING
<aw-> that's so unsafe
<aw-> yeah.. i think i will revert the code, (load T) is not a good idea
<beneroth> yeah, the implicit function calling is nice for writting quick scripts, but for cli tools which should be re-usable by others validating input is just much safer and easier to use
<aw-> indeed
<Regenaxer> It gives an error for undefined funs
<aw-> hey bene
<Regenaxer> Hi beneroth
<beneroth> Regenaxer, yes, not helpful without reading the source :)
<beneroth> hi aw-, Regenaxer :)
<Regenaxer> Parsing the input I find rather redundant
<Regenaxer> you parse each arg, then call the corresponding fun
<beneroth> only redundant if you can omit validation
<beneroth> this way, you can ensure that no function is called which is not indented for direct cli calling. and you can ensure that no missing values or out-of-range inputs happen.
<beneroth> a made scripts both ways. I tend more going into explicit input parsing now.
<aw-> beneroth: right, except now i don't check for missing/out of range inputs haha
<beneroth> :P
<aw-> not yet.. will add it maybe later this week
<beneroth> I add --help functions to my cli tools so I can lookup the usage without having to read the source, because I forget the usage all the time
<Regenaxer> afp
<aw-> beneroth: same
<beneroth> good! thx
<aw-> i've used this as referenced many years ago.. it's a bit strict, but kind of interesting and useful as "guideline"
brandelune__ has joined #picolisp
brandelune__ has quit [Client Quit]
brandelune_ has joined #picolisp
brandelune_ has left #picolisp [#picolisp]
brandelune__ has joined #picolisp
brandelune__ has quit [Client Quit]
brandelune has joined #picolisp
brandelune has quit [Client Quit]
<Regenaxer> ret
<Regenaxer> aw-, I don't what the problem is with '-foo' definitions
<Regenaxer> *understand
<aw-> Regenaxer: no problem
<aw-> i just don't want the program to end abruptly if someone provides an argument that's not defined
<aw-> and I don't want the program to accept arguments for functions which should be "internal"
<Regenaxer> But you catch errors anyway? So you could do (catch '("Undefined") (load T))
<aw-> evaluating any/all cmdline parameters is not safe
<Regenaxer> hehe, but pil *always* accets such args, right
<Regenaxer> ?
<aw-> no
<aw-> ok here's an example
<Regenaxer> No one stops you to call pil -'call "rm" "-r" ..'
<aw-> i have a function: (tc-options)
<aw-> huh
<aw-> yes i know
<aw-> but my program is not pil, it's ./whatever.l
<Regenaxer> well, ok, not a problem usually, yes
<Regenaxer> if not (load ..) is called
freemint_ has joined #picolisp
f8l has quit [Ping timeout: 260 seconds]
karswell has quit [Ping timeout: 256 seconds]
<Regenaxer> I still like the idea of command line functions
<Regenaxer> They can be easily encapsulated in namespaces:
<Regenaxer> (symbols '(cli) (load T)) guarantees that only these symbols are visible
<Regenaxer> yes, horror!
f8l has joined #picolisp
karswell has joined #picolisp
pierpal has joined #picolisp
pierpal has quit [Quit: Poof]
pierpal has joined #picolisp
orivej has joined #picolisp
refrijerator has joined #picolisp
refrijerator has quit [Client Quit]
pierpal has quit [Quit: Poof]
pierpal has joined #picolisp
karswell_ has joined #picolisp
karswell has quit [Remote host closed the connection]
pierpal has quit [Quit: Poof]
pierpal has joined #picolisp
karswell_ has quit [Ping timeout: 268 seconds]
pierpal has quit [Quit: Poof]
pierpal has joined #picolisp
pierpal has quit [Quit: Poof]
pierpal has joined #picolisp
alexshendi has joined #picolisp
pierpal has quit [Quit: Poof]
pierpal has joined #picolisp
pierpal has quit [Quit: Poof]
pierpal has joined #picolisp
alexshendi has quit [Ping timeout: 265 seconds]