See:

http://richhickey.github.com/clojure-contrib/def-api.html#clojure.contrib.def/defnk

On Apr 6, 2:25 pm, Sophie <itsme...@hotmail.com> wrote:
> Please don't misunderstand this post - it is not asking for a change
> of syntax, just trying to understand something.
>
> Clojure has chosen positional parameters (just like for Lisp, C, C++,
> Java, Ruby, Python, Prolog, ...)
>
> Smalltalk composes a full method name from a prefix-name + named
> parameters.
>    [obj]  prefix key1: x key2: y key3: z
>
> The [obj] part above is an artifact of the single-dispatch model, and
> is irrelevant to this discussion, so I'll leave it out from here on.
> Importantly, the method name here is a composite:
>    #prefix:key1:key2:key3
>
> This leads to remarkably readable function calls:
> 1.   (schedule project: p1 after: p2 before: p3 priority: 7)
>       ;; calls schedule:project:after:before:priority
> vs.
> 2.   (schedule p1 p2 p3 7)
>
> Note that 1. in no way requires arbitrary ordering of keywords, maps,
> de-structuring, etc. The positions are still fixed, just keyword-
> prefixed. It's like taking the Clojure parameter list
>     (defn schedule
>           [project before after priority] ....)
> and requiring those parameter names (or a formal version thereof which
> is meant to be part of the interface) at the calling sites.
>
> An only-slightly-strained analogy would be only allowing %1 %2 for
> formal parameters in all function bodies
>     (defn schedule [%1 %2 %3]
>           (.... stuff with %1 %2 ...))
> or
>    (deftype Person [name age])
> and then requiring
>    (1 joe)   instead of   (:name joe)
>
> Just curious
>   - what folks think of fixed-positional-keyword params
>   - whether it was considered for Clojure
>
> Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to