Comments (11)
BTW, I've re-added
(load-from-path "utilities.scm")
at the end of opencog.scm. Same thing.
from atomspace.
Hi. If you use "use-modules" then all variables not exported by the module stay local inside the scope of module. Like a local function variables not visible from outside of the function or private methods in C++.
There are several alternatives:
-
You can export module public variables, for example explicitly add (export stv) inside the utilities.scm or other place within opencog module scope.
-
You can switch into opencog module scope
scheme@(guile-user)> (use-modules (opencog))
scheme@(guile-user)> (define-module (opencog))
$1 = #<directory (opencog) 2409870>
scheme@(opencog)> (stv 1 1)
$2 = (stv 1 0,99999982)
scheme@(opencog)>
- Or you can simply use "load-from-path" instead of "use-modules"
scheme@(guile-user)> (load-from-path "opencog.scm")
scheme@(opencog)> (stv 1 1)
$1 = (stv 1 0,99999982)
scheme@(opencog)>
Maybe this semantics changed between guile versions. Don't know. I checked GNU Guile 2.0.5-deb+1-1.
from atomspace.
Yes, What Jacek says is right; the current contents of opencog.scm makes an incorrect assumption about exports. The fix would need to be something like (export-everything-in-this-file "utilities.scm") and there must surely be something that already does this, but I don't know where.
from atomspace.
An alternative would be to change all "define" in those scm file to "define-public". That should export the functions (mentioned at https://github.com/opencog/atomspace/blob/master/opencog/scm/opencog.scm#L36 )
Might interfere with the cogserver's way to loading however...
from atomspace.
As a non scheme expert it seems the right fix is 1. suggested by @jswiergo . I'll proceed unless you have more suggestions.
from atomspace.
hmm, core_types.scm uses define-public.
@williampma why do you think using define-public might interfere with the cogserver's way of loading?
Anyway, I still like @jswiergo first suggestion better, it's good to have control over what is public and what is not, and it's better to have that information around the same place in a file.
from atomspace.
According to guile's manual define-public is equivalent to export. So if definie-public interferes with cogserver's way of loading so will export (if it's inside the file).
Somehow I can't do
(for-each export <FUN_LIST>)
or
(for-each (lambda (fun) (export fun) <FUN_LIST>)
maybe I'll use define-public instead...
from atomspace.
I've come down to the following compromise, in each scheme file that can be used inside a module I define a function that exports all useful symbols and call it in the module definition, for instance I add
(define (export-utilities) (export av stv itv ...))
in utilities.scm. Then add the following in opencog.scm
(export-utilities)
in opencog.scm.
That way I don't create any interference and don't bloat the module definition.
from atomspace.
Any of these seem reasonable to me. I don't really know what the "best practices" is supposed to be.
from atomspace.
Ah, ignore my comment about interference. I just wasn't sure whether define-public
will work if the function is not in an module.
from atomspace.
Closing. The problem as originally described appears to be fixed. I don't quite recall the problem, but using export in a loop seemed to be broken on guile,
from atomspace.
Related Issues (20)
- compiling scheme atomese HOT 1
- Possible erroneous behavior of BindLink HOT 6
- Pattern matcher fails on a query involving disjunction of virtual clauses HOT 6
- SchemeEval run smoothly on x64 and i386 but it crashes on armv7-a HOT 58
- Compile *.scm files and install the *.go files HOT 2
- Compile error on persist-file.scm HOT 2
- Python import error when atomspace module is not loaded before a module with custom Atom types HOT 2
- sparse pattern query does not allow nested spare terms.
- sparse query pattern performance
- Android port issues
- IdenticalLink fails to find all permutations.
- Re-implement PostgresStorageNode to work like RocksStoragenode
- glob interval not supporting disjoint unions HOT 7
- FloatValue Example gives exception HOT 2
- Update README: package cmake3 is missing in Ubuntu 22.10 repository but package cmake is there HOT 1
- Another FloatValue example HOT 4
- In proxy agent example, cog server hangs when using proxy HOT 7
- Atomspace build broken for ubuntu with ocaml installed. HOT 4
- Broken python bindings HOT 10
- Suggestion: Table of Contents for ram-cpu.pdf HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atomspace.