REBOL Technologies

Quick Tour of Useful 2.7.8 Features

Carl Sassenrath, CTO
REBOL Technologies
16-Jan-2011 19:37 GMT

Article #0505
Main page || Index || Prior Article [0504] || Next Article [0506] || 5 Comments || Send feedback

I've been incredibly busy... and it took a week to get the list of changes updated on this website. The list is done now, but let me give you a quick overview of some features.

First, if you use REBOL as a server or for CGI-scripting, notice there's only one task running now:

rebol@linux:~$ rebol &
rebol@ub10:~$ ps
 PID TTY          TIME CMD
1474 pts/0    00:00:00 bash
1703 pts/0    00:00:00 rebol
1704 pts/0    00:00:00 ps

The DNS subtask is delayed now until you use DNS (which many scripts may not need.) This change makes your CGI scripts launch faster and also makes it possible to setuid the main process before the subtask forks.

There are also new functions for easier access to the OS environment. Notice that the secure level defaults to asking the user for permission:

>> set-env "prog-home" "/tmp"
REBOL - Security Check:
Script requests permission to access OS environment: prog-home
Yes, allow all, no, or quit? (Y/A/N/Q) A
>> get-env "prog-home"
== "/tmp"

Of course you can allow such operations with:

secure [envr allow]

or by running with the -s option.

Notice also, the list-env function:

>> list-env
== [
   "ORBIT_SOCKETDIR" "/tmp/orbit-rebol" 
   "SSH_AGENT_PID" "1327" 
   "TERM" "xterm" 
   "SHELL" "/bin/bash" 
   "XDG_SE...

You can also access special OS related settings on Posix systems. For example, if you're running a server as root to obtain a listen port on 80, it's wise to setuid the process to some other account:

access-os/set 'uid 1001

Or, if you need your process id for something like building a lock file, you can get it with:

pid: access-os 'pid
save join %/tmp/lock- pid pid

Brian Hawley also ported over a number of useful R3 functions. The full list is here.

For example last? mezzanine is useful:

>> list: [a b]  
== [a b]
>> last? list
== false
>> remove list
== [b]
>> last? list
== true

The various R3 Unix-like shell functions come in handy when you're working from the REBOL console:

>> cd %/usr/local
== %/usr/local/
>> ls
bin/      etc/      games/    include/  lib/      man/      sbin/     
share/    src/

I use dt (delta-time) a lot for measuring performance:

>> dt [loop 1000000 [next "a"]]
== 0:00:00.246217

Speaking of which, I've added a new speed? function, but that's the subject for a separate blog. It is preliminary, so don't yet depend on it.

5 Comments

Updated 15-Dec-2017   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code