Looking in man ksh I see
typeset
[...]
-t Tags the variables. Tags are user definable and have no special
meaning to the shell.
Can someone give me any realistic examples of how this is
supposed to be used ?
Looking in man ksh I see
typeset
[...]
-t Tags the variables. Tags are user definable and have no special
meaning to the shell.
Can someone give me any realistic examples of how this is
supposed to be used ?
On 08.09.2022 10:48, Spiros Bousbouras wrote:
Looking in man ksh I see
typeset
[...]
-t Tags the variables. Tags are user definable and have no special
meaning to the shell.
Can someone give me any realistic examples of how this is
supposed to be used ?
Since a tag has no special meaning to the shell and since the
shell is agnostic about variable semantics it's up to the user
to identify application cases.
Effectively you can interrogate all your "tagged variables" by
typeset [-+]t so that you could define a set of variables for
special treatment; to interrogate the names and actual values
of any tagged variables, e.g. for debugging purposes.
For such a tagging feature it might have been a better design
("better" = with wider application range) to enable the user
defining tag types, though, like typeset -t label var ...
typeset -t debug a b c
typeset -t log a e
typeset -t tmp_res c d
typeset -t log > logfile
But all those ideas are void given that some documentation
sources say "This option is obsolete."
Myself I've never used typeset -t in my ksh source code but
now that I've been pointed to that option I think there may
be useful applications (like the ones hinted above off the
top of my head or other).
On Thu, 8 Sep 2022 13:12:58 +0200
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> 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.
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.
[ 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.
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.
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.
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.)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 498 |
Nodes: | 16 (3 / 13) |
Uptime: | 61:15:26 |
Calls: | 9,813 |
Calls today: | 1 |
Files: | 13,754 |
Messages: | 6,191,184 |