giuliolunati
giuliolunati

Reputation: 766

Module can't export existing name

I wish to redefine print in a module and to export it --- just noticed I can't: only non-existing names can be exported. Any workaround?

Upvotes: 2

Views: 51

Answers (1)

MarkI
MarkI

Reputation: 347

See http://www.rebol.com/r3/docs/concepts/modules-loading.html under the heading: Explicit references into modules.

Loading a module will currently never redefine a word in the user context. I can't tell if this is a design decision or because modules are not fully baked yet.

Fortunately, there is a terrible work-around: DIY.

In your case to redefine 'print to be the 'print from your-module execute the following Rebol code:

your-module: import %your-module-filename print: :your-module/print

Also, don't try unsetting 'print before loading your module, I tried and that doesn't work either, so, a topic for another SO question.

Upvotes: 3

Related Questions