4 ms·
Sure, sure. But while it's definitely not in the standard, I do see it all over, and it's something I picked up from reading a lot of other people's lisp. SBCL
by vzcx 9y ago
Sure, sure. But while it's definitely not in the standard, I do see it all over, and it's something I picked up from reading a lot of other people's lisp. SBCL internals, for example. You might not like the convention and chose not to follow along with it, but I would be surprised if, after 18 years of lisp, you had never seen it before, and would choose to misspell an accessor to prevent a clash instead of naming it differently.
Edit: ah, I think I understand. I don't mean to imply that all accessors should be named in this way. That would be gross.
- kazinator 9y agoI've never seen this outside of internals. In application code, this is just a smell. To prevent clashes, there are packages. What will you do if three or more modules want the same function name? Tack on %%, %%%, ...
- vzcx 9y agoOnly in implementation internals? I'm fairly certain I've encountered it in other unexported package symbols in library code, things like struct constructors where you want a "smarter" "make-my-struct" function. But perhaps I misremember. > What will you do if three or more modules want the same function name? Tack on %%, %%%, ... Certainly not! I think your points are all very fair: it would be a smell, and is evidence of a need for improvements at a more structural level. It just smells a little less than a seemingly purposeful misspelling to my nose.
- jjwiseman 9y agoTo be explicit, the old Lisp convention I know of, which is not a super common one but one I've definitely used quite a bit, is that you might name a slightly lower-level/more primitive version of a function with a %-prefix. So if we have a user-email function that is just an object slot accessor, We could have %user-email that actually does a database query. I can't remember for sure, but I wouldn't be surprised if I'd seen a double %%-prefix used, too. You don't always want to put those functions in separate packages (traditionally in Lisp, packages are relatively heavyweight--e.g. an entire web server framework might have only one or two packages). Another similar example might be the convention of defining a macro with the name my-macro, and a function that actually implements much of the macro, or is an equivalent of the macro that takes a thnk, that is named my-macro*. (24 years of lisp here--I wouldn't be surprised if the conventions of mainstream lisp during the earliest six years were somewhat different than the following decades.) Edited to add: Now that I think about it, this convention may have been heavily used in the Macintosh Common Lisp community.
- vzcx 9y agoThank you, and thank you to the grandparent. It's quite fantastic to be schooled by old-time lispers (only 6 years of lisp here).
- kazinator 9y ago> Macintosh Common Lisp community. That's why I linked to some CCL code (descendant of MCL). I use foo-impl and such for the implementation of foo. If I have a my-macro, which is implemented by an expander function, then I call that function expand-my-macro.