Reserved words?

Discussion in 'Rebol' started by MaxV, Sep 29, 2010.

  1. MaxV

    MaxV Member

    How can I get a list of reserved words?
    Example: ["read" "load" "write" ... ] and so on....
  2. Graham

    Graham Developer Staff Member

    Try

    What
  3. Peter Wood

    Peter Wood New Member

    One thing to watch out for is that they are not reserved words, they are supplied functions. You can easily overwrite them if you are not careful such as in this example:

    >> read: 0
    == 0
    >> read %bbc.co.uk
    == %bbc.co.uk

    You can use the protect-system function to stop yourself accidentally overwriting the pre-defined functions

    >> protect-system
    >> read: 1
    ** Script Error: Word read is protected, cannot modify
    ** Near: read: 1
  4. MaxV

    MaxV Member

    Great! I'm always scared to modify some essential function....
  5. MaxV

    MaxV Member

    what print directly the words on the screen, how can I store them in a series?
  6. Graham

    Graham Developer Staff Member

    you can use 'echo to redirect screen output to a file, or rewrite 'what using the source
  7. Sunanda

    Sunanda New Member

    As Graham says, you could edit the source of what to gather the words in a block, and return that. To save you the bother, it's something I've already done:

    Code:
     what-ho: func [
        "Gathers a list of globally-defined functions."
        /local vals args here total words
    ][
        total: copy []
        words: copy []
        vals: second system/words
        foreach word first system/words [
            if any-function? first vals [
                args: first first vals
                if here: find args /local [args: copy/part args here]
                append total reduce [word mold args]
            ]
            vals: next vals
        ]
        foreach [word args] sort/skip total 2 [append/only words reduce [word args]]
        return words
    ]
    Example of use:
    Code:
    my-series: what-ho    ;; ho for Hold Output, I guess
    That's the R2 mod. The R3 equivalent should be just as simple.

Share This Page