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

  • SEARCH
  • Home
  • 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 5951753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:34:57+00:00 2026-05-22T17:34:57+00:00

Mainly I want to know if I can send a function in a message

  • 0

Mainly I want to know if I can send a function in a message in a distributed Erlang setup.

On Machine 1:

F1 = Fun()-> hey end,

gen_server:call(on_other_machine,F1)

On Machine 2:

handler_call(Function,From,State) ->
{reply,Function(),State)

Does it make sense?

  • 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-22T17:34:58+00:00Added an answer on May 22, 2026 at 5:34 pm

    Here‘s an interesting article about "passing fun’s to other Erlang nodes". To resume it briefly:

    […] As you might know, Erlang distribution
    works by sending the binary encoding
    of terms; and so sending a fun is also
    essentially done by encoding it using
    erlang:term_to_binary/1; passing the
    resulting binary to another node, and
    then decoding it again using
    erlang:binary_to_term/1.[…]
    This is pretty obvious
    for most data types; but how does it
    work for function objects?

    When you encode a fun, what is encoded
    is just a reference to the function,
    not the function implementation.
    […]

    […]the definition of the function is not passed along; just exactly enough information to recreate the fun at an other node if the module is there.

    […] If the module containing the fun has not yet been loaded, and the target node is running in interactive mode; then the module is attempted loaded using the regular module loading mechanism (contained in the module error_handler); and then it tries to see if a fun with the given id is available in said module. However, this only happens lazily when you try to apply the function.

    […] If you never attempt to apply the function, then nothing bad happens. The fun can be passed to another node (which has the module/fun in question) and then everybody is happy.
    Maybe the target node has a module loaded of said name, but perhaps in a different version; which would then be very likely to have a different MD5 checksum, then you get the error badfun if you try to apply it.

    I would suggest you to read the whole article, cause it’s extremely interesting.

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

Sidebar

Related Questions

I want to query a number of different databases mainly Oracle and Informix. Can
I want to set up a personal workspace on my home machine. I mainly
As a .net developer mainly c#, I want to know what would be the
I want to know how can I speed up RSA 7.5( which is an
I know you can assign a function's return value to a variable and use
I want to buy a brand new notebook for out-of-the-office work. I mainly develop
I have till now mainly concentrated on web programming thus far and now want
I'm creating a mainly GUI Cocoa app, but I want to create a command
I have an application that will mainly operate in the background. I want certain
I want to make a website, but all I know is basic HTML and

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.