Liste des Groupes | Revenir à cl forth |
On Thu, 3 Jul 2025 20:47:07 +0400
Ruvim <ruvim.pinka@gmail.com> wrote:
Yes, something like "private[ ... ]private" is a possible approach,
and its implementation seems simpler than adding the smarts to `:`
and `;` (and other defining words, if any).
>
The advantage of this approach over "<: ... ;>" is that you can
define not only colon-definitions, but also constants, variables,
immediate words, one-time macros, etc.
>
>
: foo ( F: r.coefficient -- r.result )
private[
variable cnt
0e fvalue k
: [x] ... ; immediate
]private
to k 0 cnt !
...
;
>
It's also possible to associated the word list of private words with
the containing word xt for debugging purposes.
>
>
In lxf I have module, private, public, end-moduleI usually take this approach too.
your example would be
module
private
variable cnt
0e fvalue k
: [x] ... ; immediate
public
: foo ( F: r.coefficient -- r.result )
to k 0 cnt !
...
;
end-module
end-module will remove all headers from the private words in the module
I am not found of mixing definitions inside others.By the way, local variables slightly break this principle. Also, conceptually, a module definition contains definitions of other words and possibly nested modules. And, conceptually, there is nothing wrong with defining a module as a colon-definition.
Les messages affichés proviennent d'usenet.