Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use module inside module?

I have this simple module:

REBOL[
    Name: 'test1
    Type: 'module
    Exports: [foo]
]

foo: does [print "foo"]

and this one:

REBOL[
    Name: 'test2
    Type: 'module
    Exports: [bar]
]

import %test1.reb

foo

bar: does [foo]

When I try to do import %test2.reb, I get foo word is not bound to a context error. After this error, I'm able to call foo from console, so it was imported, but somehow it's invisible to test2 module. So what's the proper way to use module inside module?

like image 366
rebolek Avatar asked Jul 10 '26 05:07

rebolek


1 Answers

I'm not certain if this is a bug in IMPORT, however Using the NEEDS header should work:

Rebol [
    Name: 'test2
    Type: 'module
    Exports: [bar]
    Needs: [%test1.reb]
]

foo

bar: does [foo]
like image 82
rgchris Avatar answered Jul 13 '26 22:07

rgchris