[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 0/4] Add import builtin
From: |
Koichi Murase |
Subject: |
Re: [PATCH 0/4] Add import builtin |
Date: |
Fri, 3 May 2024 12:25:26 +0900 |
2024年5月3日(金) 11:17 Lawrence Velázquez <vq@larryv.me>:
> If "import" were qualitatively different from "source" (say it
> integrated some sort of namespace functionality), then it would be
> more compelling.
That sounds interesting. It's a bit unrelated to the main discussion,
but I was wondering if it is possible to allow expansions in the
function name <name> in the function definition "function <name>
<compound>". Zsh allows it:
$ zsh -c 'ns=mynamespace; function $ns/util1 { echo This is util1; };
mynamespace/util1'
This is util1
This is just a hypothetical feature, but if we have a PATH-like
variable (e.g. BASH_FUNCTION_PATH or BASH_FUNCTION_NAMESPACE) for the
function name search, one can set « local
BASH_FUNCTION_PATH=mynamespace » to make `mynamespace/util1' visible
with the name `util1'.
But a problem of such a variable-based approach is that the namespace
is resolved by a dynamic condition (i.e. the variable in the context
when it is called) instead of the lexical context (i.e. where the
caller is defined or to which namespace the caller belongs). Maybe `.'
in BASH_FUNCTION_PATH can be treated as any namespace the caller
belongs to.
----
By the name "import", I expect also something like an include guard,
i.e., it loads the same file only once at most. I have a
shell-function implementation,`ble-import', in my framework. It
doesn't support namespace, but it supports the include guard. It also
accepts a setting for the paths to search. It also has a feature like
`with-eval-after-load' of elisp (or the "onload" event).
--
Koichi
- [PATCH 0/4] Add import builtin, Matheus Afonso Martins Moreira, 2024/05/02
- [PATCH 1/4] builtins: extract file content executor function, Matheus Afonso Martins Moreira, 2024/05/02
- [PATCH 3/4] findcmd: define the user import finder function, Matheus Afonso Martins Moreira, 2024/05/02
- [PATCH 4/4] builtins: add import builtin, Matheus Afonso Martins Moreira, 2024/05/02
- [PATCH 2/4] findcmd: parameterize path variable in functions, Matheus Afonso Martins Moreira, 2024/05/02
- Re: [PATCH 0/4] Add import builtin, Dale R. Worley, 2024/05/02
- Re: [PATCH 0/4] Add import builtin, Lawrence Velázquez, 2024/05/02
- Re: [PATCH 0/4] Add import builtin, Koichi Murase, 2024/05/02
- Re: Re: [PATCH 0/4] Add import builtin, Matheus Afonso Martins Moreira, 2024/05/03
- Re: Re: [PATCH 0/4] Add import builtin, Koichi Murase, 2024/05/03
- Re: Re: Re: [PATCH 0/4] Add import builtin, Matheus Afonso Martins Moreira, 2024/05/03
- Re: Re: Re: [PATCH 0/4] Add import builtin, Koichi Murase, 2024/05/03
- Re: Re: Re: [PATCH 0/4] Add import builtin, Matheus Afonso Martins Moreira, 2024/05/03
- Re: Re: Re: [PATCH 0/4] Add import builtin, Koichi Murase, 2024/05/04