This is the mail archive of the guile@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Capturing main - a heretical experiment.



>>>>> "satchell" == satchell  <satchell@merry.dera.gov.uk> writes:

    satchell> As I understand it, guile needs to capture main to find
    satchell> the top of stack. This is so the GC can scan for
    satchell> possible SCM values, that may be roots. Scanning the
    satchell> whole stack is obviously safe, but may not be needed. If
    satchell> you can prove that there are no SCM values above the
    satchell> point where guile is started, then you can avoid
    satchell> scanning the stack.

    satchell> I tried this as a trivial hack. I took a biggish X+Motif
    satchell> progrramme, and left all of main unchanged, except the
    satchell> last line, where it would jump into the event loop
    satchell> (XtAppMainLoop). I put scm_boot_guile there, and ran the
    satchell> event loop inside the inner main. Guile booted, and the
    satchell> application still ran normally.

This is not different from putting scm_boot_guile() just after main().
The whole problem is the following: you CANNOT currently link directly
some extension library of your own +
libguile.a (or dynlink libguile.so) to an existing application, call
some scm_init() function and then safely use all the gh_* or scm_*
functions. You currently NEED to modify the SOURCES of the application
you are extending to capture one function of its code, which you will
not be allowed to return from.

Actually, you COULD return from, (modify gh_launch_pad and scm_shell
to return, not exit), but calling guile functions after that will
certainly lead to disaster.

    satchell> Obviously this is trivial, and a better test requires
    satchell> doing no trivial work in guile. But my beleif is that
    satchell> you can run arbitary C code before starting guile
    satchell> provided you follow these rules.

    satchell> 1) No SCM globals.  2) No SCM variables in any code that
    satchell> runs before starting guile.  3) Don't try to sneak round
    satchell> 1+2 by casting!

Yes, but only if you set their value from guile code.

Regards.

-- 

B. Urban




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]