Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: passing argument(s) to Mata constructors


From   [email protected]
To   [email protected]
Subject   Re: st: passing argument(s) to Mata constructors
Date   Wed, 27 Feb 2013 15:19:52 -0000

Phil Schumm wrote:

I'd like to pass arguments to a constructor (i.e., new() method) in
Mata, but can't seem to figure out how.  Does anyone know if this is
possible, and if so, how to do it?  I looked through the official
code distributed with Stata, the documentation, and the Statalist
archives, but couldn't seem to find anything on this issue -- if I
missed it, a pointer to the relevant code/literature/post(s) would be
much appreciated.

[Later:]

Ok, evidently I didn't read the documentation carefully enough (or
simply forgot).  In fact, it appears to be unambiguous on this point
([M-2] class):

    Function new() must be declared to be void and must take no
arguments.

and my attempts to find some undocumented functionality here were
unsuccessful.  Thus, it appears that passing arguments during class
instance creation is not possible.

----------------------------------------------------------------------

It?s far from ideal, but you can pass them into constructors via
external global variables.  There are a few features that Mata would
benefit from.  Constructor arguments is one.  Name spaces and
interfaces are two more.

Joseph Coveney



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index