apply
, but you can use tricks similar to the above one.
Well, thanks, I was just imaging if there where a simple way to load code words/values at the current program execution position. So, it FOO expected X and Y then something like
(I assume "<" mean: "insert the result of the code between parens at this point")
FOO <(BAR)
Print "A"
Would be interpreted like
FOO 1 2
Print "A"
>> foo: func [x y][x + y]
== func [x y][x + y]
>> bar: does [[1 2]]
== func [][[1 2]]
>> compose [foo (bar)]
== [foo 1 2]
>> do compose [foo (bar)]
== 3
Macros is not what you want, I guess. They can't operate on values that are presented at run-time (i.e. you can't evaluate function bar
, because it doesn't exist yet).#do [bar: [1 2]]
#macro ['< paren!] func [start end][
get in preprocessor/exec start/2/1
]
probe expand [
foo <(bar)
foo #do keep [[1 2]]
]
>> apply: func [function data][do compose reduce [function quote (data)]]
== func [function data][do compose reduce [function quote (data)]]
>> apply 'reverse/part [[a b c d] 2]
== [b a c d]
>> skip tail words-of system/words -5
== [right-menu left-command right-command caps-lock num-lock]
>> 'abracadabra
== abracadabra
>> skip tail words-of system/words -5
== [left-command right-command caps-lock num-lock abracadabra]
>> [what? no this can't be serious!]
== [what? no this can't be serious!]
>> skip tail words-of system/words -5
== [what? this can't be serious!]
no
isn't among the last 5 "mentioned" words, because it was already pre-defined.
get
.
@Ungaretti context
is a wrapper around make object!
:
>> source context
context: func ["Makes a new object from an evaluated spec"
spec [block!]
][
make object! spec
]
object
is a... well, see yourself :wink:
object: :context
, so they are the same?