Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73331

Access instance, class, or function "own" identifiers within the .class file

$
0
0
In class programming, is there a way to access an instance's, class's or member function's own identifier programmatically from within a class or function definition? The current use case is to display a generalized error message within a member function, as in .import below, but getting an identifier seems like a general problem that may have other applications.
dataSource.class:

Code:
class dataSource {
    repositoryURL  = ""
    version             = ""
    filelist               = ""
    localDir            = ""
}

...
program .download
    //Default provided here
    ...
end

program .unpack
    //Default is do nothing; override if necessary
end

program .import
    di as err "Classes that inherit from .dataSource MUST override .import"
    exit 4050
end
but I would like the text ".dataSource" and ".import" added to the error message automatically based on the fact that the currently executing (or compiling?) function is .dataSource.import. Is that possible in Stata?

Viewing all articles
Browse latest Browse all 73331

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>