[erlang-questions] a little meta-programing help

anders conbere aconbere@REDACTED
Mon Oct 6 20:42:51 CEST 2008

On Mon, Oct 6, 2008 at 11:26 AM, Bryan Fink <bryan.fink@REDACTED> wrote:
> On Sun, Oct 5, 2008 at 7:31 PM, anders conbere <aconbere@REDACTED> wrote:
>> On Sun, Oct 5, 2008 at 4:12 PM, Antoine Koener <antoine.koener@REDACTED> wrote:
>>> On Mon, Oct 6, 2008 at 12:15 AM, anders conbere <aconbere@REDACTED> wrote:
>>>> Today I sat down to try to make working with mochiweb a little cleaner
>>>> for myself. I wanted a way to specify a list of mappings between url
>>>> patterns and methods to be called with the matched variables from
>>>> them. I quickly ran into issues with not being able to create patterns
>>>> dynamically, and then tried using funs to wrap that functionality but
>>>> pretty soon I was back at the same mess I started with.
>>> I used the list_to_atom fun to build the module name.
>>> This is not recommended but it's still really useful:
>>> check out: http://easyerl.blogspot.com/2008/07/my-mochiweb-webservice.html
>> Yeah, so I'm working more under the presumption that I can specify the
>> route to the module for each mapped url pattern. I'm not supper
>> interested in mapping urls to modules from the actual url text.
> Hi, Anders.  I might suggest that you take a look at the webmachine
> project.  It has a module that does dispatch and binding on URLs, and
> is built on top of mochiweb.  I'm not sure if it's exactly what you're
> looking for, but it's in the same vein.
> Take a look at webmachine_dispatcher.erl from
> http://code.google.com/p/webmachine/
> Details about its dispatch configuration syntax are here:

Interesting it looks like it does what I was considering which is
writing matching code specifically for this. It seems like there are
many good reasons to expose more of erlang's pattern matching tools to
developers. I'm not sure historically what the reason behind not
exposing the matching primitives is, but it would certainly make
metaprogramming in erlang a ton easier.

~ Anders

> http://code.google.com/p/webmachine/wiki/DispatchConfiguration
> -Bryan
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list