Skip to content

Instantly share code, notes, and snippets.

@9214 9214/5r.org
Last active Jan 10, 2019

Embed
What would you like to do?
rrrrr (red/rebol resources and rough reasonings)

List of resources for Red and Rebol programming languages

Rebol

Forums and community hubs

Hands-on guides and tutorials

Personal blogs and pages from community members

Books

Red

Media

Forums and community hubs

Hands-on guides and tutorials

Personal blogs and pages from community members

In between

Backtrack
discard paritally matched input and return to previous position;
Fail
find alternative rule in current block or search recursively for one in parent blocks. Fail implies a backtracking (unless no partial match).

When a pipe (|) word is encountered, parse will just jump at the end of the current rule block.

  • collect after, it’s similar to collect into, just appends instead of inserting;
  • keep acts like /only, while keep pick does not.

Zen and the Art of Scope Maintenance: An Inquiry into Contexts

Context is essentialy a namespace

Two key points to get it:

  1. Every word is bound to global context by default at load time (source as text to Red values).
  2. Local contexts are constructed at run-time.
  • Each context constructor will determine which words it should capture by either looking into a declared list (locals in functions), or gather all the set-words (objects).
  • Then, the constructor will go through the nested blocks in the body to bind all the “local” words. When applied in nested way object [... object [... func [...][...]]], the various binding passes will produce a result which mimic nested scopes.
  • That is what we call definitional scoping.

With dynamic scoping we have chains of function calls to traverse, with static scoping we have chains of definitions, but with definitional “scoping” there’s no chains at all, hence there’s no spoon scopes! Multiple rounds of bindings give an illusion of nesting (i.e. static scoping), while in fact all contexts are completely separate, w/o any hierarchy between them.

Red type hierarchy from @toomasv

any-type!
    event!
    unset!
    any-function!
        native! action! op! function! routine!
    any-object!
        object! error!
    series!
        any-block!
            any-list!
                block! paren! hash!
            any-path!
                path! lit-path! set-path! get-path!
        any-string!
            string! file! url! tag! email!
        binary!
        image!
        vector!
    immediate!
        any-word!
            word! set-word! lit-word! get-word! refinement! issue!
        scalar!
            number!
                integer! float! percent!
            char!
            pair!
            tuple!
            time!
        datatype!
        none!
        logic!
        typeset!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.