Chapter 1
- Red/System is the part of Red needed to do lower-level programming like C.
- A full-stack language is a language that can be used on the whole spectrum of programming, from systems level to high-level language construction. Red together with Red/System is able to do that.
- Red and LISP both have the block (or list) as its basic structure, for code as well as for data.
-
1) Red has a very small tool-chain, with no installation and configuration
2) The size of its executables is around 1 Mb
3) The reduced size of its source files.
- A dialect is a specialized high-level language written in Red. Examples: parse, view, Red/C3
- Red is compiled to native code, while REBOL is always interpreted.
- Red runs in Windows, Linux, Android, OS X and FreeBSD environments in a 32 bit version, also on ARMv5 processors.
Chapter 2
-
Refer to exercise1.red
- red.r is the REBOL script used currently to compile Red to Red/System, and Red/System to native code
- A self-hosting language has a compiler that is written in itself (in the case of Red, written in Red)
- The do function
- libRedRT is not needed in release mode
- The compiled code of libRedRT is contained within the program's executable
- Visual Studio Code with the Red plugin gives you code completion
Chapter 3
- It gives a *** Script Error: John has no value. Corrected: name: "John"
- See explanation in text
- i1 ;== 1 i2 ;=
The point is that (i1: 1) itself has the value 1 and the effect that i1 refers to 1 from then on. - print [10 * 5] ;== 50
probe [10 * 5] ;== [10 * 5]
- to_float 42 *** Script Error: to_float has no value.
to_float is not a known word.
- (Chapter03/evaluation.red):
print (6 < 13) and (42 < 33) ;== false
print (43 < 42) xor (44 < 43) ;== false
print complement 3 ;== -4
- a: "red" ;== "red"
b: copy a ;== "red"
a = b ;== true ;same value
a == b ;== true ;same value and datatype
a =? b ;== false ;not the same object!
- print [3 = 2 tab 5 = 5 tab 1 = 1.0] ; == false true true
- on = (5 = 5) ;== true
- ? now
REFINEMENTS:
/year => Returns year only.
/month => Returns month only.
/day => Returns day of the month only.
/time => Returns time only.
/zone => Returns time zone offset from UCT (GMT) only.
/date => Returns date only.
/weekday => Returns day of the week as integer (Monday is day 1).
/yearday => Returns day of the year (Julian).
/precise => High precision time.
/utc => Universal time (no zone).
- square-root 9 + square-root 9
Same as: square-root (9 + square-root 9)
Same as: square-root (9 + 3)
Same as: square-root (12) ;== 3.464101615137754
(square-root 9) + square-root 9 ;== 6.0
- minimal.red
–c compilation: 66kB
–r compilation: 583 kB
Chapter 4
- see testing-conditions.red QA 1
- out ;== "bad luck"
- see raining.red
- see testing_conditions.red ; QA 4
- see testing_conditions.red ; QA 5
- see repetitions.red ; QA 6
- see count-down.red
Chapter 5
- data: ["A" "B" "C" "D"] is a series of strings, the following is a series of characters: data: [#"A" #"B" #"C" #"D"]
- see navigating-and-looping.red section ; moving to the tail.
- see navigating-and-looping.red section ; back.
- see navigating-and-looping.red section ; skip.
- see navigating-and-looping.red ; QA 5.
- see getting-info.red section ; selecting an item
- see getting-info.red section ; QA 7
- see getting-info.red section ; QA 8
- see getting-info.red section ; QA 9
- see getting-info.red ; QA 10
- see changing-series.red ; QA 11
- see strings-as-series.red ; QA 12
Chapter 6
- see do-error-runtime.red for an explanation about the error and when you get to see it.
- see do-does-has-func.red section ; QA 1
- see do-does-has-func.red section ; QA 2 ?
The variable num defined in has1 becomes a global variable, whereas has2 turns its num2 argument into a local variable.
- see do-does-has-func.red section ; QA 4
- see function-atrributes.red section ; QA 5
- see function-atrributes.red section ; QA 6
- see working-with-functions.red section ; QA 7
- see working-with-functions.red section ; QA 8
Restricting the type of n with n [integer!] is also ok, but would provoke an exception.
To test if n = 0 you can also write if zero? n - see working-with-functions.red section ; QA 9
- see objects.red ; QA 10
- see objects.red QA 11
Chapter 7
- see reading-and-writing-files.red, section QA 1: each item is written on a different line.
- idem QA 2
- idem QA 3
- see saving-and-loading.red QA 4: after load the block structure is recovered.
- see saving-and-loading.red QA 5
- see currency-rates3.red
Chapter 8
- see bitsets.red section QA 1
- see bitsets.red section QA 2
- see bitsets.red section QA 3
- see how-parse-works.red section QA 4
- see how-parse-works.red section QA 5
- see searching-and-changing.red QA 6
- see searching-and-changing.red QA 7
- see searching-and-changing.red QA 8
- see searching-and-changing.red QA 9
- see more-features.red QA 10
Chapter 9
- see currency-rates-gui2.red
- see faces-are-objects.red
- see close-window-quit.red and close-window-unview.red
- see container-layout.red section QA 4
- see button-check.red
- see sorted-text-list.red
- see extracted-text-list.red
- see text-hover-wheel.red
- see drawing-lines.red
Chapter 10
- see reactive-drag.red
- Non-reactive version is box-color-non-reactive.red, reactive version is box-color-reactive.red
- see hello.reds
Compile it with: red –r hello.reds
To execute: ./hello
- print-test.red calls print-test.reds
- see perf-datatypes.red, section QA 5