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
f[x] has joined #picolisp
f[x] has quit [Remote host closed the connection]
<geri> i didnt read till the end, but diogenes forgot to quote 'sec in their call
<geri> what do you like about forth abu[7]
<geri> bet its simplicity first and foremost
<beneroth> good morning geri :)
<geri> hi
<geri> im tryna write my first compiler for fun
<geri> i was recommended to write for a stack machine i can implement myself
<geri> s/write for/target/
<beneroth> do you have the Knuth books? they might be great for you
bjorkint0sh has joined #picolisp
bjorkintosh has quit [Ping timeout: 260 seconds]
<geri> no
<geri> heart something about him but idr
<geri> wait he's the creator of tex?
<geri> the one that had to write a book or something and instead he wrote a full typesetting system? xd
<geri> talk about procrastination
<abu[7]> Good morning!
<abu[7]> geri, one note obout yesterday:
<abu[7]> (buf P PATH_MAX (struct (%@ "realpath" 'P "lib.l" P) 'S))
<abu[7]> I was concerned about the buffer
<abu[7]> all correct
<abu[7]> But now of course we *can* use the returned pointer directly, because we control it
<abu[7]> Thus we can do it shorter:
<abu[7]> (buf P PATH_MAX (%@ "realpath" 'S "lib.l" P))
<abu[7]> Just for the records
<beneroth> geri, T that one.
<beneroth> math genius
<beneroth> abu[7], nice, thanks for the update :)
<abu[7]> :)
<beneroth> afk now
<geri> read the forth question a bit up abu[7]
<geri> cool about even shorter realpath
<abu[7]> I like Forth because of its extreme simplicity and elegance, and because I can understand and control it on all levels
<abu[7]> For 8-bit CPUs, there is nothing better
<geri> too bad real world doesnt run on 8-bit CPU's...
<abu[7]> T :)
<geri> forth is yet to click for me
<geri> but i rememebered that many bytecode interpreters are stack machines
<geri> so we get a funny thing where lisp is pure AST and forth is like a target of most interpreters
<abu[7]> Have you seen the book "Thinking Forth" by Leo Brodie? It is an eye-opener.
<geri> i have it queued
<geri> to read later
<aw-> geri: i wrote a Forth implementation for 32-bit MCUs
<abu[7]> Wow, cool! In Arm ASM
<geri> where's `if' defined?
<geri> also forth's creator said he doesnt want forth standartized because it kills innovation, so creating your own forth for your use case is the expected thing to do :D
<abu[7]> I completely agree with that
<geri> i like standards, but i see why he thinks that
<geri> re-learning every tool all the time is tedious
<geri> and re-writing software that could just work if there were standards
<geri> (but in reality wont "just work" because of some small implementation details that weren't properly documented in the spec)
<abu[7]> Forth so easy to roll your own
<geri> lisp interpreters too imo
<geri> just slightly different levels
<abu[7]> Forth is a lot easier
<abu[7]> No data types and no garbage collection
<geri> i guess
<geri> but still infinitely easier than your own C or whatnot
<abu[7]> right
<geri> is gc hard to write?
<geri> thats like one part i hadnt gone through yet
<abu[7]> The gc in pil is simple, as there is only a single size (a cell)
<abu[7]> Pil gc got complicated because of features like database and coroutines
<abu[7]> For a purer version, look into src/gc.l of miniPicoLisp
<geri> one day ill get why database is built into the language instead of being some kind of library
<geri> xd
<geri> yeah i was thinking that pil gc would be faster and simpler cause everything is a cell
<abu[7]> DB objects must be a first class data type
<geri> minipico's gc file only 169 lines, cool
<abu[7]> T, and gc itself is only 100
<geri> not like i understand it though XD
<geri> brb, gotta walk
<geri> (for like 40 minutes...)
<abu[7]> Have fun!
<abu[7]> Here it is raining, will go later
abu[7] has left #picolisp [#picolisp]
abu[7] has joined #picolisp
<geri> rain feels nice to listen to at least
<abu[7]> true :)
<geri> but yeah, i wrote a super basic and super bad stack machine and now working on compiling stuff to it
<geri> at least -*+/ work
<geri> im really happy about my music client too)
<abu[7]> Perfect :)
<aw-> abu[7]: RISC-V ASM ;)
<abu[7]> Oh, cool!
<abu[7]> Seems my Arm ASM knowledge is rusty
<beneroth> aw-, really cool :D
<tankf33der> forth machine on picolisp is already implemented if you need it
<tankf33der> geri: ^^^
<beneroth> hey tankf33der :)
<geri> tankf33der: i know about lifo, im trying to write a compiler for fun
user47 has joined #picolisp
<user47> hi
<abu[7]> Hi user47
<user47> I am toying around with namespaces right now and i am not quite sure i understand them completly. I found the "symbolsnamespace" wiki entry but there are still a few questions i have, for example: i what way are namespaces nested?
<abu[7]> A namespace is a collection of symbols to be searched by the reader. As it is also just a symbol, in may be contained in another namespace
<abu[7]> s/in may/it may
<user47> when i use the "namespaces" function i see all the namespaces, is a nested namespace searched before or after the ones that are on the same level?
<abu[7]> The namespace search order is a simple list, searched sequentially
<abu[7]> (symbols)
geri has quit [Ping timeout: 252 seconds]
<user47> ah, that makes sense
<user47> i have noticed some behaviour that puzzles me. if i start pil and enter e.g. "vip~winsize" everthing works as expected, but if i enter "vip~pico~vip~winsize", it puts me in the "vip" namespace and no symbol seems to be bound to anything; is that expected?
<abu[7]> I would say yes, 'vip~pico' does not exist, so a new symbol 'pico' is created in 'vip'. Not sure atm about the exact consequences after that ;)
<abu[7]> In any case, that new symbol 'pico' is not a namespace, thus we get "Bad symbol namespace"
<user47> so in vip there is no way of getting to the real 'pico' namespace, because there is no nested 'pico' namespace symbol that holds what it normaly holds; is that approximately correct?
<abu[7]> Yes. But you can create it
<abu[7]> (setq vip~pico pico)
<abu[7]> Then vip~pico~vip~winsize gives 8
<abu[7]> Do you think such a use case exists?
<user47> as far as i understand, its a different think if i switch to a namespace with 'symbols' e.g. (symbols 'vip 'pico) and try to access something in 'pico' or if i access something using '~', because in the first case there is a set search order, while in the second its only symbols in the namespace itself and i nested namespaces (using '~') that can be accessed, a far i understand; but to answer your question, it can be
<user47> doubted, but i like to understand the intricasies of PicoLisp ;)
<abu[7]> It is different insofar as 'symbols' sets a new search order. The reader always starts there
<abu[7]> a~b~c needs 'a' to be somewhere in the current search order
<abu[7]> b and c are then directly accessed
<user47> that makes totally sense, also if i do e.g. 'vip~de' it finds nothing, because in this case it only searches in 'vip' and doesnt go out of the with '~' specified namespace
<abu[7]> Right
<abu[7]> My example above (setq vip~pico pico) is perhaps not good, it creates a copy of 'pico'.
<abu[7]> Better is (intern 'pico 'vip)
<user47> Then its two references to the same symbol, right?
<abu[7]> Yes
<user47> I noticed, if i do (setq vip~pico pico) and the do (namespaces T), it shows 'vip' nested under 'pico' (as expected) and '"pico"' nested under 'vip'; why is the '"pico"' under 'vip' a transient symbol?
<abu[7]> This is because this symbol is "shadowed" by the 'pico' found earlier in the search order
<abu[7]> If you do (symbols '(vip pico)) it is no longer transient
<user47> Is that just a way of indicating that a symbol is shadowed or is it also an actual transient symbol (if that makes any difference; i am not sure) ;)
<abu[7]> Basically there is no difference. A transient symbol means just that it is a symbol which is nowhere interned in the current search order
<abu[7]> (including not interned anywhere)
<abu[7]> The new pico symbol is interned in vip, but vip is not searched in the above case
<abu[7]> If we do (symbols 'pico 'vip), it will also no longer be transient
<user47> I see, now '"pico"' turns into 'vip~pico' to differentiate it from the normal 'pico', correct?
<abu[7]> T
<user47> If i do (setq vip~pico pico) then (symbols 'vip 'pico) and (namespaces T), there is a namespace named '@@'; where does it come from?
<abu[7]> I think this is a relict from the REPL mechanism of keeping the last 3 results in @, @@ and @@@. When you did (setq vip~pico pico), it returned a very long list (a tree)
<abu[7]> This is the value of 'pico'
<abu[7]> So technically '@@' indeed became a namespace for a short time
<user47> Interesting, that explains why its gone after a second '(namespaces T)'
<abu[7]> Yep
<abu[7]> I did (setq vip~pico pico) (symbols 'vip 'pico)
<abu[7]> to avoid the long output
<abu[7]> and thus never had @@ as a namespace :)
<user47> Oh, i never thought about entering two LISP expressions at once on the RELP, but obviously there is no reason why that shouldnt work, very nice
<abu[7]> I often simply do (longResult) T
<user47> Huh, i sometimes do (t (longResult)), but your way is more convenient
<abu[7]> a little less to type :)
<abu[7]> brb
abu[7] has left #picolisp [#picolisp]
abu[7] has joined #picolisp
<abu[7]> I stop for today o/
<user47> Well i think ive learned a lot, atm i have no further questions, so thanks for the help :)
<abu[7]> Great! ☺
user47 has quit []
user47 has joined #picolisp
user47 has quit []
f[x] has joined #picolisp