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
seninha has quit [Quit: Leaving]
seninha has joined #picolisp
seninha has quit [Remote host closed the connection]
zaWanderer has joined #picolisp
<zaWanderer> greetings
<zaWanderer> I have a questions regarding database seeding ..
<zaWanderer> I am unable to use (request! for a nested instance creation inside the initial file" it complains about bad DB file. I can write the same lines in REPL and instances are created successfully in DB
<zaWanderer> I may be wrong, but it seems that I am unable to sync the db while creating the nested request! instances.
<zaWanderer> so I am ending up with a lot of dangling items
<zaWanderer> I think I am confusing myself, maybe the real problem is that I don't understand the difference between (new!..) and (request!...)
chexum has quit [Remote host closed the connection]
chexum has joined #picolisp
avocadoist has joined #picolisp
<abu[m]> Good morning zaWanderer!
<abu[m]> Strange if behavior in the REPL is different
<abu[m]> A bad DB file usually means that 'pool' was not called
<zaWanderer> so what is the difference between obj and request!
<zaWanderer> I meant obj + commit Vs. request!
<zaWanderer> good morning abu :)
<abu[m]> 'request' does a check first if an object with the given key(s) already exist
<abu[m]> 'obj' always makes a new one
<abu[m]> oops, no, wait!
<abu[m]> Too early in the morneng ;)
<zaWanderer> :D
<abu[m]> 'obj' is basically a non-evaluating version of 'request'
<zaWanderer> sorry if I keep getting confused
<zaWanderer> by non evaluating you mean (obj ((+Item) nr 2) is similar to (request '(+Item) 'nr 2)
<abu[m]> yes, exactly
<abu[m]> 'obj' is more convenient and readable for lots of initial data
<abu[m]> 'obj' also takes additional initialisation data
<abu[m]> (let Obj (request '(+Cls) 'key Val) (put> Obj ...
<abu[m]> (obj ((+Cls) key "Value") key1 "Val" ...
<abu[m]> 'obj' is also used in generated dumps of a database. Using 'request' here would be more verbose
<zaWanderer> can I call obj with more than one key value pair?
<abu[m]> yes
<zaWanderer> (obj ((+Cls) key1 "Value" key2 "Value2") key3 "val3"..)
<abu[m]> Like for requet, the combination of keys should be specific enough
<abu[m]> So if you say you are writing an init file, 'obj' is the best
<zaWanderer> (but for request, I can't create te object in one step. I have to use something like (let Obj (request '(+Cls) 'key Val ..) (put> Obj 'keyN ValN
<abu[m]> yes
<zaWanderer> Thanks, I will try again and let you know. At least I know what I should expect from obj calls
<abu[m]> 'request' is using either 'db' or 'new' internally
<abu[m]> good
<abu[m]> Still the DB error is strange
<zaWanderer> ok, is nesting obj statements at initialization allowed?
<zaWanderer> I still get the error Bad DB file
<abu[m]> Not directly, because the inner 'obj' call is not evaluated. But as the inner data are also constant, you can use a read macro
<zaWanderer> from (get *DB (cdr Tree) (car Tree))
<zaWanderer> my call is like this
<zaWanderer> (obj ((+Person) nm "Steve") addrs `(obj ((+Address)) city "San Jose"))
<abu[m]> good
<abu[m]> Can you show the 'rel' definitions?
<abu[m]> What is 'Tree'? e.g. (nm . +Cls)
<abu[m]> The above line is in 'root'
<abu[m]> : (who '(get *DB (cdr Tree) (car Tree)))
<zaWanderer> (root)
<abu[m]> or just inspecting 'Tree' at the error prompt
<abu[m]> Yes, so which tree is wrong?
<abu[m]> It must be a wrong E/R definition
<abu[m]> (or 'pool' was not called?)
<zaWanderer> that brings me to the second part
<zaWanderer> is it only sufficient to start a file from scratch using "(pool "tmpDev.db") for example
<abu[m]> Yes, you can call just 'pool' interactively
<zaWanderer> (when (call 'test "-r" "tmpDev.db")
<zaWanderer> (call 'rm "tmpDev.db") )
<zaWanderer> (pool "tmpDev.db")
<abu[m]> yes, fine
<zaWanderer> I always delete the file and start from scratch.
<abu[m]> Or just (call "rm" "-f" ...)
<abu[m]> i.e. without testing
<zaWanderer> working after I took out (pool ...) from the main() and put it on top of the app.l file
<abu[m]> 'main' should be fine, if you make sure it is always called
<abu[m]> I usually check inside the main function whether the DB exist
<abu[m]> Typical example is in "app/main.l"
<abu[m]> symbols, mkdir, pool and init.l
<abu[m]> init.l checks with 'seq' if the DB already exists
<abu[m]> And after a project is in production, I remove the init stuff
<zaWanderer> is there any problem calling (pool ..) after loading er.l outside the main()
<zaWanderer> with the line (pool ...) is inisde main
<abu[m]> No problem
<abu[m]> You can call pool also later, e.g. to switch betteen databases
<abu[m]> PilBox does that all the time
<zaWanderer> (when pool returns T) am I sure the DB file exists or the files system may still be creating the file and may not be available for the next calls of(obj ((+Cls) ....
<abu[m]> Yes, a file is immediately available after opening it. The OS may not have written it physically, but for a program this does not matter.
<zaWanderer> ok, I will dive deeper into it, many thanks
<abu[m]> Welcome :)
zaWanderer has quit [Ping timeout: 240 seconds]
rob_w has joined #picolisp
seninha has joined #picolisp
seninha has quit [Remote host closed the connection]
seninha has joined #picolisp
<abu[m]> Again fixed a bug in the context of coroutines
<abu[m]> A bit esoteric. Happens if thrown from a coroutine into another on which then involves a 'finally' clause
<abu[m]> s/on/one
<abu[m]> Just for the records ;)
<beneroth> thanks abu[m] :)
<abu[m]> ☺
<abu[m]> I'm going a bit extreme with coroutines recently. Working on the discrete event simulation library.
<beneroth> oh nice!
<beneroth> sounds very exciting
<abu[m]> Yeap. A lot of fun.
<abu[m]> In fact it is in @lib/simul.l since January, but still in progress, so I did not announce anywhere yet.
<abu[m]> It is also (primarily) documented in https://software-lab.de/doc/des.html
<abu[m]> But no hurry! ☺
<beneroth> awesome
<beneroth> this can be used for process simulation and all kind of games
<abu[m]> Exactly
<beneroth> maybe also for parsing/network connections to guard timeouts in a very async way
<abu[m]> I've built a model railway simulation with it
<beneroth> nice!
<abu[m]> Back in February I even made a screenshot video: https://picolisp.com/pub/bahn.mp4
<abu[m]> But it is all still changing
<beneroth> haha, cool!
chexum has quit [Quit: No Ping reply in 180 seconds.]
chexum has joined #picolisp
rob_w has quit [Quit: Leaving]
seninha has quit [Remote host closed the connection]
seninha has joined #picolisp
zaWanderer has joined #picolisp
seninha has quit [Remote host closed the connection]
zaWanderer has quit [Ping timeout: 240 seconds]
_whitelogger has joined #picolisp
cpli has joined #picolisp
casaca has joined #picolisp
seninha has joined #picolisp
seninha has quit [Remote host closed the connection]
seninha has joined #picolisp
clacke has joined #picolisp