Naming style question

Discussion of Common Lisp

Naming style question

Postby findinglisp » Sun Jul 13, 2008 5:00 pm

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?
Cheers, Dave
Slowly but surely the world is finding Lisp. http://www.findinglisp.com/blog/
findinglisp
 
Posts: 440
Joined: Sat Jun 28, 2008 7:49 am
Location: Austin, TX

Re: Naming style question

Postby Ramarren » Sun Jul 13, 2008 11:59 pm

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.
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland


Return to Common Lisp

Who is online

Users browsing this forum: Google [Bot] and 2 guests