Hi, I'm running into a problem with nesting user-defined data types in the
shell, and could use some advice.
It's not an inheritance issue; that seems to work fine, of course. In other
words, this is a "has-a" and not an "is-a" relationship between types. I
originally ran into the problem with arrays of objects as members of other
objects, but I found that I could reproduce the problem without arrays at all.
I'm not convinced this is a problem with the shell, of course; it's entirely
possible that I'm not defining my types correctly. Any advice would be very
appreciated. I'm including the simplest example of it that I can construct
below. I'm seeing this with the following versions, both built from sources.
Version JM 93u+ 2012-02-29 on freebsd8.amd64 with gcc 4.2.1
Version AJMP 93u+ 2012-08-01 on sol10.sun4 with Sun C 5.9
Here's the example I've narrowed it down to, has-a.sh:
#!/usr/bin/env ksh
typeset -T foo_t=(
f=123
function out { print foo f ${_.f}; }
)
typeset -T bar_t=(
foo_t foo
b=456
function out { print bar b ${_.b} f ${_.foo.f}
_.foo.out; }
)
typeset -T baz_t=(
bar_t bar
z=789
function out { print baz z ${_.z} b ${_.bar.b} f ${_.bar.foo.f}
_.bar.out; }
)
foo_t f; f.out; print
bar_t b; b.out; print
baz_t z; z.out; print
exit 0
This is the output I encounter from the example above. I'm sure the expected
results are obvious.
: rtfm; ksh has-a.sh
foo f 123
bar b 456 f 123
foo f 123
baz z 789 b 456 f 123
bar b 456 f 123
has-a.sh[24]: z.out[19]: _.bar.out[12]: _.foo.out: not found [No such file
or directory]
As I said, this is not necessarily a bug, it could very well be that I'm
declaring my types incorrectly. Please let me know if that's the case.
Regards,
Bob
--
Bob Krzaczek, Chester F. Carlson Center for Imaging Science, RIT
phone +1-585-4757196, email [email protected], icbm 43.08586N 77.67744W
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users