World: r3wp
[!REBOL3 Modules] Get help with R3's module system
older newer | first last |
Carl 23-Oct-2010 [188x3] | core >> print stats 856824 core -b sys >> print stats 793984 core -b base >> print stats 573336 |
Note that -b base is not useful for you (it's for me) because schemes are not yet init'd. It's a bit like booting an OS without the file system. | |
Also, -b sys is somewhat useful, because there is a very minimal LOAD that should work. | |
Andreas 23-Oct-2010 [191x3] | USAGE says: --boot-level L Where L can be: base sys mods |
Reported as #1713. | |
And from the hostkit: the long option name actually is "--boot". | |
BrianH 23-Oct-2010 [194] | I like that better. Nice catch. |
Andreas 31-Oct-2010 [195x2] | Quick Q: are modules supposed to actually work with A109? |
Because it seems I can't even get http://www.rebol.net/r3blogs/0344.html to work. | |
BrianH 31-Oct-2010 [197x4] | No, they don't quite work in 109. All of the problems with modules have been fixed for alpha 110. |
But in theory the stuff in that blog should have worked even in a109. | |
Next week, as time allows, I will be reformatting the module system into a loadable script that can work at lower boot levels. This will both be good documentation and allow better testing, for the module system and the boot levels too. | |
See here for the bug announcement, in the comments to the release announcement: http://www.rebol.net/cgi-bin/r3blog.r?view=0343#comments | |
Andreas 31-Oct-2010 [201x4] | As far as I can tell, hardly any of the "basic" features work in A109. |
Doing a plain import %module.r from the console only works as expected if the module is named and not private. Unnamed, private+named, private+unnamed modules seem to not work. | |
Here's what I tried: https://gist.github.com/cd03af7ddacc2eb9a2e3 | |
Well, looking forward to A110 :) | |
BrianH 31-Oct-2010 [205x2] | Despite what the blog says, unnamed modules are a bit of an advanced feature in the R3 module system. Normally modules should be named. But yes, the bug was in the criteria that determined that private import should be done, and all unnamed modules do the private import method (in alpha 110+ at least). |
Carl really should stop pushing unnamed modules in those blogs of his. I know they look cleaner, but they are only for certain purposes. | |
Andreas 31-Oct-2010 [207] | Poor REBOL if DRY gets relegated to an "advanced feature". |
BrianH 31-Oct-2010 [208] | DRY? |
Andreas 31-Oct-2010 [209] | Don't repeat yourself. |
BrianH 31-Oct-2010 [210] | Oh, you mean like what unnamed modules do when imported more than once. |
Andreas 31-Oct-2010 [211x2] | No, I'm hinting at the most simple and straightforward use. |
I write a module in a file named %module.r. I don't want to repeat that name in a header unless necessary. | |
BrianH 31-Oct-2010 [213x2] | Do import 'module and you will be fine - the name gets applied. |
In alpha 110 of course. | |
Andreas 31-Oct-2010 [215] | So by "stop pushing unnamed modules" you mean he should write import 'module instead of import %module.r? |
BrianH 31-Oct-2010 [216] | At the time he wrote that blog the name getting applied feature hadn't been added yet. |
Andreas 31-Oct-2010 [217x2] | That was not what I asked. |
Do you want him to write import 'module or do you want him to write REBOL [name: 'module] or both? | |
BrianH 31-Oct-2010 [219x2] | In order to be fully imported into the system, a module needs a name that the system can use to refer to it by in the modules list. If it doesn't have a name then it can't be reused or referred to later, so subsequent imports will reload the module source and create a new module. And all unnamed modules import privately, meaning that they import into the local context only, not into the system runtime library. This means no variable sharing. |
The name isn't some random requirement - it means something, it is used. | |
Andreas 31-Oct-2010 [221] | Still no answer. |
BrianH 31-Oct-2010 [222] | I don't care how someone wants to write their modules or import statements. We have tried to make unnamed modules work as well as we can, given their limitations. However, there is a real difference between the behavior of named and unnamed modules. For most code it won't matter, but if your code depends on that difference then you better make sure it loads the way you want it to. |
Andreas 31-Oct-2010 [223] | Let's try again. You wrote "Carl really should stop pushing unnamed modules in those blogs of his." I presume this also refers to: http://www.rebol.net/r3blogs/0344.html Considering this blog post, would your suggestion amount to: - A: using import 'simple instead of import %simple.reb - B: adding name: 'simple to the REBOL header - C: both, A and B - D: neither of the above |
BrianH 31-Oct-2010 [224] | A, B or C. Or he can continue to gloss over the difference until he decides to write a blog about it. |
Andreas 31-Oct-2010 [225] | Ah, so retract your suggestion. Fair enough. |
BrianH 31-Oct-2010 [226x2] | I don't want to dictate someone's programming style. That is why we have more than one kind of module in the first place. |
There are real consequences to whether a module is named or not, but both styles are appropriate in different circumstances. | |
Andreas 31-Oct-2010 [228] | Bad typo: Ah, so you* retract your suggestion. |
BrianH 31-Oct-2010 [229x2] | No, named should still be considered the default behavior. Unnamed is still exceptional. |
If that weren't the case we wouldn't have added the IMPORT word! applies the name feature. | |
Andreas 31-Oct-2010 [231x3] | Well, then I simply observe that you don't want to give a straight answer to above question. |
Or let's add, E: "Exactly one of A, B, or C", assume you chose E and be done with it. | |
Even the simplest discussions can be surprisingly hard when the means of communication are reduced to text. | |
BrianH 31-Oct-2010 [234x2] | I don't write blogs. If his purpose is to make the module system seem simpler than it is, cool. It can be that simple in practice. When called from user scripts there is very little difference between regular, unnamed or private modules. The context of user scripts is isolated, so all the values are copied into it afterall. It doesn't really become a big deal unless you are concerned about when words are added to the user context, or until we get concurrency going. |
It matters a *lot* for modules that are imported into other modules, but no blog has mentioned that situation yet. | |
Andreas 31-Oct-2010 [236] | Hardly worth mentioning until it actually works. |
BrianH 31-Oct-2010 [237] | ...and is released in its working form. That first part is covered already. |
older newer | first last |