Using reflection on functions

Functions are first-class objects in Red. You can give your own functions, or even built-in ones, another name, as shown here:

;-- see Chapter06/reflection-functions.red:pr: :print           ;== make native! [[pr ["Hello" "Red"]   ;== Hello Red

The : prevents the function from executing; pr: get 'print does the same thing.

This shows Red's flexibility and power; not only changing the name, but even changing the meaning of built-in words is possible. As always, with great power comes great responsibility. Use these and the other metaprogramming features to come sparely, and above all, wisely!  

Functions can contain other functions that are local to that function and that can access all its variables.

A function can also ...

Get Learn Red - Fundamentals of Red now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.