# Evaluation in calling scope?

**URL:** <https://discourse.julialang.org/t/evaluation-in-calling-scope/34897>\
**Category:** General Usage\
**Created:** [February 20, 2020, 11:15am UTC](https://discourse.julialang.org/t/evaluation-in-calling-scope/34897 "2020-02-20T11:15:55Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 21, 2020, 1:23pm UTC](https://discourse.julialang.org/t/evaluation-in-calling-scope/34897/10 "2020-02-21T13:23:18Z")

</div>

> [@tomtom](#):
>
> Ideally a complicated expression of the whole model could be built by chaining the (simpler) expressions generated by the sub-models.

Sounds like you could pass functions instead, since you can chain together functions as well. For example, this combines two single-variable functions `f1(x)` and `f2(x)` into a two-variable function with the `combine(a, b)` function:

```julia
combine(combiner, f1, f2) = (x,y) -> combiner(f1(x), f2(y))

combine(+, sqrt, exp) # returns a function (x,y) -> sqrt(x) + exp(y)

```

This is called a [higher-order function](https://en.wikipedia.org/wiki/Higher-order_function) in computer science, and is _much_ more flexible (in any language) and _much_ faster (in Julia) than working with raw expressions.

I feel like this should be a FAQ or a PSA post. 90% of the people who ask about evaluating expressions or strings in local scope should actually be using a higher-order function, in my experience.

---

_[View the full topic](https://discourse.julialang.org/t/evaluation-in-calling-scope/34897)._
