guile-user
[Top][All Lists]
Advanced

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

Re: Scheming over a PHP replacement


From: Bruce Korb
Subject: Re: Scheming over a PHP replacement
Date: Tue, 01 Jan 2002 00:39:28 -0800

Neil Jerram wrote:
> I haven't tried this out, but it looks interesting.  I hope you won't
> mind if I make two high-level comments:

I rarely object to comments.  :-)  Thank you...

> - I'd really like to see some consolidation in the Guile-related web
>   server and scripting market.  ... couldn't you all work together?

AutoGen has been in existence in one form or another for about
6 years.  Guile was a bit green.  I added Guile as the AutoGen
scripting language a little over two years ago.  What I just did
was enable it to accept name/value definitions via GET/POST
CGI methods, in lieu of its "traditional" assignment syntaxes.
i.e.:
   \'(jumble ((foo "bar") (mumble "bumble")))
or:
   jumble = { foo = bar; mumble = bumble; };
XML is under active consideration, too.

> - I don't quite like the specialness of your "while" form.  More
>   generally, I don't think you've quite cracked the (very desirable)
>   nut of being to integrate, in the same file, both static HTML code

AutoGen is not specific to HTML or anything else.  I selected "<?" and
"?>" as my example markers only because it blends with
HTML and it corresponds to what PHP uses.  Each template can specify
the start/stop markers any way that is both convenient and unambiguous.
The concept is that the Scheme code is embedded in a template.
That template describes whatever output is desired.  This is completely 
analagous to what PHP does, except PHP is pretty much hard wired
to HTML type output and has a C-ish type of PHP-only extension language.

AutoGen's peculiarities are limited to:

  IF/ELIF/ELSE/ENDIF
  CASE/SELECT/ESAC
  WHILE/ENDWHILE
  DEFINE/ENDDEF/INVOKE
  INCLUDE
  COMMENT

and I've not encountered any need to expand these for years.

>   and HTML code which is generated dynamically by Scheme code.  Is
>   this possible?

Without any changes at all, it is possible to:

  <?  (define value "")
      (do all kinds of things to 'value'....)
      value  ?>

and everything between the "<?" and "?>" will be replaced with
whatever you wound up assigning to 'value'.  However, one of the
points of PHP and AutoGen is that you specify most of the output
text directly and only insert expressions here and there where
you want to compute a text fragment.  The goal is to avoid being
balled up in working out program logic in order to emit several
variations on a block of text.

I would like to refer you to this page with a couple caveats:

1.  As a PHP replacement, the definitions would come from form
    submissions, so they would be flat instead of hierarchical
2.  The example output is C code, instead of HTML.  AutoGen is
    output type agnostic.

  http://Autogen.SourceForge.Net/doc/autogen_1.html#SEC3

Neil Jerram wrote:
> I'm working on a (java/kawa based) system which has a nice easy
> syntax. It abandons the idea of special tags and instead opts for
> expressing dynamic parts of pages with a special 'scheme' attribute.
> 
> A sample page might look like this:
> 
> <html>
> <body color="&(select-color)">
> <table>
> &(let ((parameter-list (get-request-params))

I would suggest that you do have a special marker:  ``&(''
and the end marker is found with a lexical scan.  I opted
against this form for AutoGen because I wanted the text
that would be repeated to follow the same mechanism as the
document as a whole.  Specifically, template text to be
emitted unchanged lay outside of the scripting text.
My goal was to minimize to the extent possible the
programming logic needed to repeat and select blocks of
template text.  Unless you are a full-time schemer, this:

  <table>
  &(let ((parameter-list (get-request-params))
       (proc
         (lambda ()
           (if (not (null? parameter-list))
               `( <tr> <td> name </td> 
                  <td> ,(pop parameter-list) </td>
                  <td> value </td>
                  <td> ,(pop parameter-list) </td> </tr> )))))
        proc)
  </table>

is less obvious than this:

  <table><?
    FOR parm-list  ?>
    <tr><td><? parm-name  ?></td>
        <td><? parm-value ?></td><tr><?
    ENDFOR ?>
  </table>



reply via email to

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