reflect: make action! [[
{Returns internal details about a value via reflection}
value [any-type!]
field [word!] {spec, body, words, etc. **Each datatype defines its own reflectors**}
]]
Can I get list of datatype - reflector(s) from within red?
@toomasv I see, I will keep this in mind.
>> ? "-of"
body-of function! Returns the body of a value that supports reflection.
caret-to-offset function! Given a text position, returns the corresponding coordinate relative to the top-left o...
class-of function! Returns the class ID of an object.
keys-of function! Returns the list of words of a value that supports reflection.
layout function! Return a face with a pane built from a VID description.
spec-of function! Returns the spec of a value that supports reflection.
values-of function! Returns the list of values of a value that supports reflection.
words-of function! Returns the list of words of a value that supports reflection.
>> ? "reflection"
body-of function! Returns the body of a value that supports reflection.
keys-of function! Returns the list of words of a value that supports reflection.
reflect action! Returns internal details about a value via reflection.
spec-of function! Returns the spec of a value that supports reflection.
values-of function! Returns the list of values of a value that supports reflection.
words-of function! Returns the list of words of a value that supports reflection.
SYSTEM/CATALOG is an object! with the following words and values:
datatypes none! none
actions none! none
natives none! none
accessors block! length: 12 [date! [date year month day zone ti...
errors object! [throw note syntax script math access reserved1...
system/catalog/accessors
exists, but it contains only the words that can access components of values of direct types: extract system/catalog/accessors 2 => date! email! event! image! pair! time!
. To complete Toomas's list:object!
, error!
, port!
and map!
have words-of = keys-of
, values-of
and body-of
any-function!
have spec-of
, body-of
and words-of
(this one not yet implemented)
To answer the original question:
Can I get list of datatype - reflector(s) from within red?
Red [
Title: "Bruteforce search of all available reflectors"
Author: 9214
Date: 9-Oct-2018
]
; N.B. KEYS-OF is an alias for VALUES-OF
reflectors: extract load rejoin take/part at
read/lines https://raw.githubusercontent.com/red/red/master/environment/functions.red
116 5 2
datatypes: remove/part sort load help-string datatype! 12
seeds: [[[][]] [1 1 0] 0 0x0 "."]
cartesian: function [domains body][
product: reduce [body]
do take forall domains [
remove back tail spelling: form domains/1
product: reduce [
head insert product reduce ['foreach to word! spelling domains/1]
]
]
]
probe also catalog: make map! length? datatypes cartesian [reflectors datatypes seeds][
all [
attempt [reflect make get datatype seed reflector]
either catalog/:datatype [
append catalog/:datatype reflector
][
catalog/:datatype: make block! length? reflectors
]
]
]
w2: 'foo/('bar)/baz
; == foo/('bar)/baz
get w2
; == 42
w3: 'foo/('bar)
select get w3 'baz
?
w3: to-path w3
select w3 'baz
>> ? :w
FOO/BAR/BAZ is an integer of value: 42
@nedzadarek
w: 'FOO/(:REDUCES-TO-BAR)/BAZ
is the answer