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: How to define an external Mata class within the namespace of an ado-file


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to define an external Mata class within the namespace of an ado-file
Date   Mon, 13 Dec 2010 09:40:25 +0000 (GMT)

--- On Mon, 13/12/10, Joseph Coveney wrote:
> I'm writing a program that makes use of a parent (base) Mata class for
> generalized linear model likelihoods.  The program, an ado-file,
> provides one subclass as a default (binomial distribution family and
> logit link function). But, I would like for users to be able to extend
> the program with likelihoods of their own, without having to modify
> the original ado-file.  The idea is for users to create their own 
> likelihood subclasses in external Mata code that they write as needed.  
> The ado-file will, at the users' option, call this external Mata code, 
> instantiate its contained subclass, and use that object in lieu of
> the default logistic object.
> 
> The problem is that the ado-file's Mata code is run within
> the namespace of the ado-file:  the parent/base class is not visible
> to the external Mata code, and so the external Mata file cannot extend
> it.

How about the following rough idea:

In the .ado file allow and option where users can specify the name of
their own Mata evaluator function. 

In your .ado file ensure that when no evaluator was specified the 
local contains the name of the default Mata evaluator function.

When populating the class in Mata you refer to the evaluator function 
via a pointer which comes from the local defined above. So you would
create a Mata function that fills your class, and in your .ado file
you would call it something like this:

mata: fill_my_class(&`evaluator_name'(), ...)

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index