ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Picolisp latest found at http://www.software-lab.de/down.html | check also http://www.picolisp.com for more information
rob_w has joined #picolisp
<beneroth> Good morning all
<aw-> hi
rob_w has quit [Remote host closed the connection]
rob_w has joined #picolisp
rob_w has quit [Remote host closed the connection]
<aw-> rumours...
<Regenaxer> Hi beneroth, aw-
<aw-> hi Regenaxer
<aw-> Regenaxer: is there a way to store multiple key/value pairs with (rc) ? like (rc "file" 'a 1 'b 2 'c 3) ?
<Regenaxer> Yes, but with multiple calls to 'rc'
<Regenaxer> 3 args means "store"
<aw-> hmmm
<aw-> ok so the data in the rc file is just an assoc list, right? can i do (out "file" (prin '(cons 'a 1) (cons 'b 2))) ?
<Regenaxer> yes, but this example is wrong then
<aw-> or (prin '((a . 1) (a . 2)))
<Regenaxer> needs 'print'
<Regenaxer> or 'println'
<aw-> oh it needs a newline?
<Regenaxer> I think without newline is OK
<Regenaxer> 'prin' will not work
<aw-> what's the difference?
<Regenaxer> oh
<Regenaxer> you don't know that?
<aw-> oh oh
<aw-> sorry
<aw-> yes i do
<aw-> my bad
<Regenaxer> :)
<aw-> haha i wasn't paying attention
<Regenaxer> The newline is more an issue for an editor
<aw-> yes i want to print, not print a string of my list
<Regenaxer> yep
<Regenaxer> vim complains without nl, but the pil reader does not care
<aw-> ok so, just printing an assoc list to a file is the same as multiple calls to 'rc ?
<Regenaxer> yes, perhaps you need to lock the file also
<aw-> ah
<Regenaxer> in case of concurrent access only
<aw-> yes so my concern was the locking/unlocking of multiple 'rc calls
<aw-> ok so, (ctl "file" (out ... ?
<Regenaxer> Just to be sure :)
<Regenaxer> yes
<aw-> awesome, thanks!
<Regenaxer> Probably a write of less than BUFSIZ is atomic anyway
<aw-> oh, one more question
<aw-> do you have a shorthand for (cdr (assoc "something" List)) ?
<Regenaxer> Unfortunately not. I miss it sometimes too
<Regenaxer> also the pattern (if (assoc ..) (con @ ...) (push ...
<aw-> hmmm yeah
rob_w has joined #picolisp
<Regenaxer> ah, in some cases (cdr (assoc is 'get'
<Regenaxer> if pointer-equal
<Regenaxer> ie (cdr (asoq <-> get
<aw-> oh.. pointer-equal
<aw-> how about (;) ?
<aw-> '
<aw-> ';
<Regenaxer> it is also based on 'get'
<Regenaxer> as :
<aw-> i'm not sure how they are different
<Regenaxer> : (get '((a . 1) (b . 2) (c . 3)) 'b)
<Regenaxer> -> 2
<Regenaxer> (; '((a ...)) b)
<aw-> hmmm...
<aw-> I remember using it to fetch an item by index
<aw-> like (; List 1) or (; List 2)
<Regenaxer> yes, this too
Regenaxer has left #picolisp [#picolisp]
Regenaxer has joined #picolisp
<Regenaxer> 'get' behaves differently depending on the arg types
<Regenaxer> a number is a list index
<aw-> right
<Regenaxer> I have sometimes ':' or ';' with 5 or more arguments. Very convenient
<beneroth> T
<aw-> interesting.. i haven't tried that, will look into it
<Regenaxer> It makes sense typically in the DB
<Regenaxer> following +Links and +Joints
<Regenaxer> depending on the DB model
mtsd has joined #picolisp
<aw-> beneroth: do you use GitHub?
<beneroth> not really, beside reading and fetching stuff others have hosted there.
<beneroth> but that's just because I hadn't had the need yet.
<aw-> oh i see
<aw-> you work a lot?
<beneroth> tankf33der, important point! I read a bunch of studies which used GitHub code, didn't consider this!
<beneroth> aw-, yeah
<aw-> beneroth: makes sense
<aw-> tankf33der: corollary, 70% of code on GitHub is nodejs ;)
<beneroth> argh
<beneroth> how horrible
<aw-> well probably not 70%, but it's definitely #1
<aw-> (javascript)
<beneroth> says something about language popularity metrics :)
orivej has quit [Ping timeout: 240 seconds]
<tankf33der> how to solve this one ?
<tankf33der> any hints ?
<beneroth> sounds like path finding. A* ?
<beneroth> maybe https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm is simpler, dunno
<beneroth> maybe I'm completely wrong :)
<tankf33der> http://rosettacode.org/wiki/A*_search_algorithm
<tankf33der> not solved in picolisp too
<tankf33der> there is no single destination, so this is not A*
<beneroth> good point
orivej has joined #picolisp
reed has joined #picolisp
<reed> Hi All. I'm trying to get something like (dm-macro 'f) -> '(de f () (=: x 100))
<reed> Right now I have (de dm-macro X (let C (car X) '(dm `C () (=: x 100))))
<reed> but it isn't expanding C to the correct symbol
<Regenaxer> I can answer a little later
<reed> Thanks!
<Regenaxer> ok, ready :)
<Regenaxer> hmm, 'dm' is "define method", not macro
<Regenaxer> Are you aware what the ` read macro means?
<Regenaxer> It is a *read* macro
<Regenaxer> So the value of C at the moment when this expression is read is inserted
<reed> And "let" won't bind C until the function dm-macro is actually called?
<beneroth> yeah, its not executed unless called
<Regenaxer> let binds when the expression is executed
<Regenaxer> yes
<Regenaxer> moment again ;)
<reed> Is there any way to get the behavior I'm looking for? I should note that I meant to write (dm-macro 'f) -> '(dm f () (=: x 100))
<beneroth> I don't understand yet what you want to do :)
<beneroth> a function 'dm-macro which binds a function definition to the symbol you give it?
<reed> correct. But specifically a method definition
<Regenaxer> back
<reed> To be used with cclass
<reed> *class
<Regenaxer> the 'dm' function pushes the method into the value of *Class
<Regenaxer> let me give an example
<Regenaxer> This "defines" a method "foo>" for class '+A':
<Regenaxer> (push '+A '(foo> (X) (:= x X)))
<Regenaxer> (de dm-macro (F) (push *Class (cons F '(() =: X 100))))
<Regenaxer> Not tried :)
<beneroth> a function (or method) in picolisp is just a list, first parameter being the argument list (or the symbol @ for a varying number of evaluated parameters, or another symbol for a varying number of unevaluated parameters, or a cons pair to combine the different types of parameters) followed by expressions (the function body)
<Regenaxer> T
<reed> Ahhh, that seems reasonable. I'll see if I can make something like that work
<Regenaxer> yeah
<Regenaxer> does not need 'push' of course, any list operations will do
<beneroth> for OOP in picolisp: the methods are stored in the value of the Class symbol. the name of the symbol being the class, the properties of the symbol being its attributes (or relationships when using pilDB), and the value is a list of parent classes/objects, followed by the method definitions.
<Regenaxer> yes, but "name of the symbol being the class," should be "the value ..."
<beneroth> T
<Regenaxer> ie the superclass(es)
<beneroth> there is not 'really' a differentiation between classes and objects in picolisp. in usage there is, but not in the technical implementation
<beneroth> Regenaxer, did MacLisp have a symbol type similar to picolisp? The symbol type of picolisp seems to be pretty unique in todays lisps...
<beneroth> (afaik)
<Regenaxer> Yes, symbols were central to Lisp always
<Regenaxer> (as opposed to Scheme, and (?) Clojure)
<Regenaxer> CL still has them in full power
<beneroth> really? the CL (and Clojure) guy I talked with was pretty surprised about picolisps symbol type
<reed> So I tried (de dm-macro (F) (push *Class (cons F '(() (=: x 100))))) but when I run (dm-macro 'a>) then call (a> my-shape) It says "a> -- undefined"
<Regenaxer> beneroth, this is funny then
<beneroth> reed, (extend 'my-shape) (dm-macro 'a>)
<Regenaxer> reed, right! I needs more
<Regenaxer> the value must be set
<Regenaxer> (de dm-macro (F) (def F meth) (push ...
<beneroth> but... your class names should start with +CapitalLetter... (naming conventions, no technical effect)
<reed> Right, my-shape is an element of +Shape
<beneroth> I would do it this way: (class +MyShape +Shape) (dm a> () (=: x 100))
<reed> That would definitely be the most direct way, but it doesn't generalize. I'm really just trying to learn to write "macros" to define methods
<Regenaxer> The values of symbols usable as methods have a special definition
<reed> Regenaxer: so in this case "meth" would be '(() (=: x 100))?
<Regenaxer> oops
<Regenaxer> Lost network to my provider
<Regenaxer> Did I lose something?
<Regenaxer> no, 'meth' is a built-in function
<Regenaxer> : meth
<Regenaxer> -> 266980
<Regenaxer> all methods have this value
<Regenaxer> : upd>
<Regenaxer> : rel>
<Regenaxer> -> 266980
<Regenaxer> -> 266980
<Regenaxer> (def F meth) is the same as (setq upd> meth) or (set 'upd> meth)
<reed> ahh
<Regenaxer> 'def' just sets the value of the symbol, doing some checks and debug infos
<Regenaxer> 'def' says "redefined" if 'a>' already had some other value
<reed> I have to go afk for about an hour. This is definitely pointing me in the right direction. Thank you!
<Regenaxer> Welcome :)
<reed> had a chance to test it before i left. That worked. Thank you!
<Regenaxer> great :)
<Regenaxer> beneroth: Perhaps the above guy first learned Clojure, and now programs CL in Clojure style! Has he heared about cons pairs?
<beneroth> he first learned CL, but currently programs mainly in Clojure. I suspect he never was that fluent in CL as he is now in Clojure.
<Regenaxer> ok
karswell_ has joined #picolisp
mtsd has quit [Quit: Leaving]
karswell_ is now known as karswell
rob_w has quit [Quit: Leaving]
grp has joined #picolisp
<Regenaxer> reed: There is also a way more close to your initial intention
<Regenaxer> Not with a read macro, but with the 'macro' function calling 'dm'
<Regenaxer> (de dm-macro (@F)
<Regenaxer> (macro
<Regenaxer> (dm @F ()
<Regenaxer> (=: x 100) ) ) )
<reed> That seems significantly cleaner
<Regenaxer> well, a matter of taste perhaps
<Regenaxer> I prefer the first, with direct control
<Regenaxer> But if the operation were more complicated than 'dm' I would use 'macro'
<Regenaxer> The real problem in this case is that pil has no *evaluating* version of 'dm'
<Regenaxer> afp
Regenaxer has left #picolisp [#picolisp]
karswell has quit [Read error: Connection reset by peer]
alexshendi has joined #picolisp
Regenaxer has joined #picolisp
tankf33der has quit [Quit: Connection closed for inactivity]
styx has joined #picolisp
reed has quit [Quit: Page closed]
styx has quit [Quit: styx]
alexshendi has quit [Read error: Connection reset by peer]
tankf33der has joined #picolisp
grp has quit [Ping timeout: 268 seconds]
grp has joined #picolisp
karswell has joined #picolisp
orivej has quit [Ping timeout: 260 seconds]
alexshendi has joined #picolisp
orivej has joined #picolisp
grp has quit [Quit: box shutting down...]
alexshendi has quit [Read error: Connection reset by peer]