scheme chicken implementation, subenvironment script loading

72 views Asked by At

Background

I am using the scheme chicken implementation. Latest version (4.9.0.1).

I am trying to implement a generic arithmetic system on rational, complex and fix-precision numbers in a file called arithmetic.scm.

But for the complex numbers, as I also designed a generic arithmetic system for both rectangular and polar representations, I decide to write the code for the complex number in file called complex.scm.

Problem

So when I try to load the complex.scm into the file arithmetic.scm, I found that some functions have the same name in both files, so I want to use a lambda to wrap the former into a sub environment and register the operators from there using property list. However, the load command can only load the script into the global environment no matter where it is writen. I wonder, other than renaming the functions or copy all the code from complex.scm into a lambda function, what other options do I have. Thanks a lot!

1

There are 1 answers

0
sjamaan On

You should indeed use the module system for such situations, as Chris Jester-Young indicated.

However, have you seen the numbers egg? It adds full numeric tower support (including rational numbers, arbitrarily large integers and complex numbers). This is currently an extension which can be installed separately, but it is (tentatively) slated for inclusion into the next major version (CHICKEN 5).

Full disclosure: I'm the current maintainer of the numbers egg.