r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3 Modules] Get help with R3's module system

BrianH
19-Jul-2010
[54x2]
There is no key-value format, there is a key opt-val-1 opt-val-2 
format. Needs is processed with PARSE.
Check the source of the DO-NEEDS function.
Gregg
19-Jul-2010
[56]
Yes, poor wording on my part. The point being that there is an identifier 
before the version and other information related to a module, and 
the system version is an implicit exception.
BrianH
19-Jul-2010
[57x2]
Yup. But it's always at the beginning. There's another exception 
where Needs can just be a tuple, and only the system version is checked.
And it's not implicit, it's documented.
Gregg
19-Jul-2010
[59x2]
I'll cast my vote to allow 'REBOL as an optional key, rather than 
'core, and leave it at that.

Documented does not equal explicit.
All very cool though. It's nice to only pick on little things like 
this. :-)
BrianH
19-Jul-2010
[61x3]
It turns out that there is no 'system or 'rebol module - it's a chicken-vs-egg 
thing. If it is a module, it can be overriden, so it really does 
need to be special-cased. I don't like that there is a 'core optional 
keyword, because there can also be a 'core module and that isn't 
screened for. But the 'core keyword is there for backwards-compatibility.
I could screen for it in DO-NEEDS, but that wouldn't help with everywhere 
else the modules list is accessed. It would really be better to not 
have any optional keyword at all, but there's that backwards-compatibility 
thing. We'll have to resolve this before we have a real R3 release.
For now, you can have a module named 'core, but you might run into 
gotchas when trying to use it.
Carl
20-Jul-2010
[64]
Should we do it here?
BrianH
20-Jul-2010
[65x2]
Sure, let's show how the sausage is made :)
If you are adding a module to the module list, and there is an existing 
module of that name, then the new module either overrides it, replaces 
it, or doesn't get added (possibly with an error triggered, but so 
far not). The question is which one to do in the particular circumstances. 
The factors are whether it is the same module, for whatever "same" 
means here considering it might be reloaded or still source; whether 
the versions are the same or greater; whether the existing module 
has already been made or is still source, and the same for the module 
to be added.
Carl
20-Jul-2010
[67x2]
There's also the option of keeping both. That is, my code may have 
bindings to the first instance.
(Maybe that's the "overrides" option.)
BrianH
20-Jul-2010
[69x4]
Yes.
So far, my guess is that

- Premade modules can't be delayed since their code blocks and side 
effects have already been executed.

- Delayed modules can't be added unless they have at least the version 
of an existing delayed module, or more than an existing imported 
module.

- Premade modules can't be added unless they have at least the version 
of an existing delayed module, or more than an existing imported 
module.

- If a overriding module is added and the existing module is delayed, 
the existing reference should be replaced, not overriden.

- If a overriding module is added and the existing module is already 
imported, the new module overrides the old but the old reference 
is still there.

- If a delayed module is a mixin, the module is made and returned, 
but the stage-two delayed source is kept in the list.
- I'm missing something.
The questions I have are:

1. What do we do when a module is not added due to a policy issue? 
Currently the add accessor returns none if it is a version issue, 
and triggers an error for a checksum violation.

2. How do we determine (officially) that two modules are to be considered 
the same? Name and version?

2. Can we safely LOAD-EXTENSION more than once with the same extension?

3. Does LOAD-EXTENSION on an embedded extension have any side-effects 
beyond creating an object?

4. ... return the same source each time, or different copies of the 
same source? Testable by SAME?

5. Is is safe to delay the object returned by LOAD-EXTENSION instead 
of the source?
6. Should the checksum of an extension include the extension-specific 
source added?

7. Should the version in the header of a module be set to 0.0.0 if 
not a tuple? Currently it is.

8. If so, should module checksums be done after the version field 
is fixed?
BrianH
21-Jul-2010
[73x2]
Questions and answers posted here: http://www.rebol.net/wiki/Module_Design_Details
Will be edited as the remaining design decisions are made.
Ammon
26-Aug-2010
[75]
Awesome.  Just read through the messages here and will be reading 
the document you linked shortly.
BrianH
26-Aug-2010
[76]
I haven't added documentation for the individual functions yet, since 
they are not yet done. Well, most are, but there might be changes 
required to implement the rest. That is a guru-level doc, but it 
could be used as source material for user-level docs.
Ammon
26-Aug-2010
[77]
Excellent.  I'm looking for guru-level docs.  


If I'm reading this correctly, I will finally have everything I asked 
Carl for (in regards to Object! enhancements) at the '04 Devcon. 
 I'm going to spend some time stubbing out the functions I will need 
to do the advanced IDE tricks I've been wanting to do.  I'll have 
some questions for you once I get some of that done...
BrianH
26-Aug-2010
[78]
I'll be done before then. Yeah, a lot of the proposed object enhancements 
have been done to modules instead. Objects will likely still get 
enhanced in some ways, but modules can better handle a lot of what 
objects were previously used for.
BrianH
22-Sep-2010
[79x2]
In theory, it should be possible for delayed network protocol modules 
to be autoloaded on first use.
The modules that implement the protocols could be delay-loaded and 
registered with the general protocol dispatcher. Then the dispatcher 
could import the module the first time it is needed.
Andreas
22-Sep-2010
[81x3]
Yes. Could be made even simpler, though.
Bundle the modules as what Carl now calls "optionally included". 
Also keep a list of scheme prefix to module name, and just auto-import 
the module from this list when a scheme is used in on of the scheme 
action functions (READ, OPEN, ...).
But well, I guess that in fact is exactly what you also describe 
:)
BrianH
22-Sep-2010
[84x3]
Yup :)
That kind of seamless autoimport is one of the main advantages to 
the import-to-system model of the R3 module system. Even if you did 
explicit import, such as with mixins, the rest of the dependencies 
would be able to be resolved automatically.
You don't necessarily need to explicitly import regular modules in 
order to use them, but you do need to do so for mixins. Mixins are 
like the modules in Maxim's or Gabriele's module systems, more or 
less. As such, mixins will only be used by the kind of advanced programmers 
that already need to write modular code. Regular programmers won't 
need them.
Andreas
22-Sep-2010
[87]
So if, for example, DECODE-CGI is in an "optionally included" (which 
I guess == "delay-loaded") CGI module, DECODE-CGI will be available 
even if you don't import 'cgi first?
BrianH
22-Sep-2010
[88]
A regular, non-delayed module could include a delayed module that 
does the real work. And there are other tricks that can be done.
Andreas
22-Sep-2010
[89]
Well, I personally see not cluttering the "global" namespace with 
those names as a great advantage.
BrianH
22-Sep-2010
[90x3]
A lot of those names won't need to be exported at all. Internal use 
words can stay internal.
The wiki link above has some other ideas for advanced tricks, though 
that page is still being written.
And it's not user-level, so be warned: Here there be dragons :)
BrianH
12-Oct-2010
[93]
OK, the third rewrite of the module system has a few simplifications 
as related to the (unreleased) second rewrite, but it is mostly the 
same design. I will be revising the wiki above with the changes.
Andreas
20-Oct-2010
[94x2]
Now that issues are no long strings but words, maybe we want to revisit 
the decision to introduce EXPORT and HIDDEN keywords. In http://www.rebol.net/r3blogs/0300.html
the main reason not to use #export and #hidden seems to be the nature 
of issues.
I'd actually prefer to use #export and #hidden, as I rather dislike 
the concept of "module keywords".
Pekr
20-Oct-2010
[96]
I think that most of guys did not accept changes to issue dtype ... 
maybe it should be put back to original functionality, no?
Andreas
20-Oct-2010
[97x2]
That is a separate discussion.
Currently we have the issues-as-words, and it does not look like 
they are going away, but rather their semantics be adapted to address 
the concerns raised.
Maxim
20-Oct-2010
[99x2]
*VERY* good catch !!!
pekr, most of whined and tried to put the change in our perspective, 
yes  :-)
shadwolf
21-Oct-2010
[101x2]
Pekr be happy i absolutly don't care about any issue ;) aaaaaaaaaahahahaha
so much of a thing used by 3 guys around the world. That impress 
me.
BrianH
21-Oct-2010
[103]
Well, I hope that we are able to make things good enough for you 
without your help. Wish us luck!