Re: Need help embedding Guile

2021-12-29 Thread Olivier Dion via General Guile related discussions
On Wed, 22 Dec 2021, Mikael Djurfeldt wrote: > All of this indicates that it could be nice to have some kind of Guile > shutdown call in the C API. Such a shutdown call could go through live > objects and free them. Indeed, that's a cool feature. Not many libraries are able to do so though and

Re: Need help embedding Guile

2021-12-23 Thread Mikael Djurfeldt
Den ons 22 dec. 2021 18:37Mikael Djurfeldt skrev: > Hi, > > I think you should give up the idea to GC collect all objects. Due to the > GC being of the conservative type, that can't be guaranteed to happen. Any > attempt to wait until all objects are collected runs the risk of hanging >

Re: Need help embedding Guile

2021-12-22 Thread Dimitris Papavasiliou
On Wednesday, December 22nd, 2021 at 5:29 PM, Maxime Devos wrote: > This seems clear to me (I think you mean that there's some guile code > that preprocesses the node graph to optimise it a little, before > evaluating things). I don't see what dead code elimination has to do > with the structure

Re: Need help embedding Guile

2021-12-22 Thread Dimitris Papavasiliou
Thanks to everybody for their suggestions. I'll respond to all in this single message to keep the discussion from spreading out too much. Please let me know if this is inconvenient for you. I also apologize in advance for my large messages. There's a TL;DR of sorts in the last 3 paragraphs.

Re: Need help embedding Guile

2021-12-22 Thread Mikael Djurfeldt
Hi, I think you should give up the idea to GC collect all objects. Due to the GC being of the conservative type, that can't be guaranteed to happen. Any attempt to wait until all objects are collected runs the risk of hanging indefinitely. Here's a suggestion for a less "heavy-handed" approach

Re: Need help embedding Guile

2021-12-22 Thread Maxime Devos
Hi, Dimitris Papavasiliou schreef op wo 22-12-2021 om 11:41 [+]: > Creating the complete graph before evaluation begins in the second > phase is probably not necessary (nodes could be evaluated as they're > created), but it creates the opportunity for certain optimizations > (like dead code

Re: Need help embedding Guile

2021-12-22 Thread Maxime Devos
Olivier Dion schreef op wo 22-12-2021 om 09:46 [-0500]: > From `eval-in-sandbox` documentation: > >  If SEVER-MODULE? is true (the default), the module will be unlinked >  from the global module tree after the evaluation returns, to allow MOD >  to be garbage-collected. > > So I _think_ you're

Re: Need help embedding Guile

2021-12-22 Thread Olivier Dion via General Guile related discussions
On Wed, 22 Dec 2021, Dimitris Papavasiliou wrote: > Foreign objects currently come in two categories: > > 1. Complete geometric operations such as `cube' and `difference' >above. These are allocated on the C++ side and a so-called "smart >pointer" (shared_ptr) is exported to Scheme.

Re: Need help embedding Guile

2021-12-22 Thread Thien-Thi Nguyen
[cc trimmed] () Dimitris Papavasiliou () Wed, 22 Dec 2021 11:41:22 + One idea would be to simply call `scm_gc()' and `scm_run_finalizers()' until the latter returns 0. As far as I can see, this should ensure all finalizers are called, assumming no references to any foreign

Re: Need help embedding Guile

2021-12-22 Thread Dimitris Papavasiliou
Hi Olivier, Thanks for chiming in! On Wednesday, December 22nd, 2021 at 12:39 AM, Olivier Dion wrote: > From this description, what I understand is that you want to use Scheme > as a configuration file for batching the operations to be done in a > second phase in C++. >From an architectural

Re: Need help embedding Guile

2021-12-21 Thread Olivier Dion via General Guile related discussions
On Tue, 21 Dec 2021, Dimitris Papavasiliou wrote: > The idea is that the C++ program, after some initialization, loads and > evaluates > one or more Scheme files (provided by the user as command line arguments). > During the course of their evaluation, these create objects on the C++ side >

Re: Need help embedding Guile

2021-12-21 Thread Dimitris Papavasiliou
Hi Maxime, Many thanks for your response; it was very helpful. Unfortunately I'm now not so sure that I have the basics of embedding Guile more or less working and, even worse, I'm not really sure Guile is meant to work in the way I'm trying to use it. The idea is that the C++ program, after

Re: Need help embedding Guile

2021-12-21 Thread Maxime Devos
Maxime Devos schreef op di 21-12-2021 om 11:37 [+]: > About finalizers: No. From the BDW-GC faq: [...] I misread your question; this answer doesn't apply exactly to your question. However, there still are no formal guaranteed BDW-GC will collect everything. Greetings, Maxime

Re: Need help embedding Guile

2021-12-21 Thread Maxime Devos
Hi, Maxime Devos schreef op di 21-12-2021 om 11:37 [+]: > >    approach above seems to correctly finalize all objects created > > as > > the Scheme > >    code executes, but if references are kept, say via (define), > > they > > are not > >    finalized and I get memory leaks. You can (set!

Re: Need help embedding Guile

2021-12-21 Thread Maxime Devos
Dimitris Papavasiliou schreef op di 21-12-2021 om 11:12 [+]: > [1...] > . The manual is not very specific about how and when finalizers are > run.  The >    approach above seems to correctly finalize all objects created as > the Scheme >    code executes, but if references are kept, say via

Need help embedding Guile

2021-12-21 Thread Dimitris Papavasiliou
Hi all, I'm in the process of embedding Guile in an application and although I seem to have the essentials working, I'd appreciate some confirmation of the validity of my approach and also some tips on a couple of loose ends. I won't bore you with the specifics of my application; for the