Laurent PETIT <laurent.pe...@gmail.com> writes: > 2009/7/24 pcda...@gmail.com <pcda...@gmail.com> > > On Jul 23, 10:15 pm, Richard Newman <holyg...@gmail.com> wrote: > > > Coming from an OO background which puts a strong focus on data > > > encapsulation, > > > this makes me a little nervous. > > > > The same problem exists with OO. > > Not to the same extent, unless you expose all the internals of your > classes (including fields) as public. > > > Java tries hard to hide the detail, yes, but it's still possible to use > reflection. > So it's just (as you stated) a fact of making it easy or difficult. > > But you should consider that everything you cannot find in the (doc) of > functions is not public API.
While I agree with what you say, I have a couple of problems with relying on doc strings to document private fields. Firstly, I don't write docs while prototyping. Secondly, docs aren't visible when browsing code. I've been using the convention of naming private fields with a trailing hyphen: {:foo "public" :bar- "private"} Here's a patch that adds syntax highlighting for this to clojure-mode. diff --git a/clojure-mode.el b/clojure-mode.el index 2d82ab6..7f1c28f 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -374,6 +374,8 @@ elements of a def* forms." "\\(\\sw+\\)?" ) (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)) + ;; Private keywords :foo- + ("\\<:\\sw+-\\>" 0 font-lock-constant-face) ;; Constant values. ("\\<:\\sw+\\>" 0 font-lock-builtin-face) ;; Meta type annotation #^Type -- jan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---