Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 987273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:27:08+00:00 2026-05-16T05:27:08+00:00

Playing with Erlang, I’ve got a process-looping function like: process_loop(…A long list of parameters

  • 0

Playing with Erlang, I’ve got a process-looping function like:

process_loop(...A long list of parameters here...) ->
    receive
        ...Message processing logic involving the function parameters...
    end,
    process_loop(...Same long list of parameters...)
end.

It looks quite ugly, so I tried a refactoring like that:

process_loop(...A long list of parameters...) ->
    Loop = fun() ->
        receive
            ...Message processing logic...
        end,
        Loop()
    end,
    Loop()
end.

But it turned out to be incorrect, as Loop variable is unbound inside the Loop function. So, I’ve arranged a workaround:

process_loop(...A long list of parameters...) ->
    Loop = fun(Next) ->
        receive
            ...Message processing logic...
        end,
        Next(Next)
    end,
    Loop(Loop)
end.

I have two questions:

  1. Is there a way to achieve the idea of snippet #2, but without such “Next(Next)” workarounds?

  2. Do snippets #1 and #3 differ significantly in terms of performance, or they’re equivalent?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:27:09+00:00Added an answer on May 16, 2026 at 5:27 am
    1. No. Unfortunately anonymous function are just that. Anonymous, unless you give them a name.

    2. Snippet #3 is a little bit more expensive. Given that you do pattern matching on messages in the body, I wouldn’t worry about it. Optimise for readability in this case. The difference is a very small constant factor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Playing with the ssh and public_key application in Erlang, I've discovered a nice feature
I'm playing around with distributed Erlang. It's a great fun, but I want to
I am playing about with Erlang and I am trying to write a simple
I've started playing alittle with erlang, and find it most interesting. My problem is
I am quite new to erlang and yaws. I after playing around with the
I playing around with the sftp example from here: Stackoverflow: twisted conch filetransfer I
I'm playing a bit with erlang and the distributed db Mnesia. One of the
While playing around with regexps in Scala I wrote something like this: scala> val
Hi all, Very new to Erlang, coming from C/C++/Java. Been playing with code and
Playing round with Timers. Context: a winforms with two labels. I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.