On Tue, Jan 6, 2009 at 9:29 AM, Chouser <chou...@gmail.com> wrote:
>
> On Tue, Jan 6, 2009 at 10:18 AM, Mark Volkmann
> <r.mark.volkm...@gmail.com> wrote:
>>
>> I wish there was a convention for identifying constants in Clojure,
>> even if it's not enforced. I'd be fine with making their names all
>> uppercase as in Java, but I'm open to other suggestions.
>
> Vars are correctly used only two ways, aren't they?  Either meant for
> thread-local rebinding (*in*, *out*, *print-depth*, etc.) or not
> (filter, doseq, point-size, win-length).  The latter are about as
> constant as anything gets in Clojure.  If you try to change them with
> 'set!' get an exception "Can't change/establish root binding".  Other
> plain words generally also refer to constants (function formal args,
> locals).  So it seems to me the convention is that constants have
> plain names while things meant to be rebound and possibly 'set!' have
> *asterisks*.

Thanks for explaining that. I was using the asterisks incorrectly in
my snake code. I'll fix that.

>> My current habit is to use structmaps for anything that is similar to
>> a Java Bean where all the entries are used like attributes of a Java
>> object.
>
> The only benefit of structmaps (currently) is some space savings when
> you have lots of maps with the same keys but different values.  This
> comes at the cost of some flexibility (can't dissoc basis keys).

I think there is one other benefit of using structmaps. They document
the expected keys. In my snake example, I wanted a way to document
what a snake, apple and cell were in terms of their "attributes". For
example:

(defstruct snake-struct :alive :body :color :direction)

seems like good documentation to me.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to