Page 1 of 1

Naming style question

Posted: Sun Jul 13, 2008 5:00 pm
by findinglisp
Okay, I'm working on a package that is going to have a set of read/write functions for a data type. What do you as a programmer prefer in terms of naming conventions:
  • Name the functions READ-FOO and WRITE-FOO for the foo data type
  • Name the functions READ and WRITE and put them in the FOO package
Either way the functions are going into the FOO package.

The advantage of the first is that it's easier to identify that READ-FOO is operating on a foo data object. There is also less risk of name clashes when using the package from a calling package (won't conflict with CL:READ, for instance). Obviously, there are ways to fiddle with the package system to resolve the conflicts, but they're more typing.

The advantage of the second is that it's not redundant when you don't use the package (FOO:READ as opposed to FOO:READ-FOO) and there's generally less typing. The downside is that if you use the package you'll have to shadow things to avoid conflicts with CL:READ, for example.

So, which would you as a programmer using the package prefer to have to deal with?

Re: Naming style question

Posted: Sun Jul 13, 2008 11:59 pm
by ramarren
findinglisp wrote:So, which would you as a programmer using the package prefer to have to deal with?
I think that depends on how many other symbols the package has, and how often are they supposed to be used. If few and rarely, then they might just as well be prefixed, and hence READ and WRITE are good. If many and often, then USEing the package would be more likely, and so avoiding conflicts would be better.