tag:blogger.com,1999:blog-4110180.post9154062759315275079..comments2023-06-20T05:31:24.545-07:00Comments on Tapestry Central: Named Parameters for ClojureAnonymoushttp://www.blogger.com/profile/04486596490758986709noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-4110180.post-81456674720251341992015-08-04T03:20:46.820-07:002015-08-04T03:20:46.820-07:00You say the "second function should dispatch ...You say the "second function should dispatch more intelligently". But it is quite difficult to achieve the semantically desired behavior, and that's precisely the point.<br /><br />The crux of the problem is that `nil` is used to represent the absence of an optional input, but when you pass this along, the receiving function doesn't interpret the `nil` as the absence of an input. In fact, there is no good way to pass in any value that represents the input is missing, other than simply not passing in the input. So there's no convenient way to bundle up a bunch of possibly present and possibly missing values and pass them along to another function in a way where it can recognize which were present and which were missing. Taking cases on every nil value and making different dispatch calls would just be a crazy way to do it. Mark Engelberghttps://www.blogger.com/profile/05992502488191304160noreply@blogger.comtag:blogger.com,1999:blog-4110180.post-18618697398474115282015-05-05T07:27:00.404-07:002015-05-05T07:27:00.404-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/04999696171524109943noreply@blogger.comtag:blogger.com,1999:blog-4110180.post-69029689894432836022013-09-23T18:16:42.333-07:002013-09-23T18:16:42.333-07:00Unfortunately, named parameters don't always c...Unfortunately, named parameters don't always compose well. If you call from one function with optional args to another, the :or map doesn't fill in the missing values.<br /><br />(defn named-params<br /> [& {:keys [foo bar]<br /> :or {foo "foo-default" bar "bar-default"}}]<br /> {:output-foo foo :output-bar bar})<br /><br />(defn named-params2<br /> [& {:keys [foo bar]}]<br /> (named-params :foo foo :bar bar))<br /><br />=> (named-params2)<br />{:output-foo nil, :output-bar nil}Mark Engelberghttps://www.blogger.com/profile/05992502488191304160noreply@blogger.comtag:blogger.com,1999:blog-4110180.post-87000963440264413702013-09-23T17:17:29.548-07:002013-09-23T17:17:29.548-07:00Prismatic has a good impl of this in their plumbin...Prismatic has a good impl of this in their plumbing library as defnkClifhttps://www.blogger.com/profile/14119688189797597601noreply@blogger.com