# Functions

**URL:** https://rebol.metaeducation.com/c/development/functions/59.md

[Latest](https://rebol.metaeducation.com/latest.md) · [Categories](https://rebol.metaeducation.com/categories.md) · [Tags](https://rebol.metaeducation.com/tags.md)

---

## [About the Functions category](https://rebol.metaeducation.com/t/about-the-functions-category/1931)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 0

</div>

Discussions of Functions and Generators, e.g. how things like RETURN work... or the mechanics of generators and composers like ADAPT, SPECIALIZE, ENCLOSE, HIJACK, etc.

---

## [What Are Definitional Returns?](https://rebol.metaeducation.com/t/what-are-definitional-returns/2191)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 2\
**Last updated:** [September 14, 2026, 3:46am UTC](https://rebol.metaeducation.com/t/what-are-definitional-returns/2191 "2026-09-14T03:46:03Z")

</div>

Novices using Rebol2 or Red aren't really clear on how their RETURN works. (Or doesn't work, as the case may be.) RETURN climbs the stack until it finds a function that is willing to accept returns. Functions in Rebo…

---

## [Multi-Return 2026: It's Good, But Could It Be Better?](https://rebol.metaeducation.com/t/multi-return-2026-its-good-but-could-it-be-better/2695)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 0\
**Last updated:** [March 6, 2026, 5:26am UTC](https://rebol.metaeducation.com/t/multi-return-2026-its-good-but-could-it-be-better/2695 "2026-03-06T05:26:16Z")

</div>

So I've gotten more enamored of this idea with time. Looking at something from the tests: export do-recover: func \[ "Executes tests in the FILE and recovers from crash" return: \[ ~( file! …

---

## [Function Specs: Merge TEXT! Into Parameter Specs?](https://rebol.metaeducation.com/t/function-specs-merge-text-into-parameter-specs/2668)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 0\
**Last updated:** [January 29, 2026, 5:46am UTC](https://rebol.metaeducation.com/t/function-specs-merge-text-into-parameter-specs/2668 "2026-01-29T05:46:26Z")

</div>

I wrote about the new feature of being able to put descriptions of what each type does in a type spec block: I like this. Though it made me start to wonder... If TEXT! strings are legal in the spec, what if we said t…

---

## [Default Values and MAKE FRAME! - 2024 Edition](https://rebol.metaeducation.com/t/default-values-and-make-frame-2024-edition/2347)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 3\
**Last updated:** [January 28, 2026, 2:39pm UTC](https://rebol.metaeducation.com/t/default-values-and-make-frame-2024-edition/2347 "2026-01-28T14:39:04Z")

</div>

NOTE: The below summarizes history with some adjustments made for simplification purposes. See posts in Archive regarding frames for all the exact detours. Something like this has worked ever since the first FRAME!: …

---

## [Should You Un-Ask For Refinements w/OPT, not NULL?](https://rebol.metaeducation.com/t/should-you-un-ask-for-refinements-w-opt-not-null/2363)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 7\
**Last updated:** [January 22, 2026, 7:30pm UTC](https://rebol.metaeducation.com/t/should-you-un-ask-for-refinements-w-opt-not-null/2363 "2026-01-22T19:30:59Z")

</div>

The concept behind NULL is that it's a somewhat-ornery state, that most functions don't take by default. So it helps catch mistakes. This makes me feel it's a bit haphazard to accept it at callsites: \>\> count: null ;…

---

## [Rethinking \`\<static\>\` in the Function Spec Dialect](https://rebol.metaeducation.com/t/rethinking-static-in-the-function-spec-dialect/2139)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 1\
**Last updated:** [December 26, 2025, 5:19pm UTC](https://rebol.metaeducation.com/t/rethinking-static-in-the-function-spec-dialect/2139 "2025-12-26T17:19:20Z")

</div>

In R3-Alpha, the FUNCTION construct was built on top of FUNC, and added features like statics as a refinement. It looked pretty awkward, because the static was added at the end of the expression: r3-alpha\>\> foo: funct…

---

## [How To Indicate "Divergence" in Function RETURN: Spec](https://rebol.metaeducation.com/t/how-to-indicate-divergence-in-function-return-spec/1667)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 3\
**Last updated:** [December 5, 2025, 12:31am UTC](https://rebol.metaeducation.com/t/how-to-indicate-divergence-in-function-return-spec/1667 "2025-12-05T00:31:53Z")

</div>

Today's vocabulary word is divergent functions...when a function never returns a result in a "normal" way. All functions that can PANIC or be THROWN or RETURN'd across have divergence as an option (which is, right now, …

---

## [Non-Words in Function Parameter Spec Dialect](https://rebol.metaeducation.com/t/non-words-in-function-parameter-spec-dialect/2064)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 1\
**Last updated:** [December 2, 2025, 6:00am UTC](https://rebol.metaeducation.com/t/non-words-in-function-parameter-spec-dialect/2064 "2025-12-02T06:00:47Z")

</div>

Historical Redbol only had WORD!s in the BLOCK! that came after a parameter: foo: func \[ arg \[block! word! number!\] ; all words in block \] ... But when Ren-C introduced the paradigm-breaking NULL that could not b…

---

## [RETURN PARAMETER! Holds Function Description](https://rebol.metaeducation.com/t/return-parameter-holds-function-description/2577)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 0\
**Last updated:** [December 1, 2025, 1:57pm UTC](https://rebol.metaeducation.com/t/return-parameter-holds-function-description/2577 "2025-12-01T13:57:25Z")

</div>

Historically, a function could have distinct description of itself "overall" from a description of its return value: \>\> sum-two: func \[ "This function sums two integers" return: \[integer!\] "Sum of a and b"…

---

## [Idea for Naming Function Arguments Out of the Way](https://rebol.metaeducation.com/t/idea-for-naming-function-arguments-out-of-the-way/1167)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 2\
**Last updated:** [December 1, 2025, 3:01am UTC](https://rebol.metaeducation.com/t/idea-for-naming-function-arguments-out-of-the-way/1167 "2025-12-01T03:01:17Z")

</div>

As part of Rebol's contention-for-short-names problem, there are many instances where refinements have names like :ALL where they conflict with common natives or lib functions. When this happens, I tend to do something …

---

## [Should Functions With No Return Typespec Decay Packs?](https://rebol.metaeducation.com/t/should-functions-with-no-return-typespec-decay-packs/2571)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 0\
**Last updated:** [November 28, 2025, 4:53pm UTC](https://rebol.metaeducation.com/t/should-functions-with-no-return-typespec-decay-packs/2571 "2025-11-28T16:53:48Z")

</div>

Imagine you write something like: try-digit-to-bool: lambda \[i \[integer!\]\] \[ switch i \[ 0 \["false"\] 1 \["true"\] 3 \[print "DEBUG: got 3" null\] \] \] I feel it's a bit of a thorn that the fol…

---

## [LAMBDA and YIELDER and Specifying "Return" Specs](https://rebol.metaeducation.com/t/lambda-and-yielder-and-specifying-return-specs/2567)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 1\
**Last updated:** [November 28, 2025, 7:01am UTC](https://rebol.metaeducation.com/t/lambda-and-yielder-and-specifying-return-specs/2567 "2025-11-28T07:01:34Z")

</div>

Actions that lack RETURN functions might nevertheless want to document their potential return product. intsum: lambda \[x \[integer!\] y \[integer!\]\] \[ x + y ; want to document this will be an integer \] twoints: yield…

---

## [Making FUNC Variant That Auto-Returns Last Result](https://rebol.metaeducation.com/t/making-func-variant-that-auto-returns-last-result/2124)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 2\
**Last updated:** [February 1, 2024, 9:03pm UTC](https://rebol.metaeducation.com/t/making-func-variant-that-auto-returns-last-result/2124 "2024-02-01T21:03:15Z")

</div>

I had offered that people could use this simple wrapper to get the old behavior of FUNC, to drop out its last result (instead of returning nothing): func: adapt lib.func/ \[body: compose \[return (as group! body)\]\] The c…

---

## [Refinement Arguments at Head of Args List, Not Tail](https://rebol.metaeducation.com/t/refinement-arguments-at-head-of-args-list-not-tail/2331)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 8\
**Last updated:** [October 24, 2025, 10:21pm UTC](https://rebol.metaeducation.com/t/refinement-arguments-at-head-of-args-list-not-tail/2331 "2025-10-24T22:21:38Z")

</div>

In the corpus of code we have so far, it seems to me that when a refinement adds an argument to a function that it would be preferable if that argument would become the first parameter... not tacked onto the end. Some c…

---

## [GROUP!-headed Dispatch Of Functions Via WORD! (?)](https://rebol.metaeducation.com/t/group-headed-dispatch-of-functions-via-word/2548)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 0\
**Last updated:** [October 24, 2025, 7:49am UTC](https://rebol.metaeducation.com/t/group-headed-dispatch-of-functions-via-word/2548 "2025-10-24T07:49:13Z")

</div>

If we want to use a GROUP! to assign a variable, we do that via the variable's "name", e.g. a bound WORD!: But I noticed that to do a function, you have to do it by value of the function: And if GROUP!-headed non-tri…

---

## [Bringing Back Multiple Function Types...?](https://rebol.metaeducation.com/t/bringing-back-multiple-function-types/2528)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 0\
**Last updated:** [August 14, 2025, 7:55pm UTC](https://rebol.metaeducation.com/t/bringing-back-multiple-function-types/2528 "2025-08-14T19:55:30Z")

</div>

There was a big consolidation of the mechanisms by which functions run, which gave us the invention of FRAME!. Behind the scenes, each function category actually has a different "Dispatcher"... the C code that knows how…

---

## [Design for Something Like FLIP To Reverse Arguments](https://rebol.metaeducation.com/t/design-for-something-like-flip-to-reverse-arguments/2345)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 3\
**Last updated:** [July 15, 2025, 9:10am UTC](https://rebol.metaeducation.com/t/design-for-something-like-flip-to-reverse-arguments/2345 "2025-07-15T09:10:18Z")

</div>

The design of a FLIP-like operation raises some questions. If it were an operator that acted on functions, it wouldn't retrigger them. You'd have to say: \>\> append 'd \[a b c\] == \[a b c d\] \>\> run flip append/ \[a b c\]…

---

## [Picking Function Arguments By Integer](https://rebol.metaeducation.com/t/picking-function-arguments-by-integer/2507)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 1\
**Last updated:** [July 14, 2025, 6:23am UTC](https://rebol.metaeducation.com/t/picking-function-arguments-by-integer/2507 "2025-07-14T06:23:59Z")

</div>

Having concepts like CHAIN! means there are "set integers" now, which has opened up the possibility for things like: sub1000: specialize subtract/ \[2: 1000\] This would prevent you from having to specifically know the n…

---

## [When Should Functions Validate Their Type Specs?](https://rebol.metaeducation.com/t/when-should-functions-validate-their-type-specs/2391)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 5\
**Last updated:** [April 5, 2025, 11:48am UTC](https://rebol.metaeducation.com/t/when-should-functions-validate-their-type-specs/2391 "2025-04-05T11:48:43Z")

</div>

You're able to use things in the body of a function that aren't defined yet: \>\> foo: func \[x\] \[if cool-number? x \[print "It's cool"\]\] No error there, until you run the function. But what if you use a datatype that's n…

---

## [Chaining Return Types](https://rebol.metaeducation.com/t/chaining-return-types/1467)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 1\
**Last updated:** [March 31, 2025, 3:12am UTC](https://rebol.metaeducation.com/t/chaining-return-types/1467 "2025-03-31T03:12:58Z")

</div>

Something that bothers me about C is that it doesn't let you write chaining void returns: void my\_function() { return some\_void\_function(...); /\* this is not legal! \*/ } That annoys me, because it makes it hard to…

---

## [Infix Arity 0: "Same EVAL:STEP as Prior Expression"](https://rebol.metaeducation.com/t/infix-arity-0-same-eval-step-as-prior-expression/1251)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 0\
**Last updated:** [December 12, 2019, 6:56am UTC](https://rebol.metaeducation.com/t/infix-arity-0-same-eval-step-as-prior-expression/1251 "2019-12-12T06:56:13Z")

</div>

In 2017 while trying to formalize some code I faced a question: How should the evaluator deal with a function that is marked as getting its first argument from the left (e.g. "infix") if that operation takes no arguments…

---

## [HIJACK-protection: Preserve a Weird Feature? 🫤](https://rebol.metaeducation.com/t/hijack-protection-preserve-a-weird-feature/2348)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 2\
**Last updated:** [January 29, 2025, 2:13am UTC](https://rebol.metaeducation.com/t/hijack-protection-preserve-a-weird-feature/2348 "2025-01-29T02:13:57Z")

</div>

The HIJACK functionality was proposed by @gchiu, many years ago: \>\> /foo: func \[x\] \[print \["FOO" (x + 1)\] \>\> /foo-reference: foo/ \>\> foo 20 FOO 21 \>\> foo-reference 20 FOO 21 \>\> /bar: func \[x\] \[print \["HIJACKED!" (x +…

---

## [Simplifying Refinement Promotion](https://rebol.metaeducation.com/t/simplifying-refinement-promotion/2338)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 3\
**Last updated:** [January 15, 2025, 4:26pm UTC](https://rebol.metaeducation.com/t/simplifying-refinement-promotion/2338 "2025-01-15T16:26:57Z")

</div>

There are two modes of partial specialization which Ren-C has supported. One form would be like if APPEND takes something like :DUP and fixes it to a value: \>\> append2: specialize append/ \[dup: 2\] \>\> append2 \[a b c\] \<d…

---

## [How Persistent Is Infixedness?](https://rebol.metaeducation.com/t/how-persistent-is-infixedness/2359)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 0\
**Last updated:** [December 27, 2024, 5:21am UTC](https://rebol.metaeducation.com/t/how-persistent-is-infixedness/2359 "2024-12-27T05:21:14Z")

</div>

Infixedness is a property that FRAME! cells can carry. There are 4 states that consume 2 bits: "Prefix" (not infixed at all) "Normal" Infix (sees exactly one item to the left, processed before the previous express…

---

## [Tail Calls in Ren-C...Yes, We Have Them](https://rebol.metaeducation.com/t/tail-calls-in-ren-c-yes-we-have-them/2082)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 1\
**Last updated:** [December 27, 2024, 6:35am UTC](https://rebol.metaeducation.com/t/tail-calls-in-ren-c-yes-we-have-them/2082 "2024-12-27T06:35:18Z")

</div>

Looking into some of Joe Marshall's historical participation in Rebol, he speaks about Rebol 1.0 having "continuations" and "tail calls". Ren-C uses continuations to implement stacklessness, based on a trampoline. Tram…

---

## [\-\> for Lightweight Lambda ("Arrow Functions")](https://rebol.metaeducation.com/t/for-lightweight-lambda-arrow-functions/2172)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 3\
**Last updated:** [December 22, 2024, 5:49pm UTC](https://rebol.metaeducation.com/t/for-lightweight-lambda-arrow-functions/2172 "2024-12-22T17:49:54Z")

</div>

So I'm still shoring up a new bootstrap executable, patching around in a 6-years-out-of-date codebase. It's in some ways a cruel and unusual punishment... but in other ways a good trip down memory lane to revisit decis…

---

## [Multiple Return Values Via Infix](https://rebol.metaeducation.com/t/multiple-return-values-via-infix/1257)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 0\
**Last updated:** [February 1, 2020, 5:04am UTC](https://rebol.metaeducation.com/t/multiple-return-values-via-infix/1257 "2020-02-01T05:04:04Z")

</div>

Note: Before multi-returns had an implementation in the C code of the evaluator, I observed they could be implemented by means of infix and skippable parameters. This was that implementation. It's still cool to look b…

---

## [Generalized Argument Removal - SPECIALIZE:RELAX](https://rebol.metaeducation.com/t/generalized-argument-removal-specialize-relax/2297)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 2\
**Last updated:** [September 24, 2024, 2:20am UTC](https://rebol.metaeducation.com/t/generalized-argument-removal-specialize-relax/2297 "2024-09-24T02:20:24Z")

</div>

Let's say you want a version of append that just appends random numbers to things: \>\> append-random: adapt get $append \[ value: random 10 \] This works, but the function interface still thinks it takes two arg…

---

## [Representing Everything About A Parameter (...except its name)](https://rebol.metaeducation.com/t/representing-everything-about-a-parameter-except-its-name/1459)

<div class="topic-metadata">

**Author:** [@hostilefork](https://rebol.metaeducation.com/u/hostilefork)\
**Replies:** 4\
**Last updated:** [September 21, 2024, 3:44pm UTC](https://rebol.metaeducation.com/t/representing-everything-about-a-parameter-except-its-name/1459 "2024-09-21T15:44:34Z")

</div>

I'm aiming to draw out the string labels in parameter lists into their own more compact form, that's just the pointer to the string name. We can think of splitting out the symbol as if decorations we currently put on th…

[Next page](https://rebol.metaeducation.com/c/development/functions/59.md?page=1)
