What configuration files are there for Rebol R3 and how are they loaded?

StackOverflow https://stackoverflow.com/questions/16783021

  •  30-05-2022
  •  | 
  •  

Вопрос

In Rebol 2 there was a user.r as well as the rebol.r file for adding code which would be loaded during startup. How has this changed for Rebol R3?

Это было полезно?

Решение 2

Currently user.r deprecated as a security risk. There is supposed to be a dialected method for this to happen .. but no one has started work on it yet.

See https://chat.stackoverflow.com/transcript/291?m=9149463#9149463

Другие советы

In Rebol 3 you load code using rebol.r, which is supposed to go in the same directory as the rebol executable. It won't load rebol.r from the user's home directory because files in that directory tend to be writeable by programs running with the user's permissions, which makes it a nice place to put malware. The place you put the rebol executable is assumed to be more easily securable against user code writing to it.

The file user.r is reserved to put user-specific settings and preferences, expressed in a non-procedural dialect (that we haven't discussed yet). Even when it comes back it won't be a way to load code, for the same reason that rebol.r isn't loaded from the user's home directory. It will only be for preferences.

If you want to load user-specific code you might want to do so explicitly using code in rebol.r, but be careful of security issues. The need for user-specific code is rare in Rebol 3.

You might also consider taking advantage of Rebol 3's module system. Most library and utility code is better off being defined in modules, and you can decide where to put those modules by setting system/options/module-paths. Then your scripts import the actual modules by name without having to know where they are really located. You could also set system/options/default-suffix, the default file extension for modules, in case %.reb isn't to your liking.

It's rare that you would want to load code for global use, since the need for the code is local to the scripts. One such use is to load extensions in rebol.r before you lock down the security so that no more extensions can be loaded; this lets you limit extensions to an approved list. Any global code can be delay-loaded, so it doesn't clutter the system for scripts that don't need it. Delay-loaded code isn't really imported until it is requested by the script.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top