zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Ksh emulation and function names
Date: Wed, 29 Nov 2023 16:15:43 -0800	[thread overview]
Message-ID: <CAH+w=7b6iYJAGLjQHoOc2O7nwow_e8saamyiOTohSZK6uT-HRQ@mail.gmail.com> (raw)

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.


                 reply	other threads:[~2023-11-30  0:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CAH+w=7b6iYJAGLjQHoOc2O7nwow_e8saamyiOTohSZK6uT-HRQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.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 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).