zsh-workers
 help / color / mirror / code / Atom feed
* Ksh emulation and function names
@ 2023-11-30  0:15 Bart Schaefer
  0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2023-11-30  0:15 UTC (permalink / raw)
  To: Zsh hackers list

I hadn't put this particular set of ramifications together before, but
function names in ksh have to conform to parameter name syntax, which
means they can't begin with a "." unless referencing a namespace, and
if not referencing a namespace, they can't contain a "." unless what
follows it is a valid discipline function name for the variable.**
(If a function name both begins with and contains a dot, it refers to
a function inside a namespace, not a discipline, unless there are two
dots, in which case it's a discipline of a parameter in a namespace.
Urk.)

Ksh of course won't allow reference to namespaces that haven't been
declared, so that further limits function naming.  Zsh currently has
neither declared namespaces nor disciplines, so from that standpoint
it's not inconsistent that zsh allows function names that start with
and contain dots, but should this be mentioned somewhere?  (E.g., ksh
differences in the FAQ?)  Or not worth the effort?

The ksh93 "functions" builtin prints all functions that are in
namespaces, unlike "typeset" which defaults to skipping parameters in
namespaces (except see below).  So, also not inconsistent that zsh
"functions" includes names beginning with a dot.

Related curiosity:  In my (Ubuntu) install of ksh93, "typeset" output includes

readonly .sh

This is somewhat odd because it's the only "variable name" starting
with a dot that is included in this output, and also because there's
no restriction on (for example) creating new functions in the ".sh"
namespace, so except (I guess) that you can't "unset .sh" (whatever
that would mean), it doesn't behave as though it's read-only.

** Declaring a compound type allows creating additional disciplines.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-30  0:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-30  0:15 Ksh emulation and function names Bart Schaefer

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).