Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Rebol
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====do==== The most frequently used evaluator is the <code>do</code> function. It is used by default to interpret the text input to the interpreter [[command line interface|console]]. The ''do dialect'' interpreted by the <code>do</code> function, is an [[expression-oriented programming languages|expression-oriented]] sublanguage of the ''data exchange dialect''. The main semantic unit of the language is the [[expression (programming)|expression]]. In contrast to imperative programming languages descending from [[ALGOL]], the ''do dialect'' has neither keywords, nor statements. Words are used as [[case sensitivity|case-insensitive]] [[variable (programming)|variables]]. Like in all [[dynamically typed language]]s, variables don't have an associated type, type is associated with values. The result, i.e. the evaluation of a word is returned, when a word is encountered by the <code>do</code> function. The set-word form of a word can be used for [[assignment (computer science)|assignment]]. While not having statements, assignment, together with [[side-effect (computer science)|functions with side-effects]] can be used for [[imperative programming]].<ref name="OG" /> Subblocks of the root block evaluate to themselves. This property is used to handle data blocks, for [[structured programming]] by submitting blocks as arguments to [[control flow|control]] functions like <code>if</code>, <code>either</code>, <code>loop</code>, etc., and for dialecting, when a block is passed to a specific interpreter function.<ref name="RD" /> A specific problem worth noting is that composite values, assigned to variables, are not copied. To make a copy, the value must be passed to the <code>copy</code> function.<ref name="OG" /> The <code>do</code> function normally follows a [[polish notation|prefix style of evaluation]], where a function processes the arguments that follow it. However, [[infix notation|infix evaluation]] using infix [[operator (programming)|operator]]s exists too. Infix evaluation takes precedence over the prefix evaluation. For example, [[absolute value|abs]] -2 + 3 returns 1, since the infix addition takes precedence over the computation of the absolute value. When evaluating infix expressions, the order of evaluation is left to right, no operator takes [[Order of operations|precedence]] over another. For example, <syntaxhighlight lang="smalltalk"> 2 + 3 * 4 </syntaxhighlight> returns 20, while an evaluation giving precedence to multiplication would yield 14. All operators have prefix versions. <code>Do</code> usually evaluates arguments before passing them to a function. So, the below expression: <div class="plainlinks"> print read http://en.wikipedia.org/wiki/Rebol </div> first reads the Wikipedia Rebol page and then passes the result to the <code>print</code> function. Parentheses can be used to change the order of evaluation. Using [[Polish notation|prefix notation]], the usage of parentheses in expressions can be avoided.<ref name="OG" /> The simple precedence rules are both an advantage: * No need to "consult" precedence tables when writing expressions * No need to rewrite precedence tables when a new operator is defined * Expressions can be easily [[transliteration|transliterated]] from infix to prefix notation and vice versa as well as a disadvantage: * Users accustomed to more conventional precedence rules may easily make a mistake<ref name="RD" />
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Rebol
(section)
Add topic