guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Web Development with Guile in HB


From: Jorgen 'forcer' Schaefer
Subject: Re: Web Development with Guile in HB
Date: 12 Nov 2000 11:47:23 +0100
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7

Alejandro Forero Cuervo <address@hidden> writes:

> I'm the primary author of Hyper Builder (HB), a free web development
> platform useful to generate dynamic (server-side) content.
> 
> In the latest unstable version (1.9.24), we have added support for
> embedding Scheme code in HB source files using Guile.  The syntax for
> HB files is very simple and, along with HTML, is all that one needs to
> know in order to generate dynamic web content using Scheme.

Great!

> 1. Is there any workaround to having to call a function that never
>    returns (such as gh_enter or scm_boot_guile)?

There's a stack finding procedure in the latest CVS version of
guile.  It makes scm_boot_guile and gh_enter deprecated (maybe
useful on some obscure platform).  You can just call
scm_init_guile().

> 2. How can I make functions such as `display' call my callback
>    functions rather than print to stdout?  In an application server,
>    such as HB, printing to stdout is stupid.  I want to capture
>    whatever output the Scheme code produces and add it to some
>    buffers.  Redefining those functions (how?)?  Or can I call some
>    functions to set my callback function so it gets called rather than
>    something that calls write/printf?

The easiest thing is to define your own port type (that's a bit
hairy, UTSL for now :|), and set-current-output-port! that one.

> 3. How can I define procedures (as with gh_new_procedure) in a way
>    such that my callback functions get passed a given void pointer I
>    specify?  This is necessary because HB uses multiple threads to
>    attend requests simultaneously so my functions need to know which
>    was the HTTP request that caused them to be called.  For example,
>    in the previous question, my function needs to know what buffer it
>    should work with.

Either you pass the void pointer as a smob to your functions, or
you define a thread-global variable which contains your state.

> 4. Is Guile reentrant/thread safe?   Or should I wrap all calls to
>    Guile functions with a mutex/lock?  In case it can be compiled both
>    ways, how can I find out how it was compiled?

Guile is *not* thread safe -- yet.  You can use it safely from
one thread, but only one.  This is going to be fixed RSN :]

> 5. How can I use multiple environments/contexts/name-spaces?  So if HB
>    executes some code in some file with a few (define)s, only that
>    code can see them.

>From NEWS:
| ** It's now possible to create modules with controlled
| environments
| 
| Example:
| 
| (use-modules (ice-9 safe))
| (define m (make-safe-module))
| ;;; m will now be a module containing only a safe subset of R5RS
| (eval-in-module '(+ 1 2) m) --> 3
| (eval-in-module 'load m) --> ERROR: Unbound variable: load

In effect, you just create a new module, and import the bindings
you want to it.

There should be first-class-environments in guile soon,
too.  (the new module system needs them)

I hope i could help you,
        -- forcer

-- 
((email . "address@hidden")       (www . "http://forcix.cx/";)
 (irc   . "address@hidden (IRCnet)") (gpg .    "1024D/028AF63C"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]