[tbnl-devel] Re: Quick Question about Dispatch Handlers in TBNL
Edi Weitz
edi at agharta.de
Thu Jul 6 08:32:49 UTC 2006
Hi!
Please use the mailing list for questions about TBNL.
On Wed, 5 Jul 2006 22:55:08 -0500, Cameron Desautels <cam at apt2324.com> wrote:
> I have a quick question about TBNL that I am hoping you wouldn't
> mind helping me with.
>
> I'm a little surprised to see that TBNL does not contain a function
> which creates a dispatcher that matches an exact string (rather than
> a prefix or a regexp). Perhaps something like this?:
>
> (defun create-static-dispatcher (str page-function)
> "A convenience function which will return a dispatch function
> which will return `page-function' whenever the path portion of
> the URI matches the string `str'."
> (lambda (request)
> (if (string= (script-name request) str)
> page-function)))
>
> I'm somewhat curious what the reason for this omission is. Is it
> because the same functionality can be achieved with
> create-regex-dispatcher given a string with no wildcards? Certainly
> that method would be less efficient and isn't as (logically) clear.
> Am I missing something?
>
> Your enlightening reply is appreciated.
I've never needed such a function, but as you demonstrate above it is
trivial to build it yourself. I could add it to the next release if
people feel that it's a worthwhile contribution.
Concerning your remark about efficiency: Do you really think that the
speed difference between a regex scan and a string comparison (if
there is one) would be noticable in a web application?
Cheers,
Edi.
More information about the Tbnl-devel
mailing list