beneroth changed the topic of #picolisp to: PicoLisp language | The scalpel of software development | Channel Log: https://libera.irclog.whitequark.org/picolisp | Check www.picolisp.com for more information
clacke has joined #picolisp
bjorkintosh has quit [Remote host closed the connection]
bjorkintosh has joined #picolisp
bjorkintosh has quit [Changing host]
bjorkintosh has joined #picolisp
bjorkintosh has quit [Remote host closed the connection]
bjorkintosh has joined #picolisp
bjorkintosh has quit [Changing host]
bjorkintosh has joined #picolisp
bjorkintosh has quit [Ping timeout: 268 seconds]
bjorkint0sh has joined #picolisp
bjorkint0sh has quit [Remote host closed the connection]
bjorkint0sh has joined #picolisp
msavoritias has joined #picolisp
clacke has quit [Remote host closed the connection]
<tankf33der> hi all
<tankf33der> pull request on github mirror :)
<tankf33der> 5 min ago
<abu[7]> Interesting! The first one?
<tankf33der> yea
<abu[7]> Hmm, I would not load @lib/http.l implicitly
<tankf33der> i can reply
<abu[7]> Good, thanks!
<abu[7]> We have libs @lib.l -> @lib/net.l -> @lib/misc.l -> @lib/http.l -> @lib/xhtml.l -> @lib/form.l
<abu[7]> I would not load them all
<tankf33der> done
<abu[7]> A program might load only @lib/http.l and load @lib/xhtml.l etc. dynamically when needed
<abu[7]> But in general positive if people supply ideas :)
iacore has joined #picolisp
<iacore> hello
<tankf33der> iacore: hi
<tankf33der> abu[7]: this is github user with request
<tankf33der> afk.
<iacore> hi
<iacore> i'm learning picolisp
<abu[7]> Cheers iacore!
<iacore> i'm still figuring out how does (function . symbol) work
<iacore> it's strange, because the symbol itself is passed in
<abu[7]> For example?
<iacore> how do i paste code block in IRC
<abu[7]> Works only for short code
<tankf33der> pb1n.de
<tankf33der> written on picolisp
<iacore> If I do (print-concepts . xs0) , i get the symbol xs0
<abu[7]> Semicolon is not a comment
<iacore> what
<abu[7]> It is # :)
<iacore> fixed it :)
<abu[7]> Arguments are only evaluated if they are list elements, not in the CDR of the last cell
<abu[7]> So xs0 is ignored in (print-concepts . xs0)
<iacore> example: (setq xs0 (box)) (de print-concepts Xs (println Xs)) (print-concepts . xs0)
<iacore> (print-concepts xs0) also pass the symbol in
<iacore> who decides what here
<abu[7]> xs0 is two anonymous symbmls, ok
<iacore> is there a section in the manual that i can read > Arguments are only evaluated if they are list elements, not in the CDR of the last cell
<abu[7]> Not sure if thie is mentioned in ref.html
<abu[7]> in "Evaluation" ?
<iacore> why does picolisp have two domains (software-lab.de and picolisp.com)
<abu[7]> Software-Lab is the company
<abu[7]> probably historical reasons
<abu[7]> I'm not sure I understood your question above
<iacore> it's a bit confusing
<iacore> i also hope the documentation has a search bar like https://nim-works.github.io/nimskull/hashes.html, since i find myself looking up symbols a lot
<abu[7]> Best is to do (doc 'foo) in the repl
<abu[7]> or (vi 'foo)
<iacore> (vi 'doc) opened an editor
<iacore> i don't think it's vi
<iacore> how do i make it another editor
<abu[7]> It is Vip
<abu[7]> You can use any editor, but only Vip knows everything about Pil
<iacore> how do i use any editor
<abu[7]> It is deeply integrated
<iacore> vip doesn't know arrow keys in my terminal, at least
<abu[7]> It should know
<abu[7]> Normal is j k l h etc.
<abu[7]> Arrows scroll in the four directions
<iacore> when i press the arrow keys in edit/insert mode, it just insert a [
<abu[7]> Hmm, what terminal is it?
<abu[7]> Ah!
<abu[7]> Vi movement work only in command mode of course
<abu[7]> otherwise it inserts ;)
<abu[7]> Arrow keys are escape sequences
<abu[7]> : (pack (make (link (key)) (while (key 80) (link @))))
<abu[7]> -> "^[[A"
<abu[7]> This is up arrow
<abu[7]> so it does ESC and then [ and A
<iacore> no way to make (vi 'sym) open another editor?
<abu[7]> I never use arrow keys, so I did not think about it
<abu[7]> There is in fact
<abu[7]> Older versions of PicoLisp used Vim
<abu[7]> But very limited
<abu[7]> Other editors may open the source, but then don't know the context
<abu[7]> e.g. to click on other symbols
<abu[7]> They have no idea of what namespace is active, and dynamically loaded symbols in the running process
<iacore> how do i turn "name" into 'name
<abu[7]> (intern "name")
<iacore> there is ,"read". can i add other reader macro, or change how it works?
<iacore> my application has an internal dictionary of words, which i hope ,"invalid_word" will print an error
<abu[7]> Yes, e.g. (vi 'llvm~read0)
<abu[7]> But you can call any function in a normal read-macro
<abu[7]> The comma above puts the symbol "read" into *Uni
<abu[7]> is that what you mean here?
<abu[7]> Normal read-macros are `(foo "invalid_word")
<iacore> woah
<iacore> I think ,"word" is used for translation
<iacore> so it does expand to something else
<iacore> I think I'll just use symbols for now
<abu[7]> Yes, for translation. But it does not expand. The *value* is set to the translated word
<abu[7]> (prinl ,"foo")
<abu[7]> so in the code is (prinl "foo")
<abu[7]> But it evaluates "foo" and prints "bar")
<iacore> and all "foo" now evaluates to "bar"
<abu[7]> yes, but not all "foo", only exactly this one symbol
<abu[7]> The comma also looks it up in *Uni
<abu[7]> *Uni is a kind of special namespace
<iacore> if i use "foo" in the same source file it evaluates to "bar"
<iacore> that's still too confusing
<abu[7]> "foo" is a transient symbol
<abu[7]> Transient symbols have a file-local scope
<abu[7]> Like static symbols in C
<abu[7]> ,"foo" is a symbol with global scope
<abu[7]> it uses the same transient symbol "foo" everywhere
<abu[7]> s/uses/specifies
<iacore> how do i get the symbol's pointer value as integer
<abu[7]> This can be done with 'adr'
<iacore> (adr ,'"foo") (adr ,"foo") (adr "foo") are all different
<iacore> they are all transient symbols
<iacore> this is confusing
<abu[7]> ,'"foo" is a cons pair
<abu[7]> And (== "foo" ,"foo") is NIL because the comma puts it into that special namespace
<abu[7]> It is non-NIL only the first time
<abu[7]> when it is inserted into *Uni the first time
<abu[7]> hmm, no, not even then
<iacore> ,1 is valid
<iacore> what is , doing
<iacore> it seems to use structural equality
<iacore> ,'(1 2) ,(1 2) ,'(a 2) ,(a 2) # invalid
<abu[7]> Yes, any s-expression may follow the comma
<abu[7]> It is stored in *Uni, and thus made unique
<abu[7]> Localization is a higher-level usa case of that feature
<abu[7]> The pil kernel does not know about it
<abu[7]> So it uses pointer-equality
<abu[7]> The exactly same cell
<abu[7]> or number
<abu[7]> (as a symbol is also a cell ;)
<iacore> so i should do ',(a 2)
<iacore> to quote a unique symbol
<abu[7]> right :)
<abu[7]> No harm though
<iacore> if i want to have a type of symbol that's not a string, what should i do
<iacore> or, how do i tell apart ,"word" and "word" (both transient)
<abu[7]> To be exact, there are no strings in Pil
<abu[7]> only symbols
<abu[7]> Yes, both transient
<abu[7]> just that the first one is kept unique via *Uni
<iacore> my application does require me to tell apart both types
<abu[7]> To tell them apart: (idx '*Uni "foo")
<abu[7]> Or call '=='
<abu[7]> They are not different types
<abu[7]> just different symbols
<abu[7]> So if you have a symbol and want to know if it is in *Uni, use the above 'idx' call
<iacore> how do i use 'assert
<abu[7]> (doc 'assert) ?
<abu[7]> (help 'assert) ?
<abu[7]> Better (help 'assert T)
<iacore> (help 'assert T) is slower than I expected
<iacore> i think i know everything i need to know about picolisp right now
<abu[7]> Great ☺
<abu[7]> Hi! :)
<abu[7]> Did you change nick?
<abu[7]> I mean, have we talked before?
<abu[7]> oops
<abu[7]> AH!
<abu[7]> Sorry, wrong channel
iacore has quit [Quit: Leaving]
iacore has joined #picolisp
<iacore> ~(assert T) cannot appear at top level. (prog ~(assert T)) is fine.
<abu[7]> Yes. The tilde splices the result into the current list
<abu[7]> At the top level there is no list
<iacore> what if the entire program is an implicit list
<abu[7]> You mean all top-level? Then you don't need riead-macros
<iacore> if every *.l file is an implicit list, then ~(assert T) can be used at the top-level of the file
<abu[7]> Makes no sense. Building a list is unnecessay overhead, and a read-macro makes no sense ih it is evaluated only once anyway
<abu[7]> Like assert, you can write the check directly
<abu[7]> The purpos of a read-macro *is* to put the result into the currently built list
<iacore> does (prog ~(assert T)) build the list (prog X) before evaluating it?
<abu[7]> No list -> no read-macro ;)
<abu[7]> yes
<abu[7]> read-eval-print
<abu[7]> print only in repl
<abu[7]> so the interpreter goes read-eval
<abu[7]> always
<iacore> so it goes like, read-eval first s-exp in source file, read-eval seconds-exp in source file, ... so on
<abu[7]> Yes, exactly
<iacore> then, I assume there are cases where top-level A (de ...) behaves differently from '(A (de ...)) (in a list)
<iacore> example: (de r ...) `(r ...)
<iacore> yes, it behaves differently
<abu[7]> Behaves identically
<iacore> (de r (X) NIL) `(r) is valid
<iacore> (list (de r (X) NIL) `(r)) is error
<iacore> that's interesting
<abu[7]> Just keep in mind that read-macros are evaluated at read time
<abu[7]> The reader evaluates the expression
<abu[7]> OK, I'm out now. bbl
<abu[7]> I'll check here from time to time
<iacore> :+1:
iacore has quit [Quit: Leaving]
iacore has joined #picolisp
<iacore> how do i do term rewriting
<iacore> goal is to have (rewrite (list (cons 'X 1) (cons 'Y 2)) (list 'X 'Y)) be (list 1 2)
<abu[7]> There is 'patch'
<iacore> i think i should use eval here
<iacore> temporarily set the symbols value, then eval
iacore has quit [Remote host closed the connection]
iacore has joined #picolisp
<abu[7]> Not sure what you want to do
<iacore> term rewriting
<iacore> there is 'replace but i need a recursive one
<abu[7]> Thgs is the core of Lisp
<abu[7]> yes, as I said, (vi 'patch)
<abu[7]> (doc 'patch)
<abu[7]> s/Thgs/This
<abu[7]> Modifying lists is the core of Lisp
<abu[7]> There are many ways
<abu[7]> Using 'fill', or low level 'list' and 'cons'
<abu[7]> btw, in your 'print-concepts' the 'mapcar' is probably not right
<abu[7]> It builds a list
<abu[7]> 'mapc' is better
<abu[7]> Or simply a 'for' loop
<iacore> can i do a deep copy of a list
iacore has quit [Remote host closed the connection]
<abu[7]> Iterating a single list is shorter and faster with 'for'
iacore has joined #picolisp
<abu[7]> iacore: You know you can read the log of this channel at https://libera.irclog.whitequark.org/picolisp ?
<abu[7]> I also wrote something for your request concerning xhtml.l
<abu[7]> Anu no, there is no deep copy built-in
<abu[7]> Very seldom needed
<abu[7]> In fact I *never* needed it
<abu[7]> But it is easy:
<abu[7]> : (let L (1 (2 . 3) 4) (recur (L) (if (atom L) L (cons (recurse (car L)) (recurse (cdr L))]
<abu[7]> -> (1 (2 . 3) 4)
<abu[7]> If you need only 2 levels:
<abu[7]> (mapcar copy L)
<abu[7]> 'copy' is just one level
<iacore> is there a function like JS fetch
<abu[7]> What does it do?
<iacore> it's curl
<iacore> abu[7]: No. I do not know i can search the log.
<iacore> (= (fetch URL) PageContent)
<abu[7]> Good, so you can re-read any time
<abu[7]> there is 'client' and 'ssh'
<abu[7]> but you can do (call "curl" ...)
<abu[7]> I use all those three
<abu[7]> Or (in '(curl "-O" ...) (while (line) ...
<abu[7]> (line) or (read) or (char) etc.
<iacore> oh
<abu[7]> Or all in a big string with (till NIL T)
<iacore> I coded something, and I feel like I still don't understand anything.
<abu[7]> No worry!
<iacore> is this valid? (in '("curl" `Url) (till NIL T))
<abu[7]> Yes
<iacore> the url is in a function
<abu[7]> But more useful is (in (list "curl" Url) ...
<abu[7]> Yes, therefore a read-macro is not useful
<abu[7]> (in (list "curl" "-OUrl) ...
<abu[7]> (in (list "curl" "-O Url) ...
<abu[7]> grr
<abu[7]> (in (list "curl" "-O" Url) ...
<abu[7]> I'm struggling with my new keyboard
<iacore> it seems like read-macro is only used for macro. not very useful for quote/unquote
<abu[7]> 'macro' does not use a read-macro
<abu[7]> Look at 'fill' to get what you call "unquote"
<abu[7]> There is no "unquote"
<abu[7]> The opposite of "quote" is "eval"
<abu[7]> read-macros are for constant values, calculated at read time
<abu[7]> Exactly like C macros
<iacore> there is no quasiquote?
<abu[7]> Look at 'fill'
<abu[7]> Backquote in CL is the same as 'fill'
<abu[7]> It is a function, not a macro
<iacore> i understand now, thanks
<iacore> i made my code cleaner
<abu[7]> 👍
iacore has quit [Quit: Leaving]
inara has quit [Quit: Leaving]
DKordic has joined #picolisp
msavoritias has quit [Remote host closed the connection]
inara has joined #picolisp
clacke has joined #picolisp