Function proxy a la Misty #11
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Proxy
A function can be used as a proxy for a record. If a function is called as
function.name(input_value_a, input_value_b)
then the function will be called as though it had been written as
function("name", [input_value_a, input_value_b])
The function will be called with the name of the method and an array of input values. The result that is returned by the function will be given to the caller.
Example:
def my_record: {
a(value) (
"a-" & value
)
}
def pseudorecord(
name
input_values
) {
if function?(my_record[name])
return apply(my_record[name], input_values)
fi
log error: "something is wrong with" ≈ name
disrupt
}
function?(pseudorecord) # true
stone?(pseudorecord) # true
record?(pseudorecord) # false
length(pseudorecord) # 0
arity(pseudorecord) # 2
pseudorecord.a("ok") # "a-ok"
pseudorecord.b("ok") # disrupt
////
This would break some code, but not much, and would be as useful as the JS proxy, but more well defined, and thus faster