Rebol3 Code Examplex
Introspection
Rebol [
title: "Rosetta code: Introspection"
file: %Introspection.r3
url: https://rosettacode.org/wiki/Introspection
]
print ["Using Rebol" system/product "version" system/version "on" system/platform]
print ["Build info:" mold to-block system/build lf]
;; Verify the version of your currently running interpreter and exit if it is too old.
assert [system/version >= 3.0.0]
;; Create a `bloop` variable if doesn't exists.
unless value? 'bloop [bloop: -1.4]
if all [
number? :bloop ;; check whether the variable "bloop" exists
any-function? :abs ;; and whether the math-function "abs()" is available
][
print ["abs" bloop "==" abs bloop] ;; and if yes compute abs(bloop).
]
;; Report the number of integer variables in global scope, and their sum.
sum: 0 foo: dummy: 23
print "^/Lib scope numbers:"
foreach [name value] system/contexts/lib [
if integer? :value [
print [" " pad name 8 value]
sum: sum + value
]
]
print "^/User scope numbers:"
foreach [name value] system/contexts/user [
if integer? :value [
print [" " pad name 8 value]
sum: sum + value
]
]
print ["Sum of all integers:" sum]
Output:
Using Rebol Bulk version 3.22.3 on Windows
Build info: [
os: windows
os-version: "10.0.26200.8655"
abi: pe
sys: win32
arch: x64
libc: none
vendor: pc
target: x64-pc-win32-pe
compiler: cl
date: 10-Jul-2026/12:14
git: none
]
abs -1.4 == 1.4
Lib scope numbers:
zero 0
User scope numbers:
b 31
sum 31
g 16
foo 23
dummy 23
ZERO 0
Sum of all integers: 124