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

Re: Dylan's direction



In article <383459D3.A9EB6AF1@openscript.com>, James
<james@openscript.com> wrote:

> The performance question is a good one. Compiled dylan should give us
> a performance edge, but it would only be compelling if there were some
> cool tools which make creating cgis, or dynamic pages a snap. For
> instance, I use perl for most of my web projects because it deals with text
> better than dylan. I can't figure out a way to translate this perl code:
> 
> sub Template {
>     local(*FILE);         # filehandle
>     local($file);         # file path
>     local($HTML);         # HTML data
> 
>     $file = $_[0] || bail "Template : No template file specified\n";
> 
>     open(FILE, "<$file") || bail "Template : Couldn't open $file : $!\n";
>     while (<FILE>) { $HTML .= $_; }
>     close(FILE);
> 
>     $HTML =~ s/<!-- \$(\w+) -->/${$1}/g;
> 
> return $HTML;
> }

The only tricky thing there -- from a language point of view rather than a
"what's buit-in" or "what libraries are there" point of view -- is using
the text in a variable as the name of another variable.  In Dylan you'd
need to use an associative array.  In fact I would have done that in Perl
as well, because the above code is insecure and allows you to get at
*anything*.

Unfortunately, in Perl using a hash would probably be slower, because it
would involve more code being interpreted.


> into a compiled dylan program and still maintain the flexibility I have
> with perl. In fact, a lot of these web scripting languages offer the
compelling
> feature of allowing code to be kept inside HTML template file, which are
> much easier to use and manage than large blocks of HTML kept inside
> programs. It would be wonderful if we could create a mod_dylan which
> would work like mindy, for the quick hack; and also have the compiled
> code option for those people who need it.

A "mod_dylan" could perfectly well use d2c.  It could keep the compiled
code in a database (which might just be the filesystem) and only recompile
when either the web page as a whole, or the actual code itself, changes.

-- Bruce



References: