REBOL
1997fragletMCP + fragletc
Rebol is a homoiconic language that was designed by Carl Sassenrath. It is a descendant of Lisp and Forth, and it is known for its simplicity and ease of use. Rebol is a cross-platform language that can be used for a variety of tasks, including scripting, web development, and data processing.
From Wikipedia:
Douglas Crockford, known for his involvement in the development of JavaScript, has described Rebol as "a more modern language, but with some very similar ideas to Lisp, in that it's all built upon a representation of data which is then executable as programs" and as one of JSON's influences.
Hello World
REBOL [Title: "Example"]
; BEGIN_FRAGLET
print "Hello World!"
; END_FRAGLET
quitCoding Guide
Language Version
REBOL 3.18.0
Execution Model
- Interpreted, runs directly from source
- Code executes at the top level
Key Characteristics
- Homoiconic language (code is data)
- Dynamic typing
- Case-insensitive keywords (but case-sensitive strings)
- Minimal syntax with block notation
- Built-in data types: strings, integers, blocks, words, etc.
Fragment Authoring
Write valid REBOL statements. Your fragment becomes the script body. Code runs at the top level.
Available Libraries
Standard REBOL library is available. No additional modules are pre-installed.
Common Patterns
- Print:
print "message"orprint {message} - Variables:
name: "Alice" - Blocks:
[1 2 3 4 5] - Functions:
add: func [a b] [a + b] - Conditionals:
if condition [code] - Loops:
foreach item block [code] - String concatenation:
rejoin ["Hello " name]
Examples
; Simple output
print "Hello, World!"
; Variables and expressions
name: "Alice"
age: 30
print rejoin ["Hello, " name "! You are " age " years old."]
; Function definition
greet: func [name] [
rejoin ["Hello, " name "!"]
]
print greet "Bob"
; Block processing
numbers: [1 2 3 4 5]
sum: 0
foreach num numbers [sum: sum + num]
print rejoin ["Sum: " sum]
; Conditional
x: 10
if x > 5 [
print "x is greater than 5"
]
; String operations
text: "Hello World"
print uppercase text
print length? textCaveats
- REBOL keywords are case-insensitive, but strings are case-sensitive
- Blocks use square brackets
[]for code and data - Words (identifiers) don't need quotes
- Use
rejoinfor string concatenation
Fraglet Scripts
Echo Args
#!/usr/bin/env -S fragletc --vein=rebol
print rejoin ["Args: " system/script/args]Stdin Upper
#!/usr/bin/env -S fragletc --vein=rebol
line: input
print uppercase lineTest
#!/usr/bin/env -S fragletc --vein=rebol
print "Hello World!"