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 7974343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:20:29+00:00 2026-06-04T08:20:29+00:00

I have been trying to implement a factorial function using the actor model with

  • 0

I have been trying to implement a factorial function using the actor model with the d language.
My objective is to use to create actor to calculate each part alone e spawn a new actor to make the next.
I am just a beginner with D, so I’m just learning how to use the language. My objective is to expand the factorial implementation to much more. This is just a test.

Here is my problem:
I’m trying to implement the factorial using recursion; the fact function will create a new fact thread for next number in line, unless it has reached the base condition.

My code:

void fact(Tid tid)
{

        int fact = 1;
        receive
        (
        (int i)
        {
            if(i == 0)
            {
                writeln("End of recursion");
            }
            else
            {
                fact *= i;
                send(thisTid, i-1);
            }
        }
    );
    send(tid, fact);
}

void main()
{

        auto tid = spawn(&fact, thisTid);
        int x = 3;
        send(tid, x);
        auto fact = receiveOnly!(int);
        writeln(fact);
}

I don’t even know if that’s possible, in any case it does not work. If I try to add a spwn in fact function it returns the following error:

src/main.d(62): Error: template std.concurrency.spawn does not match any function template declaration
/usr/include/x86_64-linux-gnu/dmd/phobos/std/concurrency.d(399): Error: template std.concurrency.spawn(T...) cannot deduce template function from argument types !()(int*,Tid)
src/main.d(63): Error: template std.concurrency.send does not match any function template declaration
/usr/include/x86_64-linux-gnu/dmd/phobos/std/concurrency.d(463): Error: template std.concurrency.send(T...) cannot deduce template function from argument types !()(_error_,int)

So, is it possible to do what I am trying to do? How?
If not, is there any plans to make some thing like that possible?

Please, help.

  • 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-06-04T08:20:31+00:00Added an answer on June 4, 2026 at 8:20 am

    I could be way off base here, but from that error message it looks to me like dmd is not using the fact that you think it is using, in your call to spawn. You have several integers named fact, and although in this (obviously cut down, since it’s not 400 lines) example none of them would conflict, in the full code my guess is one of them does (because &fact would be an int* if fact was an int).

    Try renaming the function to factorial or some such, and changing the spawn call where appropriate. Make sure not to change the integers.

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

Sidebar

Related Questions

I use Devise (1.4.8) for my User model and have been trying to implement
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
Hello guys, I have been trying to implement the DSUM function but failed to
I have been trying to implement hash-tables using uthash.h, following the (excellent) documentation I
I have been trying to implement the delete BST function but I don't know
I have been trying to implement proximity search using Lucene 3.6 . I went
I have been trying to implement pinch zoom/in-out for PhotoView (a UIImageView instance) using
I have this hashCode function that I have been trying to implement with Eclipse
I have been trying to implement the Authorize.NEt SIM Method using the information given
I've been trying to implement unit testing and currently have some code that does

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.