in reply to Mapping URLs to code - in search of perlish dispatch schemes
I am coming to like this URL matching even more... :) are there any polymorphic lessons to be learnt from other OO languages that might help?
Another thought springs to mind - is there a place for a hierarchy in your interface? It might also assist in despatch efficiency, or even just remind the using programmer to consider despatch efficiency. I don't know if it would have any relevance to handling multi- matching despatches - maybe this is how you specify a multi-despatch?
etc# flat /edit?name=(\w+);city=(\w+);... { $r->print "Edit '$name' in '$city'"; }; /edit?name=(\w+);job=(.*);... { $r->print "Edit '$name' who does '$job'"; }; # hierarchical1 /edit => [ name=(\w+);city=(\w+);... { $r->print "Edit '$name' in '$city'"; }, name=(\w+);job=(.*);... { $r->print "Edit '$name' who does '$job'"; }, ] # hierarchical2 /edit => [ name=(\w+);... => [ city=(\w+);... { $r->print "Edit '$name' in '$city'"; }, job=(.*);... { $r->print "Edit '$name' who does '$job'"; }, ], ] # hierarchical3 /edit => { /contact => [ name=(\w+);city=(\w+);... { $r->print "Edit '$name' in '$city'"; }, name=(\w+);job=(.*);... { $r->print "Edit '$name' who does '$job'"; }, ], /basket => [ items=[(\w+)];... { $r->print "Edit items in basket"; }, delivery=(\w+);... { $r->print "Edit delivery details"; }, ], }
|
|---|