bjorkintosh has quit [Ping timeout: 276 seconds]
z4k4ri4 has quit [Ping timeout: 272 seconds]
z4k4ri4 has joined #picolisp
rob_w has joined #picolisp
rob_w has quit [Quit: Leaving]
rob_w has joined #picolisp
<
aw->
quick question: how to get the value of a value being tested with '= ?
<
aw->
(= 'test *MyVar) returns T
<
aw->
but I want it to return 'test
<
abu[7]>
Yes, = does not set '@'
<
abu[7]>
You need to keep the value, eg. with 'let'
<
abu[7]>
But in this cate you know it is 'test :)
<
abu[7]>
(let V (foo) (and (= V (bar)) (laber V)))
<
abu[7]>
= cannot employ @
<
abu[7]>
or, more correct
<
abu[7]>
= cannot return the value
<
abu[7]>
because (= NIL NIL) should return non-NIL
f[x] has joined #picolisp
geri has joined #picolisp
rob_w has quit [Quit: Leaving]
rob_w has joined #picolisp
<
geri>
hey, is there a way to exit (while) at an arbitrary point without using (catch)?
<
geri>
i think i have some weird bug because of it
<
abu[7]>
No, only throw or an error
<
geri>
i guess ill do a boolean flag then
<
abu[7]>
Or use 'do', 'loop' or 'for'
<
geri>
maybe loop, but gotta think about how im gonna organize code then
<
abu[7]>
Yeah, transforming while to loop is quite straightforward
<
abu[7]>
(while (foo) (bar)) -> (loop (NIL (foo)) (bar))
<
geri>
whats the difference between nil and t here
<
abu[7]>
nil and t are functions (?)
<
geri>
im too lazy to capitalize
<
geri>
i meant in car of clauses
<
abu[7]>
(loop (T (not (foo))) (bar))
<
geri>
T inverts the condition?
<
geri>
T is "if condition is true" and NIL "if condition is false"?
<
abu[7]>
yes, then exit
<
geri>
okay yeah it was a catch error
<
geri>
remind me to only use it for error handling
<
abu[7]>
Wrong tag?
<
geri>
i was using throw/catch to exit a loop
<
geri>
and for some reason io was acting weird
<
geri>
like, i had read the symbol but its still in the fd
<
abu[7]>
catch/throw is needed to exit a nested loop
<
geri>
ill save buggy code and send it later
<
abu[7]>
ok but a little expensive
<
abu[7]>
catch / throw
<
geri>
man's gotta do what he's gotta do and all
<
geri>
how does it work internally?
<
abu[7]>
It saves and restores environments
<
geri>
like with (env) and (bind)?
<
abu[7]>
bindings, files
<
abu[7]>
llvm~unwind
<
geri>
can it save stdio? 🤔
<
abu[7]>
Save in which sense?
<
geri>
like, in a file you could maybe save its position or the pointer to it or whatever
<
geri>
but stdio is constantly moving
<
geri>
maybe im not understanding what you meant by saving and restoring files
<
abu[7]>
Not the data
<
abu[7]>
(catch 'a (in "b" (throw 'a
<
abu[7]>
"b" is closed
<
geri>
shouldn't it be the opposite?
<
geri>
(in "b" (catch 'a (... (throw 'a ...))))
<
abu[7]>
Then throw does not close
<
abu[7]>
throw may be deeply nested
<
geri>
is the position in file changed if in ... points im doing smth like line?
<
abu[7]>
All open channels since the corretponding catch are just closed
<
abu[7]>
*need* to be
<
abu[7]>
Else the FDs would dan
<
abu[7]>
(vi 'llvm~unwind)
<
abu[7]>
Called by throw and other occasions
<
abu[7]>
(vi 'throw)
<
geri>
(btw if im vi'd into a file already, how do i edit another one?)
<
geri>
:e llvm~unwind didnt work i think
<
abu[7]>
or click on it
<
geri>
okay it was tag
<
geri>
what was it's opposite?
<
geri>
or there isnt one
<
abu[7]>
^] and ^T are from VI
<
abu[7]>
K and Q are easier
<
geri>
K works in vim i think
<
geri>
idk what it does though, im using it in evil mode in emacs
<
geri>
there its for documentation
<
abu[7]>
IIRC "K" is free in vim, I set it in .vimrc
<
abu[7]>
Maybe I redefined it
<
geri>
im installing vim in a container just to check it
<
geri>
podman is nice to have time to time
<
geri>
K seems to run man with whatever's under the cursor
<
geri>
im using throw to get out of deeply nested recursion
<
geri>
just as the creator willed it :)
<
geri>
how do i catch eof overrun
<
geri>
is that the label name? "EOF Overrun"
<
abu[7]>
Yes, "EOF Overrun"
<
abu[7]>
afk a little, we have Pizza :)
<
geri>
also-also, is there a convention for writing macros with ` and ~?
geri` has joined #picolisp
<
geri`>
i was like "my pc seems to be struggling" and i actually forgot it was unplugged
geri has quit [Ping timeout: 252 seconds]
geri` is now known as geri
<
geri>
does inlining functions with `~ do anything for performance?
<
geri>
like, the full function is executed, but you inline it within another function
<
geri>
cause 1 less function call :D
<
abu[7]>
one fun call overhead
<
geri>
but you get to eval an extra NIL if you do ~ with a normal function without args
<
geri>
so probably very a little
<
geri>
i think i fell in love with IO in picolisp btw
<
abu[7]>
but fun calls are expensive
<
abu[7]>
(vi 'llvm~evExpr)
<
geri>
hows it different from evlist
<
abu[7]>
evList evaluates a list
<
abu[7]>
ewExpr does the lambda stuff
<
abu[7]>
binding etc
<
geri>
ah, youre calling evexpr in evlist
<
abu[7]>
So you probably know, it starts at 'llvm~eval
<
abu[7]>
*the* eval
<
geri>
inline eval :D
<
geri>
what does use @ do in that one
<
abu[7]>
evList is a bit involved, as it also handles cases like ((getFun) arg)
<
abu[7]>
'use' preserves it
<
abu[7]>
Compile time, not runtime
<
abu[7]>
'@' in the compiler
<
geri>
like it makes a new binding so when you're popping out of use its back to prev value?
<
abu[7]>
in List it is same
<
abu[7]>
(use X (setq X
<
abu[7]>
same as (let X
<
geri>
i remember you said use is "the main thing"
<
geri>
i guess im actually getting it now
<
abu[7]>
Yes. First PicoLisps had only 'use'
<
abu[7]>
It was called 'local' back then
<
abu[7]>
'@' was not durinp the first years I would say
<
geri>
and setting @ is pretty lovely
<
abu[7]>
yes, extremely convenient
<
geri>
what's the fastest way to append a single symbol to alist?
<
geri>
rn using append
<
geri>
s/alist/a list/
<
abu[7]>
Perhaps 'queue'
<
abu[7]>
(unless you don't start with 'make')
<
geri>
(append (chop Str) '(" "))
<
geri>
with queue i guess id need to let Str first
<
abu[7]>
'conc' is a lot faster than 'append'
<
geri>
actually i can queue to unchopped symbols
<
abu[7]>
but destructive
<
geri>
thats fine in this case
<
abu[7]>
yes, if Str it "fresh"
<
geri>
i can conc symbols as well
<
abu[7]>
only to a cell
<
geri>
and it doesnt seem to affect original, probably cause chop
<
abu[7]>
chop maket a fresh list
<
geri>
yeah the result is a list of symbols so i need its car
<
geri>
wait actually it didnt work :thinking:
<
abu[7]>
(conc (chop Str) (list "a"))
<
abu[7]>
(setq Str (conc (chop Str) (list "a")))
<
geri>
i think it works
<
geri>
wait so append clones very link??
<
abu[7]>
copies all cells of the first arg list
<
abu[7]>
then 'conc's the second arg
<
geri>
is there a way to (read) but not convert in the end and just return a list of characters?
<
geri>
honestly doubt, asking just in case cause theres a builtin for everything
<
abu[7]>
Something like (till) ?
<
abu[7]>
ie (till NIL NIL)
<
abu[7]>
the whole file as a list of chars
<
geri>
btw i also found out json.l can parse "{a: b}"
<
geri>
idk how i feel about it honestly :D
<
geri>
pretty simple though
<
geri>
what's an escape symbol for linefeed
<
abu[7]>
Shall I change to 'name',
<
geri>
i had the fix in the file i sent like yesterday
<
geri>
probably gone now
<
geri>
in atom case you wanna do (pack "\"" (name @) "\"")
<
abu[7]>
No problem, let me try
<
geri>
and in T case just replace sym with name
<
geri>
is there a find function but not higher order but just finds element in a list?
<
abu[7]>
'member', 'memq' etc
<
geri>
im literally using those
rob_w has quit [Remote host closed the connection]
<
geri>
i was talking about packJson :D
<
geri>
parse just checks if its correct?
<
abu[7]>
but we had parse
<
geri>
or its like read from string
<
abu[7]>
no, it builds a list
<
abu[7]>
'sym' was not good
<
abu[7]>
wrong paste
<
abu[7]>
I've not tested at all :)
<
geri>
breaks on '((1 . b)) but imo that's a good thing as its not valid json
<
abu[7]>
good indeed
<
geri>
oh wait, it actually cant pack numbers at all
<
geri>
also null true and false, but let's ignore that for now
<
geri>
give me like 10 minutes and ill drop some very bad code
<
abu[7]>
Then let's keep 'sym'
<
geri>
reasonable enough
<
abu[7]>
That's why I used sym
<
geri>
also its less accurate but you could just use (recurse (caar X)) in key of object
<
abu[7]>
I think I have no use case for packJson anyway
<
geri>
imo you only need read and parse json and others you implement with input & print
<
geri>
gonna be half amount of code
<
abu[7]>
I'll revert the change
<
abu[7]>
No problem
<
abu[7]>
There is no "perfect" Pil <-> Json
<
geri>
its only 110 lines as is xd
<
geri>
abu[7]: 10 minutes...
<
geri>
well, like 5 now
<
geri>
demo effect already kicking in...
<
geri>
here's my piece of crap code
<
geri>
i think this is the most accurate schema we have
<
abu[7]>
Looks good at the first sight
<
geri>
i had to encode floats in a cons cells, same with arrays and objects
<
geri>
but full type info is saved so that's nice
<
geri>
NIL is empty string, empty array/object is (cons 'array/object NIL)
<
abu[7]>
I don't want to complicate the distro, but you could publish it in the mailing list on in the Wiki
<
geri>
ye i dont expect it to get any use lol
<
abu[7]>
*or in the ...
<
geri>
btw i tested with my swaymsg -rt and it works
<
abu[7]>
Me neither :)
<
geri>
then you owe me pack/read cleanup in json.l :D
<
geri>
its so cool that i can just use (input) and not care if im reading from stdin or a string
<
abu[7]>
replace packJson with printJson via 'output'?
<
geri>
replace printJson with packJson + print, unless you're doing something fancy there
<
abu[7]>
packJson + print is overhead
<
geri>
rewriting same function 3 times is also overhead
<
geri>
maintainability wise
<
abu[7]>
Yeah, but producing huge garbage strings is not a good idea
<
abu[7]>
We should throw out packJson
<
geri>
print + output then?
<
geri>
(i hadnt used output though, idk)
<
abu[7]>
as we now can print into a char list
<
abu[7]>
Lel's keep it as it is now, I don't want to break anything
<
geri>
how do you print into a char list
<
geri>
except something like pipe print + till
<
abu[7]>
(pack (make (output (link @@) (println 1 5 3) (print 'abc))))
<
geri>
so that could be new pack
<
geri>
aight gotta sleep
<
abu[7]>
Good night! o/
geri has quit [Remote host closed the connection]
geri has joined #picolisp
chexum has joined #picolisp
chexum_ has quit [Ping timeout: 260 seconds]
beneroth has quit [Remote host closed the connection]
beneroth has joined #picolisp