help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need advice for naming practice for namespaces in Elisp.


From: Oleksandr Gavenko
Subject: Re: Need advice for naming practice for namespaces in Elisp.
Date: Thu, 07 Feb 2013 21:04:29 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

On 2013-02-06, Stefan Monnier wrote:

>> I read very small amount of elisp code and found practice to put '->'
>> in the name of elisp var/func:
>
> I use -> sometimes, typically for access to a struct's fields.
> This comes from my learning lispy languages via Scheme.
>
Thanks for interesting answer!

>> Also I search for dot in names:
>
> I (strongly) recommend against the use of "." in symbols.
> "(erc-response.sender)" could also be interpreted as "(erc-response
> . sender)" and historically Elisp has not been very good at resolving
> this ambiguity in a reliable way.
>
OK. Thanks for advice.

I start from dot as separator to mimic OOP language syntax... And found that
evaluation of:

  (defun foo.?bar () ())

by C-x C-e produce:

  foo\.bar

in message buffer. Same for 'foo?bar' name. Why '\.' or '\?' was printed?

(info "(elisp)Symbol Type") have:

     A symbol name can contain any characters whatever.  Most symbol names
  are written with letters, digits, and the punctuation characters
  `-+=*/'.  Such names require no special punctuation; the characters of
  the name suffice as long as the name does not look like a number.  (If
  it does, write a `\' at the beginning of the name to force
  interpretation as a symbol.)  The characters `_~!@$%^&:<>{}?' are less
  often used but also require no special punctuation.  Any other
  characters may be included in a symbol's name by escaping them with a
  backslash.

>> and for colon:
>
> Colon is typically used in a Common-Lisp way, to separate the "module
> name" from the specific definition.
>
>> Seems that official sources don't often use special marker to separate
>> package name and command and some times uses '->', ':' and '.'
>
> Common usage is to use "-".
>
I complete agree.

Also I forget to mention about '/' char:

  ./cedet/ede/ede-locate.el:307:  (cedet-idutils-create/update-database root))
  ./cedet/ede/ede-locate.el:347:  (cedet-cscope-create/update-database root))

And become understand that really have another question...

I write code which have distinct parts, so use prefixes:

  blog4y
  blog4y-chuck
  blog4y-serv

I want be able to recognise them from each other, so instead of:

  blog4y-init        ; blog4y
  blog4y-chunk-write ; blog4y-chunk
  blog4y-serv-show   ; blog4y-serv

use something like:

  blog4y-init        ; blog4y
  blog4y-chunk:write ; blog4y-chunk
  blog4y-serv:show   ; blog4y-serv

But this code is ugly:

  blog4y-serv:mode
  blog4y-serv:mode-map
  blog4y-serv:font-lock-keywords

and break elisp conventions... So what I really need is to make prefix visible
and distinct from rest part of name, like:

  blog4y-init        ; blog4y
  blog4y*chunk-write ; blog4y*chunk
  blog4y*serv-show   ; blog4y*serv

or use any other `-+=*/_~!@$%^&:<>{}?' allowed non-usual symbol.

Seems that any personal choice will be good...

Again thanks all for replays!

-- 
Best regards!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]