Red has an exceptional built-in help. There is a large amount of information you can get about the language and your code just typing a few commands on the console. Many tutorials on Red (or Rebol) mention that right at the start, but I think that when you are struggling just to make some basic code work, that is not relevant. But by the time you start building more complex structures and debugging them, it is nice to learn how to use it.
? (or help)
Gives information about all of Red's reserved words and also about your own code. You may also type
? is, of course, shorter.
? by itself prints information about how to use help.
>> ? now USAGE: NOW DESCRIPTION: Returns date and time. NOW is a native! value. 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). RETURNS: [date! time! integer!]
>> a: [1 2 3] == [1 2 3] >> help a A is a block! value: [1 2 3]
>> a: function [a b] [a + b] == func [a b][a + b] >> ? a USAGE: A a b DESCRIPTION: A is a function! value. ARGUMENTS: a b
You can get information about complex objects:
If you don't know exactly what you are looking for, "?" will perform a search for you:
>> ? -to hex-to-rgb function! Converts a color in hex format to a tup... link-sub-to-parent function! [face [object!] type [word!] old new /l... link-tabs-to-parent function! [face [object!] /local faces visible?]
You can find all defined words of a given datatype!
>> ? tuple! Red 255.0.0 white 255.255.255 transparent 0.0.0.255 black 0.0.0 gray 128.128.128 ;... the list is too long!
Prints a list of globally-defined functions. Try it.
Shows the source code for a mezzanine function or a user created function.
source replace .
Red interpreter has:
- the native functions which are "embedded" in the interpreter and are executed at a very low level;
- and mezzanine functions which, even though they are part of Red interpreter (come in the Red executable) are created using Red, that is, they have a source code you can read using
Display version number and build date.