Well, even in this case how do lisp programmers typically name their
structs vs their variables?  In java I could make an "Employee" class
and then an "employee" object and it was easy to distinguish between
the two.  If it's not kosher to uppercase a struct, what's the
convention for something like that?

On Mar 19, 6:38 pm, ataggart <alex.tagg...@gmail.com> wrote:
> As the doc for 'accessor notes, you should really eschew this stuff
> altogether, and be more idiomatic by just using the keyword.  If you
> absolutely know that you need that "(slightly) more efficient" access,
> thennamingthe struct with an uppercase first letter works, and isn't
> too uncommon; besides this is a special-case performance issue, right?
>
> On Mar 19, 4:36 pm, strattonbrazil <strattonbra...@gmail.com> wrote:
>
> > If am creating accessors to access structures, how should they be
> > named?
>
> > (defstruct employer :employee)
> > (defstruct employee :employer)
> > (def employee-name (accessor employee :employer))
> > (def employer-name (accessor employer :employee))
>
> > In a situation where one struct is pointing to the other, is that the
> > best accessor name?  Since structs are lower case do they clash with
> > variables and accessors ever?  I could easily see myself doing
>
> > (def employee (...))
>
> > Here, I assume it won't have any problems, but does it become
> > problematic later?  Especially since it seems that accessors can be in
> > either order.
>
> > (defstruct vert :id :edgeId)
> > (defstruct edge :id :vertId)
> > (def vert (accessor edge :vert))
> > (def edge (accessor vert :edge))
>
> > I know this could be easily resolved by changing the accessor
> > definitions to get-vert and get-edge, but I was hoping it wouldn't be
> > necessary.  Once again, I'm bound to have a variable somewhere in my
> > code called vert and edge.  Java and Scala don't seem to have this
> > problem.  Especially using Scala's builtin getter setter feature,
> > which has strick ordering like
>
> > edge.vert // returns the vert for this edge
> > vert.edge // returns the edge for this vert
>
> > Is there a betternamingconvention to follow?  get-vert and get-
> > edge?  Should structures ever be uppercase to distinguish them?  That
> > doesn't seem to be the lisp convention.  In these cases it seems the
> > struct name would
> > never be a problem, but it seems I'm stuck between making a convenient
> > accessor name and easily stomping over if making a convenient variable
> > name.

-- 
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 from this group, send email to 
clojure+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to