I am relatively new to the use of pointers in Mata and have thusfar been impressed with their utility.

Specific to this query, I have been curious about using pointers in conjunction with mata matsave. Specifically, if I define a pointer matrix and save it using mata matsave it appears from a few instances I've tried that the contexts of the "pointee" matrixes are saved as well (i.e. are restored even after clear or starting a new session).

I wasn't able to find anything specific in the documentation speaking to this, but is my novice's observation accurate, i.e. that mata matsave of pointer matrixes will result in the contents being saved and, as such, restorable with mata matuse even after the original "pointee" matrixes have been cleared?

For instance:
Code:
. mata
------------------------------------------------- mata (type end to exit) ----------------------------------------------------
:
: p=J(3,1,NULL)

:
: for (j=1;j<=3;j++) {
>  p[j]=&I(j)
> }

:
: mata matsave pointmat p, replace
(saving p[3,1])
file pointmat.mmat saved

:
: mata clear

:
: mata matuse pointmat
(loading p[3,1])

:
: for (j=1;j<=3;j++) {
> *p[j]
> }
  1
[symmetric]
       1   2
    +---------+
  1 |  1      |
  2 |  0   1  |
    +---------+
[symmetric]
       1   2   3
    +-------------+
  1 |  1          |
  2 |  0   1      |
  3 |  0   0   1  |
    +-------------+

:
: end
Thanks for any insights and/or references.

P.S. I posted this as a response in an existing thread but realized it should probably be a new posting
https://www.statalist.org/forums/for...ciative-arrays