<geri>
what's the absolute minimum i should do to be able to connect to the interpreter with psh and still be able to do stuff in main interpreter?
<geri>
couldn't figure out how to run task with non-negative first arg
<geri>
and running the server every 10 seconds is a very bad solution
<abu[7]>
No, this does not work. 'server' cannot be called in a task. It is an infinite loop forking child processes.
<geri>
eh
<geri>
i mean i can connect to it, but its blocking main interpreter io
<abu[7]>
Try this:
<abu[7]>
In one terminal
<abu[7]>
$ ./pil lib/http.l -'server 8086' +
<abu[7]>
In the other
<abu[7]>
bin/psh 8086
<abu[7]>
But psh makes no sense by itself
<abu[7]>
It makes sense in a running *production* app
<abu[7]>
which you cannot stop because people are working on it
<geri>
psh exits instantly
<geri>
it does make sense, you just dont know how :)
<abu[7]>
You can just start a REPL
<geri>
one thing i love about cl is when i was writing my tetris i could just edit everything in real time form my editor
<geri>
i wanna pretty much do the real time redefinitions like yesterday but while terminal is busy with something else and you cant stop it (wait i just realized i dont need both to be available xd)
<geri>
but i need a server to run while something else is happening
<geri>
i guess i could use a task instead of while T but is it possible to have both vip and the while loop working at the same time
<geri>
maybe by pausing main loop while im in vip hmm
<abu[7]>
Yes. A task
<abu[7]>
(task -1000 0 (print-board) ...
<abu[7]>
and without (bye)
<geri>
actually that eats my inputs in repl
<abu[7]>
I would put a line NIL before the (bye)
<geri>
how do i pause the task quickly?
<abu[7]>
You can only stop it with (task -1000)
<geri>
i cant type fast enough for the task to not clear my repl inputs xd
<geri>
managed to ctrl-c out
<abu[7]>
I would put the body of the task into a function
<geri>
i did
<geri>
oh wait
<geri>
(clear) clears inputs as well?
<geri>
guess thats my problem haha
<abu[7]>
It clears only the screen I'd expect
<abu[7]>
Not stdin
<geri>
and now it doesn't clear until i send something to repl
<geri>
hmmmm
<geri>
it could be a weird interaction of printing and clear or something
<abu[7]>
It is only an escape sequence
<abu[7]>
You need (flush)
<abu[7]>
(clear) does not make much sense interactively I think
<geri>
okay, now i can run do-tick without crashing out of vip
<geri>
thats cool
<geri>
so you can't pause coroutines manually other than removing them from tasks?
<abu[7]>
Coroutines have nothing to do with tasks
<abu[7]>
A coroutine is paused with (yield)
<geri>
its so confusing
<abu[7]>
Vip yields with qz
<geri>
can tasks yield
<abu[7]>
No, they are not coroutines
<abu[7]>
they are multiplexed I/O handler
<abu[7]>
man select
<abu[7]>
or
<abu[7]>
man poll
<geri>
im dying lol
<abu[7]>
They run in the main (or some other) coroutine
<geri>
so main has to be a coroutine so i can pause it arbitrarily, not a task?
<abu[7]>
main runs automatically
<geri>
like my do-tick function
<abu[7]>
it is the "standard" coroutine
<abu[7]>
do-tick is called from a task?
<geri>
print board + (flush) approximately once a second
<geri>
yes
<abu[7]>
If you did not start other coroutines, it runs in main
<abu[7]>
A task waits for events
<abu[7]>
either I/O ready, or a timeout
<geri>
i honestly dont understand anything about coroutines at this point - i just want my do-tick to be run ~once a second and be pausable interactively
<abu[7]>
then executes the body
<geri>
the same way you can pause vip with qz
<abu[7]>
This is because vip starts its own coroutine
<abu[7]>
: (stack)
<abu[7]>
shows all coroutines
<abu[7]>
You can start a coroutine `a':
<abu[7]>
: (co 'a (let N 0 (loop (yield (inc 'N)))))
<abu[7]>
: (stack)
<abu[7]>
then call (co 'a T) repeatedly
<abu[7]>
'a' continues
<geri>
T stack is the default or stuff after a dot?
<geri>
((a . 63) (T . 251) . 64)
<abu[7]>
T is the main routine
<abu[7]>
(co 'a T) is different
<abu[7]>
(co 'a) stops the coroutine
<abu[7]>
(co 'a ...) starts or continues
<abu[7]>
you can also just repeat the original call (co 'a (let N 0 (l ... all the time
<geri>
that's nasty :D
<abu[7]>
A coroutine is like a function but with exits points where it can continue later
<geri>
yield is that exit point?
<abu[7]>
Yes
<geri>
okay, so i could make a coroutine out of dotick that lets me do something on some point during every iteration
<abu[7]>
Exactly
<geri>
and maybe call it like 1k times usign a loop if i wanna try fullspeed execution xd
<abu[7]>
What do you mean with "dotick"?
<geri>
just prints screen and runs flush
<geri>
do-tick
<geri>
prints board*
<abu[7]>
ok
<abu[7]>
Just to print the board a coroutine might be overkill
<abu[7]>
It makes sense if it needs to keep a state
<abu[7]>
like the 'N' in 'a'
<geri>
i want the main loop to be pausable if i wanna redefine what print-board does or whatnot
<geri>
🤧
<abu[7]>
Then I would not start the task at all during devel
<geri>
what if im in the middle of testing play logic
<geri>
then state of the board would be lost and that'd be a pain in the ass to develop
<geri>
rn its simple just for an example, its supposed to be proper chess eventually
<abu[7]>
You could redircect output to another terminal
<geri>
oh thats interesting
<abu[7]>
(out "/dev/pts/6" (prin...
<geri>
that could be nice yeah
alexshe40 has joined #picolisp
alexshe71 has joined #picolisp
alexshendi has quit [Ping timeout: 252 seconds]
alexshendi has joined #picolisp
alexshe40 has quit [Ping timeout: 272 seconds]
alexshe71 has quit [Ping timeout: 260 seconds]
alexshendi has quit [Read error: Connection reset by peer]
alexshendi has joined #picolisp
alexshendi has quit [Read error: Connection reset by peer]
alexshendi has joined #picolisp
alexshe91 has joined #picolisp
alexshendi has quit [Ping timeout: 245 seconds]
alexshe91 has quit [Ping timeout: 245 seconds]
alexshendi has joined #picolisp
alexshendi has quit [Read error: Connection reset by peer]
alexshe99 has joined #picolisp
alexshendi has joined #picolisp
alexshe99 has quit [Ping timeout: 245 seconds]
alexshendi has quit [Ping timeout: 240 seconds]
alexshe89 has joined #picolisp
alexshe89 has quit [Read error: Connection reset by peer]
alexshendi has joined #picolisp
alexshendi has quit [Read error: Connection reset by peer]
alexshe93 has joined #picolisp
<geri>
what's the difference between pil/vip in root and in bin/?
<geri>
or more like why are there two
<abu[7]>
Same as the two 'pil's - one for global installation (/usr/bin/) and one for local (relative) calls
<geri>
bin ones for global i guess?
<abu[7]>
Yes
<geri>
oki
<geri>
why does everything use pil as shebang except for vip? xd
<abu[7]>
You mean the one in bin/?
<abu[7]>
It is not the only one
<geri>
pil doesnt count
<abu[7]>
I use "#!/usr/bin/picolisp" whenever full pil is not needed
<abu[7]>
i.e. @ext.l
<geri>
i made a wrapper for that cause hardcoding shebang isnt my style
<abu[7]>
I repeat that your use of /usr/bin/env is not a good idea
<abu[7]>
Why such a big overhead?
<abu[7]>
Starting one more process
<abu[7]>
You destroy it
<abu[7]>
/usr/bin/picolisp starts up extremely fast
<geri>
its good if youre developing picolisp though
<abu[7]>
I forgot how termux does it
<geri>
something like that
<geri>
or just use env :)
<abu[7]>
Nooooo
<abu[7]>
Overhead for NOTHING
<geri>
not for nothing
<geri>
for peace of mind that itll work as long as your pil/picolisp is in path
<abu[7]>
If env is in usr/bin, pil can as well
<geri>
although having to hardcode default lib path does mess it up quite a bit
<geri>
fair point, but no B)
<geri>
if i have to install picolisp manually
<geri>
lets say i install it in my home directory
<geri>
i could still use env and not have to care where it actually is
<abu[7]>
So do I
<abu[7]>
Pil
<geri>
(if we ignore hardcoded shebangs in like every file in bin)
<abu[7]>
You don't need
<geri>
also really go check out /usr/bin/pil vs /usr/bin/env pil performance
<geri>
cause its not really noticable
<abu[7]>
As I said, /usr/bin works also on Termux
<abu[7]>
despite there is no /usr
<geri>
wait
<geri>
what
<geri>
xd
<geri>
did you install shebang patcher plugin thing
<abu[7]>
I have all newer script with just /usr
<abu[7]>
I forgot how it works
<geri>
\/usr shouldnt even be user writable on android
<abu[7]>
read about it onces
<abu[7]>
once
<abu[7]>
There is no /usr
<abu[7]>
and / is not acccessible
<abu[7]>
Still it works :)
<geri>
thats very bizzare
<abu[7]>
In any case, /usr/bin/env also does not exist on Termux
<abu[7]>
So useless here
<abu[7]>
/usr/bin/pil +
<abu[7]>
works on Termux
<geri>
ah wait
<geri>
it probably just prepends /data/data/com.termux/files to actual shebang
<abu[7]>
No
<geri>
/data/data/com.termux/files/usr/bin/env is where env is
<geri>
/usr/bin/env is how you call it
<abu[7]>
It is ../usr/bin/pil
<geri>
im talking about env rn
<abu[7]>
ok
<geri>
if you install pil with pkg its in the same path
<geri>
do `command -v pil'
<abu[7]>
this is of course in $PATH
<abu[7]>
But #!/usr/bin/xxx works
<geri>
obvious, question is where it is
<geri>
exactly
<abu[7]>
or /usr/bin/xxx in the shell
<abu[7]>
So it fixes any path
<abu[7]>
I'm walking in the fields, can't search how they do it
<abu[7]>
What do you do with env if you want to pass an argument? I have
<abu[7]>
#!/usr/bin/pil ~/pil21/lib/repo.l
<abu[7]>
Unix allows only one single arg
<geri>
that makes little sense to do - you can just (load "~/pil21/lib/repo.l")
<geri>
but picolisp binary is a different story
<geri>
it trips me up honestly
<abu[7]>
Calling 'load' is differently
<geri>
with pil it should be same no?
<abu[7]>
A hasbang script has it as comment
<geri>
different for picolisp binary
<abu[7]>
You can call all pil scripts also directly
<abu[7]>
and then we don't call 'load'
<abu[7]>
So we have some control via the hashbang line
<geri>
with env, factorial 10 takes from ~0m0.012s to ~0m0.024s, with hardcoded path its from 0m0.011s to 0m0.021s
<abu[7]>
I'm talking about startup time
<abu[7]>
not recursive multiplication :)
<abu[7]>
$ time pil21/bin/picolisp -bye
<geri>
everything except for startup time should be equal
<geri>
ok
<geri>
0m0.007s to 0m0.020s for non-shebang lmao
<abu[7]>
$ time /usr/bin/picolisp -bye
<abu[7]>
real 0m0.002s
<geri>
i was testing pil but okay
<geri>
also i re-ran the thing about 20 times to get the popular values
<abu[7]>
Yeah, ok, pil is also very heavy
<abu[7]>
loads lots of stuff
<geri>
thats why i made my own wrapper :D
<abu[7]>
Originally I used only /usr/bin/picolisp for scripts
<abu[7]>
never pil
<abu[7]>
as it has unnecessary overhead
<geri>
minimum for picolisp -bye with hardcoded path is 0m0.004s, for env its 0m0.005s
<abu[7]>
ok
<abu[7]>
Yeah, academic discussion ;)
<geri>
you could say "25% more time!" but honestly its inconsequential
<geri>
yeah pretty much
<abu[7]>
Still I hate the thought of using env
<abu[7]>
replacing one path with another
<geri>
well you havent used it for like 30+ years
<abu[7]>
assumptions
<abu[7]>
T
<abu[7]>
And I see absolutely no benefit
<geri>
to each their own
<geri>
i couldnt figure out how to write a factorial for like 5 minutes cause i put arguments for < in wrong order
<geri>
xd
<abu[7]>
☺
<abu[7]>
I always use =0 in fact iirc
<geri>
what should a negative factorial return
<abu[7]>
Would crash :)
<geri>
well, for me itd return 1, although thats not accurate either
<abu[7]>
Makes sense
<abu[7]>
Then (if (le0 N) 1 ... is best
<geri>
why le0 and not <0
<geri>
🤧
<abu[7]>
<0 does not fit the syntax
<abu[7]>
(<0 N) is *not* (< 0 N)
<abu[7]>
'le0' is fact has also the advantage of catching non-numeric args
<abu[7]>
e.g. NIL
<geri>
id say it fits syntax mroe than lt0 because you have <=, <> and < functions already and you dont have lt function
<abu[7]>
<= etc keep the arguonent order
<geri>
its more about the function name than logic
<abu[7]>
We have prefix notation
<abu[7]>
In FORT <0 makes sense
<abu[7]>
-3 <0 .
<abu[7]>
FORTH I mean
<geri>
castle, i got it
<geri>
)
<geri>
lt0 == <0
<geri>
just different style
<geri>
so if (lt0 X) makes sense, (<0 X) should be no different
<geri>
and id argue that itd be more consistent with syntax cause of existance of <= <>
<geri>
more of a taste thing really
<abu[7]>
(< 0 X) is (gt0)
<abu[7]>
(< 0 X) is (gt0 X)
<geri>
(def '<0 'lt0)
<abu[7]>
no, (def '<0 'gt0)
<abu[7]>
So it feels wrong
<abu[7]>
In prefix, you move the operator to the front
<geri>
< is read as "less than"
<geri>
or lt
<abu[7]>
(- 7 3) is 7-3
<abu[7]>
So (< 0 N) is 0 < N
<abu[7]>
which is (gt0 N)
<geri>
and lt0 is..?
<abu[7]>
(< N 0) or (> 0 N)
<abu[7]>
I usually avoid <
<abu[7]>
it is easily confused with "("
<abu[7]>
(< 3 7)
<geri>
why would anyone make a <0 function mean (< 0 X)
<geri>
XD
<abu[7]>
I always use (> 7 3)
<geri>
thats absolutely useless
<geri>
just add that one space
<abu[7]>
Prefix notation
<abu[7]>
the operator moves!
<abu[7]>
(- 7 3) is 7 - 3
<abu[7]>
(> X Y) is X > Y
<geri>
anyway
<geri>
im saying switch arguments around so it makes more sense practically, but i guess its a little less coherent if you look at stuff the way you do
<abu[7]>
(<0 X) must mean (< 0 X)
<geri>
who said so? :)
<abu[7]>
The prefix operator rules
<abu[7]>
Sigh
<abu[7]>
moving the operator to front
<geri>
imo it shouldnt because theres no reason for <0 to exist this way - just add a space between the characters and theres literally no reason for <0 to exist as a function
<geri>
but if you switch arguments around it has meaning of "check if argument is less than 0"
<abu[7]>
Yes, but then it means gt0
<geri>
(define-source-transform 1- (x) `(- ,x 1))
<geri>
1- in CL
<geri>
you just switch em around and you got an actually useful function
<geri>
anyway, that really doesnt matter
<geri>
xd
<abu[7]>
Same thing, that's why it is 'inc' and 'dec' in Pil
<abu[7]>
1- subtracts the opposite
<abu[7]>
Again, in FORTh 1- is good
<abu[7]>
postfix notation
<geri>
1- just subtracts 1 from whatever you pass it
<abu[7]>
7 1- is 7-1
<geri>
its just a function name
<geri>
it doesnt have to care about prefix notation at all
<geri>
just a name
<abu[7]>
Function names should reflect the meaning
<geri>
yes!
<geri>
you decrease argument by 1!
<geri>
i guess you take the meaning as "subtract argument from 1"
<abu[7]>
1- does not mean "decrease"
<abu[7]>
it subtracts
<abu[7]>
So pil uses 'dec'
<geri>
that's fair
<abu[7]>
(1- X) reads as 1 - X
<abu[7]>
but it is X - 1
<abu[7]>
So not good )
<geri>
thats not the way youre supposed to read it
<geri>
btw
<geri>
how is lt0 any better?
<geri>
if you had < be called lt instead your logic would apply again
<abu[7]>
It is a function name, like dec
<geri>
and it reads improperly yet again
<geri>
everything is a symbol though
<geri>
so everything is a function name
<abu[7]>
it has a meaning independent from the math operator
<geri>
(except variables)
<abu[7]>
Math operators are special
<abu[7]>
tfney have a order
<geri>
m?
<geri>
every function has an order...
<abu[7]>
To humans
<abu[7]>
7 - 1
<geri>
do you think humans read lisp? :D
<abu[7]>
I give up
<geri>
xd
<geri>
do you use vip for non-picolisp stuff?
<abu[7]>
Yes, it is my system editor
<abu[7]>
and
<abu[7]>
pager
<geri>
:D
<geri>
i used to use vimpager
<geri>
way nicer than less cause got my proper colors and syntax highlighting
<geri>
although now i just use less again
<abu[7]>
Only if I know it is not UTF-8 or very big I use Vim
<geri>
vip cant handle huge files?
<abu[7]>
One nice feature of Vip is the return value
<abu[7]>
:x returns true, :q returns false
<abu[7]>
So I often have in my bash history things like
<abu[7]>
$ vi version.l && ./release
<abu[7]>
I can abort easily
<geri>
is wq true too?
<abu[7]>
Vim always returns true
<abu[7]>
There is no wq in pil
<geri>
damn
<abu[7]>
only w and q separate :)
<geri>
and x!
<geri>
i tend to use :x
<abu[7]>
No checks, so ! is not needed
<abu[7]>
Yes, me too
<geri>
! is a separate token, not part of the command
<geri>
:D
<abu[7]>
In Vim? Yes, it forces
<abu[7]>
a write or a quit
<abu[7]>
Vi
<abu[7]>
oops
<abu[7]>
damned new k
<abu[7]>
eyboard
<geri>
what's the new kb btw
<abu[7]>
StenoBoard
<geri>
and x! == exclaiming "and x"
<geri>
it guesses stuff from syllables?
abu[7] has left #picolisp [#picolisp]
abu[7] has joined #picolisp
<abu[7]>
Hit ^D
<abu[7]>
☺
<abu[7]>
What did you mean with x! exclaiming?
<abu[7]>
In Vim?
<geri>
you can question stuff
<geri>
and you can exclaim stuff
<geri>
that ! is linguistic, its not attached to x
<abu[7]>
ok
<geri>
its cool you dont need to add the ! to commands though
<geri>
wait, is q always a force quit?
<abu[7]>
Correct
<abu[7]>
Even if dirty
<abu[7]>
Vip never complains like Vim
<geri>
thing i hate is when i do :q when i forgot i made some tiny little change and now i need to shut the warning message up and then type :q! again
<abu[7]>
Me too
<abu[7]>
But I was also too lazy to do all the checks ;)
<geri>
long as it doesnt crash
<abu[7]>
Vip crashet if the file is not writable
<abu[7]>
Vip crashes if the file is not writable :D
<abu[7]>
D
<geri>
XD
<abu[7]>
Not a hard crash
<abu[7]>
but a pil error
<geri>
"/root/hello.txt" -- Open error: Permission denied
<geri>
not as horrible as i thought
<abu[7]>
ok :)
<geri>
if the whole interpreter were to come crashing down that'd be hilarious
<abu[7]>
Main limitation of Vip is that it can do only utf8
<abu[7]>
And very big files get rather slow
<abu[7]>
because Vip keeps a list of lists of chars
<abu[7]>
So for editing an mbox file I sometimes use Vim
<geri>
oofies
<geri>
emacs pretty much freezes if you have a file with a single 160k character line
<geri>
:)
<abu[7]>
Perhaps Vip too, I did not try
<abu[7]>
Z
<abu[7]>
For long lines a large (stack) is recommended
<abu[7]>
bin/vip calls (stack 1024)
<abu[7]>
Because it runs as a coroutine it segments the system stack
<abu[7]>
And searches recurse sometimes a lot
<abu[7]>
IIRC 'match' searches with "@"
<geri>
time to rip out all syntax highlighting and indentation and everything else 👽
<geri>
for speed
<abu[7]>
Perhaps
<abu[7]>
The 'markup' function may take the time
<abu[7]>
The slowness is mostly initially when loading the file the first time
<abu[7]>
Probably heap allocation by repeated 'gc' calls
<abu[7]>
I can live with that
<abu[7]>
The largest file in the distro is src/base.ll
<abu[7]>
Only 110896 lines currently
<abu[7]>
It behaves sluggishly in Vip
<geri>
does it feel slower than anything else?
<geri>
aw
<abu[7]>
It does
<abu[7]>
But base.ll is not edited manually
<geri>
can you get the same base.ll using previous git checkout/snapshot of the repository?
<abu[7]>
Not sure, I don't use git
<geri>
you do incremental backups
<geri>
i meant snapshit in this way
<geri>
snapshot* xd
<abu[7]>
Ah, yes
<geri>
i wonder if it'd be 100% the same or not
<abu[7]>
base.ll is 100% reproducible
<abu[7]>
I 'diff' it when making changes to @src/lib/llvm.l
<geri>
that's great
<geri>
very good
<geri>
okay, im gonna do some stuff and sleep
<geri>
good luck with new keyboard
<abu[7]>
Good! Sleep well!
geri has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.3)]