Red Foundations: Difference between revisions
m
no edit summary
mNo edit summary |
mNo edit summary |
||
Line 1:
(WORK IN PROGRESS)
Human languages use words and symbols. Each word may have a different meaning, depending on the context it has been used or from the context given by the user of the word.
Let's take as an example the word PLAY: it can be used to play a song, or play a game, it could represent the round of a game or it can be a command to a human.
Rebol and Red language have the ability to give the same word different meanings.
So, in a phrase you can have 3 subsequent words which are totally different in their meaning:
PLAY %shine.MP3 PLAY %Frontier-Elite.exe or print PLAY
As a programmer, you have the power to create a sequence of action to instruct the word to do something. Or you can also assign a number to the word. You have the power, you are the creator!
In this case you create a sequence of action and play the sone whose name appears after it
PLAY %shine.MP3
This happens because the word %PLAY has internally a link to the associated action or value. (Change)
The action to perform is stored in a container called Table where the sequence is stored
Example:
Table A
------------------------------------
|PLAY | [execute-player %shine.mp3]|
+-----+----------------------------+
| | |
------------------------------------
Table A
------------------------------------
|PLAY | [run %Frontier-Elite.exe] |
+-----+----------------------------+
| | |
------------------------------------
Or the word can be associated with a value:
Table B
------------------------------------
|PLAY | 1 |
+-----+----------------------------+
| | |
------------------------------------
So, when you start your program and the computer finds
PLAY ..... it reads the internal link to the table as
PLAY(B) and then reads the instruction in the table B for the word PLAY and excutes them, thus starting the game Frontier-Elite
So in the following sequence
PLAY %shine.MP3 PLAY %Frontier-Elite.exe or print PLAY
The word PLAY really does different things even if it seems to be the same on the 3 instances.
Now lets take this:
All Redbol elements are contained in a block.
So,
PLAY %shine.MP3 PLAY %Frontier-Elite.exe print PLAY
is really
[PLAY %shine.MP3 PLAY %Frontier-Elite.exe or print PLAY]
When RUN, the interpreter really reads
[PLAY(A) %shine.MP3 PLAY(B) %Frontier-Elite.exe or print PLAY(C)]
Getting the content of play from the corresponding connected tables.
------------
(Let's introduced manipulating block first, using RED Elements)
|