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
teddydd has joined #picolisp
rob_w has joined #picolisp
rob_w_ has joined #picolisp
rob_w_ has quit [Ping timeout: 252 seconds]
rob_w_ has joined #picolisp
aw- has quit [Quit: Leaving.]
teddydd has quit [Ping timeout: 265 seconds]
aw- has joined #picolisp
teddydd has joined #picolisp
<cess11> what's the use case for modifying a cons like that?
<beneroth> cess11, in place/destructive modification of a list
<beneroth> rarely needed
<Regenaxer> I think it is very often needed
<Regenaxer> Especially in case of properties (object attributes)
<Regenaxer> (inc (prop 'obj 'foo))
<Regenaxer> Same as (set (prop 'obj 'foo) (+ 1 (get 'obj 'foo)))
<Regenaxer> or, shorter (with 'obj ... (inc (:: foo)) ...
<Regenaxer> In general, modifying cells with 'set', 'inc', 'push', 'pop' etc. is very common
<Regenaxer> Because cells are the *only* structural data type
<Regenaxer> For a start, search for 'set' in e.g. @lib.l
<Regenaxer> e.g. in Vim with /\<set
<Regenaxer> e.g. in Vim with /\<set\>
<Regenaxer> or in Vip with &set
<cess11> thanks
<Regenaxer> :)
<cess11> in practice i almost only do it with convenience functions
<cess11> i.e. not directly
<cess11> though i use setq a lot, usually to set up some globals with e.g. rdbms credentials or interactively store some data set at a particular state
<Regenaxer> It depends. And most List manipulation functions are non-destructive or have a non-destructive version
<Regenaxer> yes, setq is a variation of set
<Regenaxer> But you may want to modify structures
<Regenaxer> (mapc inc List)
<Regenaxer> oops
<Regenaxer> (map inc List)
<Regenaxer> or this:
<Regenaxer> : (setq L (1 2 3 4))
<Regenaxer> -> (1 2 3 4)
<Regenaxer> : (map set L 7)
<Regenaxer> : L
<Regenaxer> -> 7
<Regenaxer> -> (7 7 7 7)
<Regenaxer> destructive modification
<cess11> i think i mostly do it in the pildb context, with plain lists i almost always mapcar out a new list and let the other one disappear into the void
<Regenaxer> yes, in db this is better
<Regenaxer> i.e. non-destructive
<Regenaxer> (put> Obj 'var (mapcar ...
<Regenaxer> it is necessary because otherwise Obj does not notice it is *dirty*
<Regenaxer> so it is not committed
<Regenaxer> In general it is recommended to be non-destructive unless the side-effect is needed
<Regenaxer> "immutable" in Clojure-speak
teddydd has quit [Ping timeout: 252 seconds]
<beneroth> <cess11> in practice i almost only do it with convenience functions
<beneroth> same
<beneroth> but you are right Regenaxer, is/should be used more when doing non-pilDB OOP
<Regenaxer> What do you both mean with convenience functions?
<Regenaxer> I think not only should
<beneroth> put/put>
<Regenaxer> yes, but non-property data
<Regenaxer> lists, trees
<beneroth> lists yes, for trees... I use more 'conc I believe
<beneroth> not sure
<Regenaxer> yeah, depends
<beneroth> but yes, there is a good probability that I make less use of destructive functions then I should for efficiency (and where it would be perfectly appropriate)
<Regenaxer> I feel not so much for efficiency
<beneroth> then again most time I spend in pure database stuff or GUI stuff.. GUI stuff kinda lends itself to use more non-pilDB OOP and also destructive functions... but my GUI stuff is still not as mature as your framework
<beneroth> in some apps I use your framework, in some mine, which is still kinda WIP
<beneroth> different trade-offs :)
<Regenaxer> yeah
<Regenaxer> If you implement algorithms, you need 'set' a lot
<beneroth> yes
<Regenaxer> we should ask tankf33der
<beneroth> aye, I view him as the expert for this stuff
<beneroth> (beside yourself)
<Regenaxer> indeed
<beneroth> I had some use cases, but after solving them I forgot again :)
<Regenaxer> he did lots of practical stuff
<beneroth> same as with bitwise stuff
<Regenaxer> :)
<Regenaxer> I forget all the time too
<beneroth> I plan to increase my use of pil for automation and administration comfort, which I believe/guess is tankf33der's main use of pil
<beneroth> so far most is business applications
<Regenaxer> good
<beneroth> which is often.. simple. not easy, good CRUD is hard not easy, but the complexity is more in architecture than in specific code parts
<beneroth> algorithms are the other way round. unix-style tooling too, if made well.
<Regenaxer> yep
<cess11> i have one automation task i currently solve with pil, an intermediary nightly backup of ~300 databases. 'mapcar over a list of database names with dump the sql file, then fork and gzip it
<beneroth> cess11, nice
<beneroth> so... 4 lines? :D
<Regenaxer> wow
<cess11> pertty much everything else i do in pil is interactive
<beneroth> still mainly for data exploration?
<cess11> yeah, something like that
<cess11> also writing back to databases, e.g. exploring and changing schemas
<Regenaxer> cool
<cess11> could build out that automation to automatically dump the database names and probably some more, but it's a fairly simple task that would be quite a bit more noisy in bash
<beneroth> awesome. that is cool stuff
<beneroth> yeah I'm not a fan of bash syntax for more than the simplest tasks. probably habit, but still.
<cess11> in rdbms admin i use desctructive list changes a lot, 'cut is really nice there
<beneroth> I've done some interactive helper scripts, mainly to be used for myself. e.g. pil script which interactively asks me stuff on the command line, then does some validation/checks (e.g. DNS queries) and then formats and output value (to be copied in a config) or diagnosis
<Regenaxer> cess11, 'cut' is non-destructive btw
<Regenaxer> like 'pop'
<beneroth> hm... strictly speaking yes
<Regenaxer> ok, strictly
<beneroth> but in general usage.. I would also consider pop/++ as destructive.. relative to the 'var (which is "moved")
<Regenaxer> modifies the 'var' only
<beneroth> T
<cess11> an inconsistency might have creeped in, then it's easy to pull out of the schema which databases are affected, put them in a list, test until query is good on a dummy, then chug through them either sequentially or in batches that keep the locking and pressure on the rdbms engine at a tolerable level
<beneroth> if there is a shallow copy of the list, or even just another reference in a variable, it's not destructed
<beneroth> cess11, nice
<Regenaxer> 'cut' *is* destructive if 'var' is not a symbol
<beneroth> I've to do similar tasks sometimes in C#, it's very annoying and extremely bloaty
<cess11> well, not sure how 'cut works but when i tell it to cut a piece of a list the rest is magically left in my global
<beneroth> but I have now a wrapper for MSSQL sqlcmd, quite handy. I should publish it...
<Regenaxer> right
<beneroth> cess11, do you have a wrapper for MySQL or MariaDB sql client? is it available?
<Regenaxer> cess11:
<cess11> maybe ten subtly different ones
<Regenaxer> : (setq A (1 2 3 4 5 6) B A)
<Regenaxer> -> (1 2 3)
<Regenaxer> : (cut 3 'B)
<Regenaxer> -> (1 2 3 4 5 6)
<Regenaxer> : A
<Regenaxer> -> (1 2 3 4 5 6)
<Regenaxer> The list is not modified
<beneroth> cess11, I see, the lisp curse :D
<Regenaxer> only the pointer into the list
<Regenaxer> in B
<cess11> usually i just go through the command line client and stitch it together, nothing fancy
<beneroth> Regenaxer, T. moving the iterator
<Regenaxer> yes
<beneroth> cess11, makes sense
<cess11> but sometimes i need to pass in the database, sometimes it's mysqldump, sometimes it's something else
<cess11> could clean one up and put on the accursed github
<cess11> unless disroot has a git, then i can put it there and migrate.
<cess11> it varies a lot how i want to parse output too, commonly it's split on tab but not necessarily
<beneroth> T, I experienced this too
<beneroth> Regenaxer, (in) and (out) are shiny diamonds of brilliance
<cess11> for sure
<Regenaxer> oh, why?
<Regenaxer> anyway, thanks! :)
<cess11> any tool i already know can be dragged into into interactive lisp processing
<Regenaxer> yeah, pipes
<beneroth> T
<beneroth> I even used some python tool once (for MS Office stuff).. worked well, but a bit slow.. turned out the slowness was primarily the python startup
<beneroth> not significant, but interesting :)
<cess11> if a command has flags and parameters that are boring to type in repeatedly it's trivial to make it default and put on a simple parser of input into a list or list of lists
<beneroth> this!!!
<beneroth> my wrapper function is then usually one which takes arbitrary named parameters
<beneroth> so specific parameters can always handed in, if needed in the future. reusable without bloat and special handling.
<cess11> jq and xml tools are the usual suspects besides rdbms clients
<beneroth> jq?
<cess11> cli tool that gives a query interface to json files
<beneroth> oh nice
rob_w has quit [Quit: Leaving]
rob_w_ has quit [Ping timeout: 252 seconds]
rob_w_ has joined #picolisp