all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Oleksandr Gavenko <gavenkoa@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Need advice for naming practice for namespaces in Elisp.
Date: Thu, 07 Feb 2013 21:04:29 +0200	[thread overview]
Message-ID: <87pq0cx7wi.fsf@gavenkoa.example.com> (raw)
In-Reply-To: jwv4nhpff5g.fsf-monnier+gmane.emacs.help@gnu.org

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	other threads:[~2013-02-07 19:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-05 20:44 Need advice for naming practice for namespaces in Elisp Oleksandr Gavenko
2013-02-06  6:42 ` Drew Adams
2013-02-06 18:59 ` Stefan Monnier
2013-02-07 19:04   ` Oleksandr Gavenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pq0cx7wi.fsf@gavenkoa.example.com \
    --to=gavenkoa@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.