Search code examples
objectnamespacesconflictrebol

How to avoid name conflict between object function and global function in Rebol?


I have an object with a function named open that need to call global open.

obj: make object! [
    open: func [fn] [
        client: open fn ...
    ]
]

This obiously fails with stack overflow...

So, how can access global open inside object open ? (Please don't tell me "change name" :-)


Solution

  • In Rebol 3, you can use lib/open to refer to the built-in open function.

    lib is an object (which in Rebol-lingo is also sometimes called a "context") which holds all publicly exported functions, including built-in functions. The full name for the lib context is system/contexts/lib (so you could also use system/contexts/lib/open to refer to the open built-in), but because that's a mouthful, the convenience shortcut lib is provided as well.

    Also see Brian Hawley's answer regarding "user-defined words" and Carl Sassenrath's post on the basic contexts of R3 for more technical detail.