Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

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


From   jcoveney@bigplanet.com
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: passing argument(s) to Mata constructors
Date   Wed, 27 Feb 2013 17:30:30 -0000

Phil Schumm wrote:

Thanks.  Alternatively, you can use a factory function that takes
arguments, and returns a fresh instance of the class suitably
initialized (i.e., based on the arguments passed to it).  That's what
I wound up doing in this case.

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

Good that you could find a workaround for your situation.  A simple
factory is handy, but it really doesn't give you what the ability of
a constructor to take arguments does.  There are situations where a
simple factory can't serve as an alternative to passing arguments to
constructors, for example, try implementing a singleton design
pattern in Mata (not that typical Mata usage needs a singleton).

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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index