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