zsh-users
 help / color / mirror / code / Atom feed
* zsh best practices ?
@ 2006-05-26  8:49 Marc Chantreux
  2006-05-26 15:49 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Chantreux @ 2006-05-26  8:49 UTC (permalink / raw)
  To: zsh-users

Hi all,

is there a document about zsh coding style and best practices?

For exemple, i want to adopt a convention for private functions and
variables. Perl coders are using names beginning with _ but this is used
for completion functions in zsh. 

Is there another convention adopted?

regards,
mc


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: zsh best practices ?
  2006-05-26  8:49 zsh best practices ? Marc Chantreux
@ 2006-05-26 15:49 ` Bart Schaefer
  2006-05-29  8:19   ` Marc Chantreux
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2006-05-26 15:49 UTC (permalink / raw)
  To: zsh-users

On May 26, 10:49am, Marc Chantreux wrote:
}
} is there a document about zsh coding style and best practices?

Not really.

We should add something to Etc/zsh-development-guide discussing the
conventions for naming completion functions, widgets, etc. that go
into the distribution; I don't see anything in there about that.

} i want to adopt a convention for private functions and variables.
} Perl coders are using names beginning with _ but this is used for
} completion functions in zsh.
} 
} Is there another convention adopted?

It's a little more difficult with zsh than with perl because "private"
functions are still usually something you type on the command line,
not hidden in a libarary somewhere.  It's almost like asking if there
is a naming convention for files in the directories in $PATH.  The
completion system is a major exception to this.

One convention is to stick a "z" in front of anything that replaces a
similarly-named external command, but that doesn't help where the dist
has already adopted it.

I sometimes use *two* leading underscores, but only if I'm really worried
about a name collision.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: zsh best practices ?
  2006-05-26 15:49 ` Bart Schaefer
@ 2006-05-29  8:19   ` Marc Chantreux
  0 siblings, 0 replies; 3+ messages in thread
From: Marc Chantreux @ 2006-05-29  8:19 UTC (permalink / raw)
  To: zsh-users

Hi Bart,

Thanks for answer.

le 26/05/2006,
Bart Schaefer nous écrivait :
> We should add something to Etc/zsh-development-guide discussing the
> conventions for naming completion functions, widgets, etc. that go
> into the distribution; I don't see anything in there about that.

hope it will come soon.

> It's a little more difficult with zsh than with perl because "private"
> functions are still usually something you type on the command line,
> not hidden in a libarary somewhere.  It's almost like asking if there
> is a naming convention for files in the directories in $PATH.  The
> completion system is a major exception to this.

i know the difficulty of that and thought that long time zsh scripters
had already shared their tips.

> One convention is to stick a "z" in front of anything that replaces a
> similarly-named external command, but that doesn't help where the dist
> has already adopted it.
> I sometimes use *two* leading underscores, but only if I'm really worried
> about a name collision.

thinking about it, i've decided to mix both : "private" functions will
be prefixed by z__ and local vars will be prefixed by the name of their
function.

For exemple:
function z__association_compare
variable z__association_compare_current_key 

Thanks for clues and regards,
mc


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-05-29  8:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-26  8:49 zsh best practices ? Marc Chantreux
2006-05-26 15:49 ` Bart Schaefer
2006-05-29  8:19   ` Marc Chantreux

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).