I think using a naming convention isn't a good idea, especially when you have a rich macro system like Clojure. I'm actually going to be talking about using a reference to handle things like this in my next episode. For now, you can take a look at my definference macro here:
http://github.com/francoisdevlin/devlinsf-clojure-utils/blob/master/src/lib/sfd/equations.clj Hope this helps, Sean On Feb 25, 8:59 pm, joshua-choi <rbysam...@gmail.com> wrote: > Yeah, I don’t really like the underscores either. But I have to work > with the set of currently allowed non-alphanumeric symbol characters > (*, +, !, -, _, and ?, according to clojure.org/reader). > > There’s actually two different questions here—I’d love for other > people to bring in their input. > > I need to set apart “rules”, a certain type of object, from other > kinds of Clojure objects. ("Why do you even need to do this?" people > ask. Because I really want to graphically set them apart in the > programmers mind. And also, rules often shared names with objects that > they were representing: it was difficult to remember string-char-r vs. > string-char in functions, for instance. It was always a big pain. I > think it will be worth it.) > > Question 1: Of the allowed characters, which would be best to > distinguish rule symbols from other symbols? > > * can be confused with the REPL vars (*1, *e, etc.) and re-bindable > vars. > + may be a better choice, though in the other Lisps it already > indicates constants. > I don’t think ! and ? are good at all, because they really stand out > to me to mean destruction and querying respectively. > - is apparently used only once in the standard libraries: in defn-. > Maybe it would be a good choice. > _ is ugly, but it’s not used at all, so that’s good. Well, except when > used on its own: “_”, for useless bindings. > > I’m leaning toward +, -, or _. > > Question 2: Prefix, suffix, or circumfix? > > +vector, vector+, or +vector+? -vector, vector-, -vector-? Or > whatever. Don’t forget, I’m deciding this for my parser rules library. > “vector” means a rule that can parse strings representing vectors. > > Could everyone give me their opinion? Which annoys your taste the > least? I still have time to change the style in my library, and I’d > like to hear from as many people as possible. > > On Feb 25, 3:16 pm, Jarkko Oranen <chous...@gmail.com> wrote: > > > > > On Feb 25, 12:17 am, joshua-choi <rbysam...@gmail.com> wrote: > > > > When it comes to distinguishing certain types of symbols from other > > > things, should one use prefixes or suffixes? > > > Whichever makes more sense, of course. :) > > > > Example: naming tests with clojure.test/deftest. If you distinguish > > > your tests’ symbols at all, do you do “t-addition” or “addition-t”? > > > Name tests descriptively. Putting them in their own namespace helps > > too. If there's absolutely a need to distinguish them from non-tests, > > I would prefer '-test'. Abbreviating it just makes it noisy. > > > > (I need to know what the standard is, if there is any, because I need > > > a way to distinguish a certain type of symbol—those that represent > > > “rules”— in my libraries. I’m using an underscore suffix right now, > > > like “vector_”, which means “vector-rule” But “_rule” might be better, > > > or even “_rule_”, though the last one might be overkill. In the past, > > > I’ve used “vector-r", but I don’t like that now.) > > > I personally find underscores offensive, but... Some logic DSLs use ? > > foo for variables, maybe you could have something similar for you > > rules. Or you could name them using angled brackets (eg. <vector>). > > When it comes to naming, you just need to be consistent. And avoid > > underscores, please :P -- 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