Type | Wish | Status | tested | Date | 24-Jan-2010 10:04 |
---|---|---|---|---|---|
Version | alpha 97 | Category | Syntax | Submitted by | BrianH |
Platform | All | Severity | minor | Priority | high |
Summary | Module EXPORT keyword |
---|---|
Description |
This was proposed by Carl in http://www.rebol.net/r3blogs/0300.html In top-level module body code, the word EXPORT could be used as a keyword to indicate that the next any-word or block of any-words should be added to the module exports list. If the module already has an exports list, words are added to it if they aren't there already. The words will be added in the order seen in the code. If you are exporting a block of words, any values that aren't any-words in the block should be ignored. This will allow you to include docs, export words in a construct spec, whatever. Any code in the code block can act like the EXPORT keyword isn't there at all - the EXPORT keywords should be removed from the source before the module code is run. This is the only safe way to do it. Only the word! export at the top level of module code will be treated as a keyword. This will allow the word to be used as a local or even exported word if you like. No nested code blocks should be scanned, or else nested modules would fail. At runtime once the module is built, it will be as if the exported words were declared in the Exports block in the header. The words will be in the module spec at runtime, where the module infrastructure can see them without reparsing the code block. The EXPORT keyword should never be found or removed from non-modules (aka scripts). |
Example code |
; Exporting some word without initializing it export 'blah ; Usable wherever having a stray lit-word won't matter ; Exporting a block of words without initializing them export [a b c] ; Usable wherever having a stray block won't matter ; Exporting a word where it is set (to a function this time) export blah: does [...] ; Exporting a block of words that are set with SET set export [a b c] none ; Note that EXPORT is *after* SET ; Exporting an export function export export: func [what] [...] |
Assigned to | n/a | Fixed in | alpha 97 | Last Update | 8-Feb-2010 02:00 |
---|
Comments | |
---|---|
(0001925)
BrianH 24-Jan-2010 10:14 |
Added in mezz-intrinsics.r 6734. Has minimal overhead if there are no EXPORT keywords. |
(0001947)
Carl 4-Feb-2010 00:41 |
Nicely done. And super-small add! |
Date | User | Field | Action | Change |
---|---|---|---|---|
8-Feb-2010 02:00 | BrianH | Status | Modified | built => tested |
4-Feb-2010 00:41 | carl | Comment : 0001947 | Added | - |
4-Feb-2010 00:37 | carl | Fixedin | Modified | => alpha 97 |
4-Feb-2010 00:37 | carl | Status | Modified | pending => built |
24-Jan-2010 10:16 | BrianH | Description | Modified | - |
24-Jan-2010 10:16 | BrianH | Code | Modified | - |
24-Jan-2010 10:16 | BrianH | Status | Modified | submitted => pending |
24-Jan-2010 10:14 | BrianH | Comment : 0001925 | Added | - |
24-Jan-2010 10:04 | BrianH | Ticket | Added | - |