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
ygrek has joined #picolisp
ygrek has quit [Remote host closed the connection]
viaken has quit [Ping timeout: 248 seconds]
viaken has joined #picolisp
z4k4ri4 has quit [Quit: WeeChat 4.6.2]
z4k4ri4 has joined #picolisp
z4k4ri4 has quit [Quit: WeeChat 4.6.2]
z4k4ri4 has joined #picolisp
geri has joined #picolisp
<geri> hey-hey
<geri> i return from the dead for some time :D
<abu[7]> Hi geri!
<geri> ive been working on my interpreter and found out a bunch of cool ideas
<geri> :D
<geri> a very epic manual closure
<geri> but more epic - generators based on basically just functions
<geri> is there something like fold/reduce? it works like this: (fold + 0 '(1 2 3)) => 6
<abu[7]> Later, I'm in a conference
<geri> ok
ygrek has joined #picolisp
<geri> (de fold-left (Fn Acc L)
<geri> (for X L
<geri> (setq Acc (Fn Acc X))))
<geri> i guess this works :D
<abu[7]> Done
<geri> wb
<abu[7]> :)
<abu[7]> Apply does not help?
<abu[7]> : (apply + (1 2 3) 0)
<abu[7]> -> 6
<abu[7]> Instead of fill + quote you could use 'curry'
<abu[7]> : (let @N 7 (curry (@N) (A) (foo (bar A @N))))-> ((A) (foo (bar A 7)))
<abu[7]> : (let (@N 7 B 2) (curry (@N B) (A) (foo (bar A B @N))))
<abu[7]> -> ((A) (job '((B . 2)) (foo (bar A B 7))))
<geri> : (de snoc (X Y) (cons Y X))
<geri> : (fold snoc '() '(1 2 3))
<geri> -> (3 2 1)
<geri> fold is a generic higher order function
<geri> (also function i dropped is basically what fold does)
<geri> job is for the generator?
<geri> curry*
<abu[7]> job is env plus prg body
<geri> <abu[7]> Instead of fill + quote you could use 'curry' [17:16]
<geri> this, for generator function i sent?
<abu[7]> yeah
<geri> docs of curry actually have the fibo generator code haha
<abu[7]> curry is just a frontend to fill and or job
<abu[7]> oh :)
<geri> well, not completely
<geri> but close
<abu[7]> I must go. Will answer only sporadically
<geri> ok
<geri> (de fibo ()
<geri> (fill
<geri> (quote ()
<geri> (job 'ENV
<geri> (prog1 (+ N1 N2)
<geri> (setq N1 N2 N2 @))))
<geri> 'ENV
<geri> (list (cons 'N1 0) (cons 'N2 1))))
<geri> now gotta figure out curry
<abu[7]> 👍☺
<abu[7]> It is good to see you that you continue your project
<abu[7]> Vip has several examples for 'curry' iirc
<abu[7]> or @lib/db.l or @src/lib/llvm.l
bjorkintosh has quit [Quit: "Every day, computers are making people easier to use." David Temkin]
<geri> which of the projects? :D
<abu[7]> Your new language
<geri> ah
<geri> yeah, its very fun :D
<geri> (de fibo ()
<geri> (curry ((N1 . 0) (N2 . 1)) ()
<geri> (setq N1 N2 N2 @))))
<geri> (prog1 (+ N1 N2)
<geri> now that one is neat
<geri> curry basically lets you create closures, no?
bjorkintosh has joined #picolisp
<DKordic> geri: If so, sho me Scheme define.
<geri> i dont get it
<geri> and it doesnt capture whole environment, only what you want it to capture
<abu[7]> To be exact, 'job' creates the closure
<geri> how does job work internally?
<abu[7]> DKordic: What is "Scheme define" (if possible, without brackets)?
<abu[7]> job binds, runs, and unbinds
<geri> abu[7]: im guessing (define variable 'value) or (define (function args) . body)
<abu[7]> perhaps
<geri> it binds by just setting symbol values, runs normally, and unbinds by looking at current values and setting it in the env?
<abu[7]> right
<geri> okay, makes sense now
<geri> its very cool honestly
<DKordic> :) `mk-counter' is a great old example. (define (mk-counter) (define Cnt 0) (define (tick) (+ 1 Cnt)) (define (set n) (set! Cnt n)) (define (get) Cnt) (list tick get set)). It assumes Destructive Update, as even R7RS does. Did You know R5RS almost was "immutable"! Why is that hard to find?
<geri> fibo function above is basically the counter closure, yeah
<abu[7]> :)
<abu[7]> : (de f () (inc (0)))
<abu[7]> -> f
<abu[7]> : (f)
<abu[7]> -> 1
<abu[7]> :
<abu[7]> : (f)
<abu[7]> -> 2
<abu[7]> : (f)
<abu[7]> -> 3
<abu[7]> : f
<abu[7]> -> (NIL (inc (3)))
<abu[7]> Keep it simple!
<geri> haha
<geri> true that its simple, but you cant have many of such functions, that's the only problem
<abu[7]> Why a problem?
<geri> mk-counter creates a new counter on each call
<geri> well
<abu[7]> yeah
<geri> yeah :D
<geri> curry is the best option for reuse
<DKordic> «Substitution Semantics» is the essence. It do _not_ define «Side Effect», including «Destructive Update»!
<geri> now rephrase it for us mortals to be able to understand :DD
<DKordic> Mapping is more fundamental than Destructive Update.
<abu[7]> fundamental in which regard?
<DKordic> geri: In other words: what _exactly_ is "change"?
<DKordic> If You prefer it's vague definition, I prefer to say nothing.
<abu[7]> On the lowest level everything ist destructive
<DKordic> In a way. Real computers have limited Resources.
<abu[7]> T
<DKordic> Perhaps We should clarify that.
<geri> in fp terms, change typically means altering some value of a data structure in-place
<geri> like setting head field of a pair
<geri> the change fp people dont like anyway
<abu[7]> docmatic ;)
<bjorkintosh> idefix!
<abu[7]> The dog?
<geri> not having mutation does some things easier, but i dont like being constrained
<bjorkintosh> yes. I thought that's what you were referring to :-D
<geri> s/some/make some/
<bjorkintosh> dogmatix (in english) and idefix (in .de) yes?
<abu[7]> ah, right!
<abu[7]> Away for 30 mins
<geri> laters
<DKordic> abu[7]: Re: $TERM. https://terminalguide.namepad.de/seq/csi_st-18/ https://invisible-island.net/xterm/ctlseqs/ctlseqs.pdf (last update 2025-03-30) (page ). Excellent question! Short and clear. I don't like "Terminal"s at all. Therefofre, "ncurses" and it's sh.it ven less.
<DKordic> I don't think it is dogmatic, it is deeper understanding.
<geri> it is dogmatic
<DKordic> Life is... Compex in it's own way. I am afraid "Functional Programming" is indeed limited.
<geri> to write good programs you want a mix of functional and imperative imo
<DKordic> That is why they say Haskell is the best imperative PL.
<geri> uh?
<DKordic> Well, at least their favourite.
<geri> what are you saying?
<DKordic> In other words: "functional" is a joke from the 1970s.
<geri> first lisp is from 1960
<geri> and what part is a joke about it?
<geri> purely functional paradigm?
<DKordic> "operating" in OS? IMHO Object System is deeper understtanding than (merely (in a few examples)) Operating System.
<geri> i mean
<geri> lambda is immensely powerful
<DKordic> geri: Our (jumanity) understainding improved over time.
<DKordic> "lambda" is _confused_.
<DKordic> Think again.
<geri> ._ .
<geri> lambda as in first class functions
<DKordic> Clarify your thoughts so we can continue.
* DKordic sips schnaps]
<geri> i dont think theres anything to continue, i dont understand what's going on
<geri> how is fp a joke exactly?
<geri> what does "lambda is confused" mean
<DKordic> Why don't We make _Source Code_ in LaTeX, or HTML5?! Sequent Calculus? Where is it!? Your "Lambda Claculus"? Where is it!? "Calculus" it is!!
<DKordic> Shouldn't "ex", and therefore "vi", be updated to HTML5, as it is the new txt?!
<geri> uhh
<geri> well, you typically dont try to write anything useful in lambda calculus
<DKordic> geri: Huh... forgive me. Yes good question: why is "functional programming" a joke?
<DKordic> Please give me a definition.
<geri> but you can use the concept of a lambda/first class function to write very neat and/or powerful code
<geri> i thought you had a definition if you're calling it a joke :D
<geri> im guessing you mean purely functional paradigm (no side effects of any kind unless in monads or whatever)
<geri> and its a joke cause you cant write anything practically useful without side effects
<geri> i could be wrong though
<geri> if you're talking about first class functions overall, being able to define them and pass them around anywhere arbitrarily, then i don't get why would you call that a joke
<DKordic> getiYou are leveling up ;) .
<DKordic> geri: "functinoal" insinuates "dysfuncational".
<geri> ha
<geri> no, that's just poor naming
<DKordic> geri: "function" undefined. "peurely" undefiined. "effect" undefined. "side" undefined.
<geri> okay
<DKordic> Does it end there?
<abu[7]> ret
<geri> wb
<DKordic> geri: Formal, Symbolic?
* DKordic is triggered by "ret" (CPU instruction).
<abu[7]> DKordic, (prinl "\e1B[5B 1831 38 t74") causes no reply from the terminal
<geri> its "functional" because the whole paradigm is focused on functions - a procedure that takes an argument and returns a value deterministically
<geri> i.e, if function f receives argument 5 and returns 7, it should always return 7 given input of 5
<geri> side effect is basically anything that isnt just returning a value
<geri> printing text, modifying variables from the outside, etc.
<geri> pure function is a procedure without side effects
<geri> i guess there are your definitions
<DKordic> geri: Absolutely not. "definitions" for you, not for me. Do you deserve better?
<geri> > Do you deserve better?
<geri> ????????????
<DKordic> abu[7]: xterm... I ""tested"" interactively... More accurately tryed. So, yes ""it works on my machine"". I think ""terminal emulator"" is an offense to reason!! Why is it not an _Interface_?! Are We insisting on _Cargo Cult_?
<abu[7]> Anyway, we better stay with ioctl()
<abu[7]> It's the real thing
<DKordic> Yes.
<DKordic> I could not find a way to filter stdout...
<abu[7]> I see no stdout at all on my terminals
<DKordic> Times have changed... escape sequences are... should no be more than an Interface... Do We need to _repeat the mistakes_?
<DKordic> Every time...
<abu[7]> agreed
<DKordic> Web Browser is the new Terminal Emulator. HTML5 it the new escape sequence.
* DKordic runs.
<bjorkintosh> unfortunately it's true to some extent.
* DKordic ROFL
<bjorkintosh> after all, web browsers still run on something, no? they don't run on the cloud.
<bjorkintosh> the cloud is someone else's computer.
<DKordic> Good point... Why do We need "Operating System" for "Web Browser"?
<DKordic> It seems to be an OS with in OS.
<bjorkintosh> exactly.
<abu[7]> All my apps run in HTML GUI, even PilBox
<DKordic> I am glad We agree.
<abu[7]> Makes my living since 25 yrs
<bjorkintosh> we need the browser because it sort of unifies all the OSes. the dreams of java running everywhere have been supplanted by the web.
<abu[7]> T
<bjorkintosh> it's just that we're in that future and we don't like it because javascript is a big headache.
<bjorkintosh> humans are never satisfied.
<bjorkintosh> maybe unsatisfiable.
* bjorkintosh is one of those humans.
<abu[7]> I started with Jawa AWT, then Applets, later HTMK 5
<abu[7]> all similar on the Pil side
<bjorkintosh> you adapted.
<DKordic> Meanwhile Intel x86 has been running "everywhere".
<bjorkintosh> not quite.
<DKordic> Of course, not absolutely. I wanted to say not appreciated enough (at least compared to snake oil like JVM).
<bjorkintosh> jvm is a thing of beauty.
<bjorkintosh> it's x86 which is the snake oil.
<DKordic> I stand corrected.
<DKordic> I still prefer x64
<DKordic> And wonder what could possibly be beautiful about JVM.
<bjorkintosh> Java (the language, which is not that pretty) is not Java the VM.
<bjorkintosh> the jvm is a pinnacle of VM design. especially with the graal improvements.
<bjorkintosh> a marvel of engineering, much like our own picolisp :-D
<abu[7]> ;)
<DKordic> x86 is a VM (microcode) of it's own!
<bjorkintosh> there's no microcode is there? in any case, the x86 is quite ugly. it was born that way, and will remain that way.
<bjorkintosh> x64 exists in spite of intel. it was created by AMD.
<DKordic> WebAssemblt is rebranding of AMD64.
<DKordic> As some woud say: "whre rubber meets the road".
<bjorkintosh> DKordic: it's easy to dismiss java, which I happily do since options exist. but the JVM should not be included in that dismissal. it's sublime.
<DKordic> Untill RISC-V got some Implementations it was no better than WASM, or JVM.
<bjorkintosh> work in progress.
<geri> thats kind of an optimization thing, lets you generate infinite sequences without keeping them in memory
<abu[7]> nice, looks good :)
<geri> its very fun too :D
<abu[7]> I believe
<geri> abu[7]: do you get shot in the foot by dynamic binding often?
<geri> i would guess with years of experience not really :D
<abu[7]> Never
<abu[7]> T
<geri> haha
<geri> honestly as expected
<abu[7]> I stick to the rules
<abu[7]> doc/faq.html
<geri> naming conventions?
<abu[7]> "Are there no problems caused by dynamic binding?"
<abu[7]> So @doc/faq.html#problems
<geri> Fortunately, these pitfalls do not occur so very often, and seem more likely in utilities than in production code, so that they can be easily encapsulated.
<geri> i agree that utilities have that problem way more often than any scripts i had written
<abu[7]> Yes, I think to too
<geri> okay, i just now noticed all of lib.l is transient symbols
<geri> :D
<geri> sounds about right
<abu[7]> Now I would use (private), but that's the same internally
<geri> cause looks neater?
<abu[7]> Yes, and is more flexible
<abu[7]> more selective
<geri> wdym?
<geri> also you could zap selected symbols and you'd effectively make them private :D
<geri> primitive solution though
<abu[7]> (private) makes symbols individualuy
<abu[7]> (====) clears the whole transient scope
<geri> ye
<geri> i hadnt seen it getting used in the wild i think
<abu[7]> @lib/xhtml.l
<abu[7]> (private) (Prg Ofs ...
<abu[7]> ...
<abu[7]> (private) (Attr Prg)
<abu[7]> Prg is re-created
<geri> (====) does so too, no?
<abu[7]> yes, but for *all* transients
<geri> oh yeah okay
<abu[7]> : (private) (A B)
<abu[7]> : (setq A 1 B 2)
<abu[7]> -> 2
<abu[7]> : (private) A
<abu[7]> : (list A B)
<abu[7]> -> (NIL 2)
<geri> wasnt there also (local)?
<abu[7]> yes
<abu[7]> forces into current ns
<abu[7]> priv it a special ns
<abu[7]> behaves differently
<abu[7]> "always searched first, but never gets new symbols automatically interned"
<abu[7]> normal namespaces intern new symbols
<geri> how does no automatic interning part work exactly?
<abu[7]> (symbols 'ap 'pico)
<abu[7]> ap is searched, then pico
<abu[7]> if 'foo' is not found
<abu[7]> it is interned into 'ap'
<abu[7]> But really we have (priv ap foo)
<abu[7]> priv is searched first
<abu[7]> but if nowhere found,a sym is ietered in 'ap'
<abu[7]> priv is a kind of demon ns :)
<abu[7]> Not visible, but always there
<geri> haha
<geri> if you write priv~foo, will the symbol get interned to priv?
<abu[7]> Yes
<abu[7]> Vip uses that for structure editing
<abu[7]> (intern "X" 'priv)
<abu[7]> eg. (v search)
<abu[7]> you see a line (priv~search1 X Y)
<abu[7]> search1 in private in lib/db.l
<abu[7]> s/in/is/
<abu[7]> OK, must stop, demanded by 雅子
<geri> good luck!
<geri> alrighty, going as well
<geri> have fun
geri has quit [Quit: ERC 5.6.0.30.1 (IRC client for GNU Emacs 30.1)]
ygrek has quit [Remote host closed the connection]
bjorkintosh has quit [Remote host closed the connection]
ygrek has joined #picolisp
bjorkintosh has joined #picolisp
chexum has quit [Ping timeout: 264 seconds]
chexum has joined #picolisp