On 08.09.2022 20:41, Spiros Bousbouras wrote:
On Thu, 8 Sep 2022 13:12:58 +0200
Janis Papanagnou <[email protected]> wrote:
On 08.09.2022 10:48, Spiros Bousbouras wrote:
[ ksh's typeset -t ]
So you're saying that tagging is just a boolean thing i.e. either
a variable is tagged or not.
Yes. It seems it's not more that that.
If that's the case then it's even
less useful than I thought. If you want to print the values of
some variables for debugging , you just print the values , I don't
see that it buys you anything to tag them first.
Not quite. My thought was along this (sample-)application...
typeset a ; ... ; typeset -t b c ; ... ; typeset d ; typeset -t e ;
... ; printf "*** Debug: %s\n" $( typeset -t ) ; typeset +t e ; ...
In other words, define the tag attribute when the variable is set
(or declared) and print all tagged variables later in "one place",
optionally adjust tags as necessary in the course of the executed
program. I.e. it would be a mark declaring it as "var is interesting
for debugging, logging, as intermediate result, ... (whatever)" and
separating that declaration semantics from the execution point of
interest.
[ hypothetical labels as in typeset -t label var ... ]
So you're thinking of the possibility of associating an arbitrary
tag with a variable. This is how I originally thought it works.
Yes, this is what one would naturally assume when talking about
tags and tagging. But obviously it's just an untyped flag. (My
picture about the [assumed] implementation in the shell is that
the type information may be just a bit-field representing { r/o,
integer, float, ..., and 'tag' }; anything else would require a
more complex data structure.)
So for example you could tag that a numerical variable is inches
and another cm .But even that would not be much useful unless the
shell offered many more capabilities like taking into account tags
before performing some operations. And in any case , such tagging
would be perhaps appropriate for a large project and I don't think
that a shell is a good language for a large project , tagging or
no tagging.
Well, as said, I think it could still be useful. Though not as
much as it could be, especially as rudimentary as it is provided.
For example, another application that I can think of being useful
would be to mark some variables as GDPR-relevant, then it could
be simply avoided to e.g. log or display values of such variables,
but that would require to have some inverse-logic flag available;
currently typeset -t will show the variables (a possible extension
could be to functionally differentiate between -t and +t, using
one of it to support that inverse logic). Such an inverse function
could be considered independently of adding <label> functionality,
the latter making the shell function change less trivial.
But all those ideas are void given that some documentation
sources say "This option is obsolete."
My guess is that it won't be going away despite what the documentation
says.
Most likely.
With "ksh 93u+m" there would be a path, though, to refine/replace
that typeset option with a more useful [extended] variant.
Janis
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)