[REBOL] Re: Unofficial examination of undocumented REBOL features (draft)
From: ryanc:iesco-dms at: 24-Oct-2000 14:45
I like your idea Thomas to document some of the neet lesser known things you can do with
rebol. Here is one I just discovered today.
The paren! can be used much like a series!...
>> p: load "(a (aa (stuff) ) )"
== (a (aa (stuff)))
>> p/a/aa
== (stuff)
>> first p/a/aa
== stuff
>> p/1
== a
>> p/2
== (aa (stuff))
>>
The paren! datatype is a bit harder to work with because its basic nature is to interpet
everything. For instance:
>> p: load "(a (aa (stuff) ) )"
== (a (aa (stuff)))
>> insert p 'myword ;this will try to interpet p
** Script Error: a has no value.
** Where: a (aa (stuff))
>> insert :p 'myword ;getting p's value directly bypasses this effect.
== (a (aa (stuff)))
>> :p
== (myword a (aa (stuff)))
>>
It seems to me that the difference between paren! and block! is only that paren!'s are
executed during the interpeting process.
--Ryan
Thomas Jensen wrote:
> Hello list,
>
> Inspired by the recent "objects without overhead" thread, I decided to draft a document,
describing some of the undocumented features of REBOL.
>
> I have attached my first atempt, which is also available at:
> http://www.obscure.dk/rebol/REBOL_behaviour.txt
>
> My hope is that many people will contribute with corrections, whole sections and very
important; REBOL code to prove/disprove the assumptions made in the document.
>
> What do you think?
> Is it a generally good/bad idea?
> Is it structured right? focusing on the right aspects?
>
> Best regards
> Thomas Jensen
>
> BTW.
> English is not my native language, so please don't be shy to comment on the words/language/spelling
used in the document :-)
>
> -- Attached file included as plaintext by Listar --
> -- File: REBOL_behaviour.txt
>
> Title: Unofficial examination of undocumented REBOL features
> Version: 0.1
> Status: draft
> original Author: Thomas Jensen ([thomas--obscure--dk])
> Maintainer: Thomas Jensen ([thomas--obscure--dk])
> Created: 23-Oct-2000
> Last modified: 23-Oct-2000
> History:
> 0.1: initial version
>
> *** disclamer ***
>
> The contents of this document is based on observered behaviour of the REBOL(tm)
> intepreter.
> The information given in this document is in no way endorsed by
> REBOL Technologies (REBOL tech.)
>
> *** goal ***
>
> To provide an description of some of the undocumented aspects of the REBOL(tm)
> language.
> These include: parsing, evaluation, contexts, values, words, objects and
> functions.
>
> Because REBOL is closed-source, some of these aspects can only be examined by
> analyzing the behaviour of the current REBOL intepreter. The reference version
> of the intepretor is always the most resent version of REBOL/Core, as other
> flavours (REBOL/View, REBOL/Command, etc) are presumed to be based on
> REBOL/Core code.
>
> *** concepts ***
>
> * context:
> a list of word/value pairs, a value being any valid REBOL value,
> including unset!
>
> In this text, I'll presume that a REBOL context! datatype exist
>
> * global context or top level context:
> the context represented by the 'words object! contained in the 'system
> object!
>
> * function:
> a REBOL function! value
>
> * object:
> a REBOL object! value
>
> * word!:
> a REBOL word! value
>
> *** operational behaviour ***
>
> a) LOAD (string!) behaviour
>
> 1) parse the source string into valid REBOL tokens.
>
> 2) for each token, determine the datatype and create the corresponding
> REBOL value.
> (If more than one value is present, create a block! value to contain
> them).
>
> NOTE: not all REBOL datetypes can be created in this step.
> Those that can is:
> * string! "a string" {a string}
> * email! [my--email--com]
> * integer! 1
> * decimal! 1.5
> * block! []
> * word! my-word
> * set-word! my-set-word:
> * get-word! :my-get-word
> * lit-word! 'my-lit-word
> * refinement! /my-refinement
> * file! %my-file.r
> * issue! #my-issue
> * money! $1.50
> * paren! ()
> * path! my/path/value
>
> Those that can't is:
> * list!
> * hash!
> * function!
> * object!
> * unset!
> * datatype!
> * native!
>
> 3) traverse the block, and act according to the datatype:
>
> 3.1) word!, set-word! and get-word!:
>
> 3.1.1) look in system/words to see if the word is present there.
>
> 3.1.2) If it is not, create it with a value of type unset!
>
> 3.1.3) BIND the word to system/words
>
> 3.2) block!, paren!:
>
> 3.2.1) Process step 3 for this block (or paren)
>
> 3.3) path!
>
> 3.3.1) unfinished
>
> 4) return the block! or value
>
> b) BIND (block!, word!) behaviour
>
> 1) the target context is found using the 'known-word
>
> 2) the block is traversed, and each value is checked for one of the
> following types
>
> 2.1) word!, set-word!, get-word! refinement!, and path!
>
> 2.1.1) an internal reference in the value is set to refer to the
> target context!
>
> b1) BIND/COPY behaviour
>
> Like b) with these additions:
>
> 1a) the block! is copied (including sub-blocks, parens, etc), and all
> actions are performed on the copy instead of the original
>
> 2.2) block! paren! list! hash!
>
> 2.2.1) BIND/COPY is called recursivly on the value
>
> c) DO behaviour
>
> d) MAKE FUNCTION! (aka func) behaviour
>
> e) MAKE OBJECT! behaviour
>
> f) USE behaviour
>
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400
I am enough of an artist to draw freely upon my imagination.
Imagination is more important than knowledge. Knowledge is
limited. Imagination encircles the world.
-Einstein