small medium large xlarge

20 Mar 2017, 21:53
Mark Elston (5 posts)

In chapter 5 you have a quick blurb on the use of pinning a parameter value in a function definition. I don’t understand why this is needed. Two pages previously you stated that a function being created carries the binding of variables available during its creation. In fact, the example used there includes a variable with the name name.

Then, on page 44, you call a function passing in a parameter named name but then apparently have to pin it to use its value in the returned function. Why is pinning required in this context but not in the previous context? I don’t see any difference between the two.

22 Mar 2017, 00:04
Dave Thomas (389 posts)

In the example on page 44, we want to match a message that contains the name we passed in to the outer function.

If we just had receive do {name,...} then the receive function would assign whatever was in the incoming message to the variable name. By pinning it, we tell receive only to match that specific name.

You must be logged in to comment