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

World: r3wp

[!REBOL3 Extensions] REBOL 3 Extensions discussions

Kaj
26-Jan-2011
[2164]
How much time and memory do delayed modules take? In any case, it 
will be too much on for example CGI scripts
Pekr
26-Jan-2011
[2165]
BrianH: isn't having just one name going to be a problem for us? 
I like the .rx extension very much. But think about distros. You 
can't have one storage of extensions for various platforms. Dunno 
if such use case would exist. Something like big directory of extensions 
somewhere on the fileshare. In the same path. If the suffixes would 
be different, then those files could co-exist. Hmm, maybe not, because 
.so works for Linux, other Unixes, and those might require different 
extension binary anyway? How would you solve such a case? Subdirs 
per system? e.g. /amiga, /win32, /win64, /linux, /syllable?
BrianH
26-Jan-2011
[2166]
Time: not much. Memory: don't know, platform-specific. They don't 
have their source decoded, but the library is loaded (I think), though 
no code is called except RX_Init (from what I gather). I haven't 
done much work with extensions yet but Carl says they work like that.
Kaj
26-Jan-2011
[2167x2]
Alien binaries shouldn't be installed, so you need separate packages, 
or a package with an extension installer. If you really don't want 
to do that, you need subdirectories
A system-wide loader like that is a feature of an OS that starts 
once, not of a language platform that launches many times
BrianH
26-Jan-2011
[2169x2]
Pekr, the idea behind .rx is to make it possible to write cross-platform 
extensions and have them be called by cross-platform code. If people 
are using extensions then they are expected to be importing them 
before they use them. The .rx convention is one way to do this; platform-specific 
loaders is another. Choose what you prefer.
Subdirs per platform is one way to do this (if you are calling your 
app from a network share, or building it from source for instance).
Kaj
26-Jan-2011
[2171]
So how about import/extension ?
Pekr
26-Jan-2011
[2172]
BrianH: I fear of the following problem - some user thinkining - 
hah, %sqlite.rx, downloads the extension, but the extension is in 
fact only Windows one :-)
BrianH
26-Jan-2011
[2173x3]
Have them download a zip file containing the Windows binaries. That's 
how SQLite does it.
Kaj: No need. You can import the extensions by filename. We want 
the initial import of an extension to be really clear, distinct from 
the import of a module. If you say that LOAD-EXTENSION looks up the 
file in the system library path, that shoul;d be all the searching 
we would need.
Importing an extension has security implications, so it isn't something 
we want to happen by accident. Make it clear by including the filename.
Kaj
26-Jan-2011
[2176]
Do you acknowledge my concern at all, even after learning that R3 
uses the OS loader?
Pekr
26-Jan-2011
[2177x2]
I would like to get back to Oldes' quesiton - is unloading extension/module/gui 
or other elements technically impossible?
I mean - once I define e.g. layout, objects get defined, and unview 
just hides the window, but the rest is still in the memory without 
any way to be cleared. Is that even solvable? I have no idea of how 
to track all possible references to be unset :-)
Oldes
26-Jan-2011
[2179]
I think it's just not implemented yet... R2 was using FREE to unload 
library.
Pekr
26-Jan-2011
[2180]
(sorry to spoil the extensions group for my question, but it might 
be similar)
BrianH
26-Jan-2011
[2181]
I don't know. I think that extensions are unloaded when the program 
closes.
Pekr
26-Jan-2011
[2182]
Once the program closes is not usefull at all. Think about R3 as 
an OS. It somehow should track resources. And/or stuff like GUI etc. 
should be isoloted in some context which you could easily scrape 
- unset, free, whatever ... or the memory consumption will rise endlesly?
Oldes
26-Jan-2011
[2183]
I don't think we are so far (making R3 OS) :)
Pekr
26-Jan-2011
[2184x3]
Oldes - maybe not, but those things have consequences. if we don't 
plan on collection resources info, how do we know how to free memory? 
That might influence some internals, modules, extensions, etc.?
I am not clever enough to suggest a solution, but I think that some 
solution could be at least thought about ....
Maybe we could CC it as a wish - how to free rebol resources for 
more complex stuff as a gui?
Oldes
26-Jan-2011
[2187x2]
why not... it looks the CC is the only way how to ask Carl for something 
at this moment and get response in reasonable time.
(resonable time is months unfortunately)
Kaj
26-Jan-2011
[2189]
Indeed
Pekr
26-Jan-2011
[2190]
Yeah, Carl not much active (apart from RMA reports of some activity) 
since late October ....
BrianH
26-Jan-2011
[2191]
Kaj, you do realize that you won't be able to just load any system 
library, right? Unless that library has an R3 extension API, it can't 
be loaded as an extension. And if you can only load R3 extensions 
anyways, why not name them as R3 extensions? The .so filename suffix 
isn't even portable to all POSIX platforms. If you want your code 
to be portable and load filenames, use a portable filename. That 
is why we have the .rx convention. And we have %rebol.r for anything 
specific to your personal platform - you don't even have to touch 
host code. For that matter, CGI scripts could call a R3 interpreter 
that is in a different directory than the user R3 interpreter so 
they would use different %rebol.r settings.
Kaj
26-Jan-2011
[2192]
Still, the only way to get a proposal submitted around here is to 
go to CureCode
BrianH
26-Jan-2011
[2193x2]
Oldes, Pekr, I don't know whether extensions can be unloaded. Last 
time I checked it was considered unsafe to do so, because the import 
process doesn't isolate things. In theory you could clean up after 
a module, remove it from the system modules list, remove all references 
to it from all other modules (that you have tracked), and then let 
the module be collected by the garbage collector, but I don't know 
if extensions are unloaded when they are collected.
The main way to free resources is to remove references to these resources 
and then collect them with the GC. Other resources can be freed manually 
using cleanup functions. In the case of extensions, they would need 
to provide their own cleanup functions, as only they can know what 
resources they are using.
Pekr
26-Jan-2011
[2195]
So there is no way, how to "disconnet" an extension from your app, 
so that OS finds out - look, some not connected orphan here, let's 
clear the memory here?
BrianH
26-Jan-2011
[2196]
Right, because R3 has no way of knowing what resources the extension 
is using. But extensions could be swapped out to VM if they aren't 
being used (depending on the OS), they don't have to stay in main 
memory.
Kaj
26-Jan-2011
[2197x2]
You'd have to eventually call the OS loader again to unload ir
it
Pekr
26-Jan-2011
[2199]
OK, after reading all the above, I agree on .rx being a suffix for 
an extension. The reasons? Even dll or so are not necessarily crossplatform, 
plus having an extension even as .dll is confusing - normally it 
might not be clean .dll, which you can load in some other environment 
- there might be packed rebol code inside. But I don't want to complicate 
Kaj's aproach, and more important - I never coded any extension, 
so regard it being just an opinion ...
BrianH
26-Jan-2011
[2200]
Actually, you can only unload modules in general in extremely limited 
circumstances. There has to be no outstanding indirect references 
to the module's context, and that usually can't be tracked.
Pekr
26-Jan-2011
[2201x2]
We could also create .rm, for MODULES ... but modules are plain text, 
no? Or even binary? Dunno if it would make sense to distinguis them 
from normal scripts?
OTOH it would be imediatelly obvious, that the code is some module, 
not a plain script, which necessarily does something ...
BrianH
26-Jan-2011
[2203]
You can distinguish R3 modules from scripts with LOAD/header or some 
such. But you can call R3 scripts anything you like. Scripts are 
just a kind of module in R3 anyways (one of 3 or 5, depending on 
how you count it).
Pekr
26-Jan-2011
[2204x2]
I thought about user, downloading a distro. If those are not distinguished, 
I would try to DO each script, just to demo the REBOL. And doing 
a module usually does nothing more than loading the module = nothing 
visually usefull. So I would not mind having .r3, .rm, .rx
(I know that modules are distinguished by the header, but that was 
not the reason to propose having .rm )
BrianH
26-Jan-2011
[2206]
If you want to call your modules .rm or .r3m or whatever, go for 
it. We don't have a standard suffix for scripts, but feel free to 
make one. Actually, the default suffix for R3 module files is .reb 
:)
Pekr
26-Jan-2011
[2207]
bleee :-)
BrianH
26-Jan-2011
[2208]
And that is only used when you are doing lookup by name through module-paths.
Pekr
26-Jan-2011
[2209]
if reb, then extensions should be .rex :-)
Oldes
26-Jan-2011
[2210]
But servers as Github will not colorize any extension as REBOL code:) 
I like colorized code.
BrianH
26-Jan-2011
[2211]
The .rex extension is taken on Windows by a third-party app, but 
that may not matter. The main reason the default extension is .reb 
is because Carl likes it, but the programmer is expected to change 
it, and even Carl doesn't use it. I like .r3 for R3 scripts and modules 
both, because there's really not enough of a difference between them 
to justify a different name, but YMMV. Maybe we can get Github to 
treat .r3, .r2 and .reb as REBOL scripts.
Oldes
26-Jan-2011
[2212]
.r3 and .r2 are already... don't know .reb
Pekr
26-Jan-2011
[2213]
well, there was even one other suffix, for a compressed scripts, 
was it .rip? I like .r3, .rm, .rx, and those I will use (maybe really 
not necessary to do a separate suffix, I will see). .reb just says 
- nothing ...