1

Some functions that are used in the 'layout function do apparently not exist, yet 'layout works fine. But when you try to replace the 'layout function by an adapted version containing some debugging statements, the functions and undeclared variables will immediately cause an error.

The functions BIND? and BOUND? don't show results for, for example, the used TRACK function, so there is no extra information by using those. Special interest in the do-facets and grow-facets functions.

2 Answers 2

2

Here are two ways to create anonymous contexts in Rebol 2:

context [
    semi-hidden-function: does [print "ok"]
    set 'non-hidden-function does [semi-hidden-function]
]

use [semi-hidden-function] [
    semi-hidden-function: does [print "ok"]
    set 'non-hidden-function does [semi-hidden-function]
]

In the first form you may reach the context of the word semi-hidden-function:

>> probe bound? first body-of :non-hidden-function
make object! [
    semi-hidden-function: func [][print "ok"]
]

But in second form you may not:

>> probe bound? first body-of :non-hidden-function
make object! [
]

I see many Rebolers use one of above forms, not only to hide but to keep the main function clean and separate.

Here I also add the functions you like to see, it is a bit long so I compressed & enbased:

You can simply paste below line to the console, copy the below text and execute the line to decompress it: write clipboard:// decompress debase trim/lines read clipboard://

eJyNVrty6zYQrcmvWKuJPWNFqXkn0Uyq29zbpeKwgMElhRgCOABoRfn67C7Ah5xkksJje3dxcPZ1w
N4fB6UxxQaG2Wlo6+rw62xsD2/W63fwA0wqqCsmDBGeletBpRTM25wQbj708QVuF2MRnE+g4MP0Yg
YfIKa7xR8PdRUn1DFHZ2OEE6ErC/luMAmvdUd3L1y0n+7QdnWVsVsGT8rYMwhWxzwrPkW0TYgpm9k
2QMR05LvO0HAEtG8B1TthVWjSBQM8OMnMh5Sj+wZD6VEGx0xVAsRWSLOh2+BWtsZFDGlJptwiiBxV
KWuhzZCCtqF3m188gnD85O/a5I/WZHvhsDi79u88Tt7Z+0JGsuRA+pEaNeDwj7VeZA7Yz5pKnJtU/
rugKmyo1vCFm4sLpAoI+KHsrBL2FBnwqe7qegz+9mmWHN4oely7PSnqFSS6n9K7qpFKqr31gevC9Z
WRi0DYkK6TNJkgTgsoQ9V19eV4hG+zTUbsQPfOE7HSGicm9ByTSkYzyozxpa7k1gZAW1RBhkoYPFg
yjWZnEUYPMZndPibnsLPQMR+4nZI194ZYLCMq9KkLN5P05dTjoCgJSPcJzydpLect/WTGTwDQqmlC
GotcN3LLPBiXcEQK+Gd3pO104+bN5V68aZ4sPm3Qpf6LW3Lc3HmUtrbkqTeCsELk3i3eOVh2/otXK
ra7vkzB4tYXlRPntr/jXfsem9Vr/Wj0U/H2Kime5duJ+72L6lETKpHYha3Zmyuu+OHhGHdAXHkl1+
UVceAF5SN5M2k2m7zJm61hnOVINbtkeKdpC5Lx7lwmQA7K+sl482ItITB4a/2tqOQrjDOpLjUa+wL
J09NA7zcoWNYrR3Qr3Y3fXk+adbyqVQl/gl9+JokfSDLPAjncjjSeF2iJGs2Zp8V3stRl+cvx/5fg
Evyf1IuM7Yhlrc8HBS8vFIZA78rhm4mRZpyN8xUdKa8Ph9yCFaiinCgFuYkzL8CTjyaZDzyvaVPKA
6IoDmynq4edXVhSVdBGfCUV/oEkx4F/+x11gmdiRZXCF4izvoAiQfNEi6z8eG6g1JwNF9qresf8To
yPZPkN4oKf8lhtZ7qNTP3pj/K7I47f5SmWRys/xrluJsoj7WiosH8Fqsci9zc/04t/UR8IWs3jhci
kegXdHppS/99cQO1HZ/7Efvs8aA7MPb81XdHpr/TBQCSuLNflcXiFIn35JTGO2mJYuIfgr2vmTZZ+
OXhiCQMpjojZ3hWJQ3aJCu5drDzZJRq0d4nsiCsL0N4niii+rI17X/4mYl/WxLr7C5ZY7idACQAA
4
  • I didn't check the source codes how do-facets & grow-facets made hidden, I just supposed that it is like above and explain it as so.
    – endo64
    Commented Apr 25, 2020 at 11:16
  • But you can show the definition of your semi-hidden-function also in the second example
    – sqlab
    Commented Apr 25, 2020 at 16:12
  • Thank you Endo, that is very helpful!
    – iArnold
    Commented Apr 25, 2020 at 19:02
  • @iArnold glad it helped.
    – endo64
    Commented Apr 25, 2020 at 22:20
1

You can find the definitions in the source files of the sdk e.g

track: func [blk] [if verbose [print blk]]

in view-vid.r

Here a helper function to get the definition/source of a word/function in an unknown context and e.g. without access to the sdk

find-anon: func [ words fn /local   ] [ 
    foreach word words [
        if word = fn [set :fn probe get word halt]
        if block? word [
            find-anon word fn
        ]
    ]
]

find-anon second :layout 'grow-facets
help grow-facets
3
  • This answer assumes you have access to the sdk. It does not completely explain why the functions are no longer available when redefining the layout function.
    – iArnold
    Commented Apr 24, 2020 at 20:01
  • You know about (anonymous) contexts and setting a 'function ?
    – sqlab
    Commented Apr 25, 2020 at 8:28
  • I did not until Endo's answer to my question.
    – iArnold
    Commented Apr 25, 2020 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.