This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Guile web page scripting, anyone?
- To: geoff at aspforums dot com
- Subject: Re: Guile web page scripting, anyone?
- From: Maciej Stachowiak <mstachow at alum dot mit dot edu>
- Date: Tue, 04 Jan 2000 03:15:49 -0800
- CC: guile at sourceware dot cygnus dot com
- References: <001901bf50ae$f1230940$d08701d4@marburg>
Geoff wrote:
>
> I suppose the main one is how do I get Guile to interpret the code?
> Now, it's not as dumb a question as it appears. What I really want is a
> library that'll allow something like:
>
> initialise_guile () -- does all the difficult startup stuff, just
> executed once per web server
Unfortunately there is nothing like this. However, a while back I wrote
a patch to add support for a gh_init() call which could be used this way
instead of using gh_enter(). I will check in this code in the course of
catching up on the the general Guile patch backlog.
> create_instance () - does any initialisation required to set up a new
> instance of Guile for each web page we're working with.
Guile does not support the creation of multiple separate interpreters in
one program. However, with the first-class environment patch, you should
be able to evaluate code in a fresh environment each time to get much the
same effect. A patch for this is also on my queue.
> evaluate_line () - takes a line of text and evaluates/interprets it.
> It can handle incomplete lines.
>
> Also, I have one line of the code buffered into memory. I'd like to be
> able to call a function to have it evaluated, or 'partially evaluated'
> so I can let the web developer know which line caused an error. Is
> there a way of doing this? The only method I can find that comes close
> is gh_eval_str (), but it requires the code be complete (all parentheses
> balanced). This limitation would also hamper web developers who want
> HTML to be output conditionally, but that's another story...
It may work best to translate the whole web page with embedded Scheme into a
Scheme program first, and then evaluate the whole thing. This is how JSP works,
essentially - it translates the JSP file to a Java source file, then compiles it
and runs the code (see, translators _are_ practical :-).
> Finally, I try and avoid high-scoping variables, but it looks like I'm
> being forced into using one here. The current way I'm doing it is:
>
> 1. my module receives a request
> 2. it reads and outputs the HTML until it gets to one of the special
> tags.
> 3. it reads in the code embedded in the page.
> 4. it fires up Guile, with the special guile_main () method.
> 5. the guile_main () method calls guile to interpret the code.
>
> The problem here is that the parsing of the file is done at point 2.,
> and the code is read in at point 3. How do I pass this through gh_enter
> () at point 4. so it's available for my guile_main () method to use in
> point 5., without using a module-scope variable?
I'm not entirely sure what you mean. What needs to be stored in a module-scope
variable?
> Boy, this turned out to be longer than I expected. The questions are
> clear in my head, but I'm not sure how well they came across here. By
> all means rant at me if I've been unclear.
>
> I do think this is worth pursuing though - a standard for 'Guile Server
> Pages' (or 'GNU Server Pages', or whatever) could benefit everyone as
> well as raise Guile's profile. And the ability to use different
> languages would be very cool indeed.
>
> Thanks for listening - any help gratefully received.
The JSP standard at least theoretically allows for different embedded
languages. ASP may, as well. If there is a standard for this sort of thing
which the Guile version could follow, that may be a good approach. Another
useful code base to look at would be Meta-HTML (www.metahtml.org) which is
a Lisp-like language but with HTML-like syntax.
Thanks for working on this! Server-side web scripting is an important
application for Guile.
- Maciej