Skip to content

Instantly share code, notes, and snippets.

@draegtun
Last active May 5, 2017 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save draegtun/f37e0c15afbe1ba1c66527299510a020 to your computer and use it in GitHub Desktop.
Save draegtun/f37e0c15afbe1ba1c66527299510a020 to your computer and use it in GitHub Desktop.
What to do with system/user and system/options??

system/options/home

On Rebol 2 this points to user home directory (on Linux/OSX this is get-env 'HOME). On r3 this is currently set to where the r3 executable lives.

As it stands we should rename system/options/home to make it clear this is where executable lives and avoid confusing with $HOME. See %rebol.r

We can then reclaim system/options/home to replicate R2 behaviour (if we like?)

system/user or system/options?

Should user definitions live in system/user or should there be somewhere like system/options/user ??

To me if its in system/options then it implies it could be changed by command-line switch. This seems right because you may want to do:

r3 --user-home "/root/MyHome/"

But perhaps user settings should only be updated by the %user.r file?

But what do we do with system/user?? Perhaps we just do... system/user: system/options/user :)

Resources directory

This is where %repl-skin.reb is kept. This could also be a good place to install local modules.

Currently system/user/rebol points to this. I think this should change to something like resources within system/options

See metaeducation/ren-c#475 for how it currently work and how it may change (for Windows).

HOME on Windows

This is just a stub. See comments from here - metaeducation/ren-c#475

%rebol.r

Currently on r3, if %rebol.r is found in system/options/home directory then %rebol.r is run.

This is (intended to be) a system-wide way to update or add features to rebol. So %rebol.r needs to sit next to r3 executable and use the renamed system/options/home

Did Rebol 2 do exactly same thing?

%user.r ?

This available on r2 and I believe it is found in folder referenced by system/options/home. Currently not (fully) implemented in r3.

I've never used this but I assume it just updates system/user ??

We can replicate this exactly or we can do something more like %repl-skin.reb, where it runs the file (so think of it like a user local %rebol.r) and then last expression is used to update system/user. So an example of %user.r:

insert system/module-paths:  %/path/to/mylibs

import 'baz-lib    ;; because I always want this for all my scripts!

make object! [
    email: baz@baz.com
    resources: %/some/where/else    ;; I've redefined where I live?  Should I allow this??
]

If we do resurrect %user.r then I believe it should live under directory defined in Resources directory.

NB. At the moment (in host-start.r) %rebol.r & %user.r run after the switches.

command-line switches

There should be a command-line switch to suppress %rebol.r & %user.r so something like...

 r3 --suppress-startup-files

... alternatively it can be other way round (they don't run unless we provide a command-line switch)

Some other handy switches we could add...

 --suppress-console-skin
 --suppress "console-skin.reb"                      # alternate version
 --suppress "console-skin.reb user.r"               # so can suppress multiple startups
 --run-user-file "C:\Mystuff\MyRebol\user.r"      

NB. See more command-line switches in take 1 & take 2 ideas below.

So what could system/options look like?

Take 1

 system/options/exe-home        ;; Could be exe-dir or exe-path or something else?
 
 system/options/user/name       ;; is this users name on OS or "Joe Bloggs".
                                ;; _ unless set in %user.r
 
 system/options/user/email      ;; _ unless set in %user.r
 
 system/options/user/home       ;; start-up will populated this if it finds it! 
                                ;; Can be overridden by switch.  Could even be changed by %user.r !!
			        ;; alternate name choices:  home-dir, home-path
			    
 system/options/user/resources  ;; start-up will populate this if it finds dir under system/options/user/home
                                ;; can be overridden by switch or %user.r (Hmm? perhaps we shouldn't allow??)
			        ;; alternate name choices: resource-dir, resource-path
 
 system/options/user/words      ;; Don't know what this is but its currently defined (as _) in system/user
 
 system/options/home            ;; this could be an alias to system/options/user/home ??

Related command-line switches could be:

 --user-home "/usr/baz"   
 --user-resources "Some/where/not-in-my-home"
 --user-email "baz@baz.com"

take 2

 system/options/exe-home        ;; Could be exe-dir or exe-path or something else?
 
 system/options/home            ;; Same as Rebol 2  (ie. get-env 'HOME)
 
 system/options/resources       ;; Same as take 1 version except cannot be overridden by %user.r
 
 system/user/name               ;; see system/options/user/name in take 1
 
 system/user/email              ;; see system/options/user/email in take 1
 
 system/user/home               ;; start-up will populate this with system/options/home
                                ;; Can be changed by %user.r but this WON'T effect system/options/home (I think?)
			    
 system/user/words

Related command-line switches could be:

 --home "/usr/baz"   
 --resources "Some/where/not-in-my-home"

No --user-* switches. Use %user.r to update system/user

ref: https://github.com/metaeducation/ren-c/blob/master/src/boot/sysobj.r#L580

@giuliolunati
Copy link

system/options/home -- agree with need for new name. But more important, it should be fixed because if you invoke simply r3 then system/options/home is set to $PWD/r3 instead of true executable location

@giuliolunati
Copy link

Command-line switches: ok to optionally suppress loading of startup files, but IMO default must be loading they

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment