Skip to content

Instantly share code, notes, and snippets.

@jayemerson
Created July 13, 2011 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayemerson/1081448 to your computer and use it in GitHub Desktop.
Save jayemerson/1081448 to your computer and use it in GitHub Desktop.
function loading up front
# NQR/src/nqr.pir
.sub '' :anon :load
load_bytecode 'HLL.pbc'
... # OMITTED STANDARD squaak STUFF
# ATTEMPTED LIBRARY LOADING UP FRONT?
.local pmc lib, nci
loadlib lib, 'libgsl.so'
dlfunc nci, lib, 'gsl_ran_gaussian_pdf', 'ddd'
set_global ['GSL'], 'gsl_ran_gaussian_pdf', nci
.end
## NQR/src/nqr/Runtime.pm: dnorm() works, dnorm2() does not work
sub dnorm(*@args) {
return Q:PIR {
.local num ans
.local pmc gsl_ran_gaussian_pdf
gsl_ran_gaussian_pdf = get_global ["GSL"], 'gsl_ran_gaussian_pdf'
ans = gsl_ran_gaussian_pdf(0.5, 1.0)
%r = box ans
};
}
# doesn't work. Error: invoke() not implemented in class 'Undef'
sub dnorm2(*@args) {
return Q:PIR {
.local pmc libgsl, gsl_ran_gaussian_pdf
.local num ans
libgsl = loadlib "libgsl"
gsl_ran_gaussian_pdf = dlfunc libgsl, "gsl_ran_gaussian_pdf", "ddd"
ans = gsl_ran_gaussian_pdf(0.5, 1.0)
%r = box ans
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment