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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:16:03+00:00 2026-05-11T06:16:03+00:00

I heard that some languages go from interpreted to compiled by unrolling the interpreter

  • 0

I heard that some languages go from interpreted to compiled by ‘unrolling the interpreter loop’.

Let’s say I have the following pseudo-c-code interpreter for an ast tree.

int interpret(node) {     switch(node) {         case PLUS:              return interpret(child(0))+interpret(child(1));         case MINUS:              return interpret(child(0))-interpret(child(1));            } } 

How do I unroll this loop to create a compiled program?

I see you all downvoting this like I don’t know what I am talking about, but here is a quote from Wikipedia that states exactly what I am describing.

‘Factor was originally only interpreted, but is now fully compiled (the non-optimizing compiler basically unrolls the interpreter loop’

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T06:16:03+00:00Added an answer on May 11, 2026 at 6:16 am

    ‘Unrolling a loop’ normally means replacing a repetition with a sequence of actions. The loop:

    for (int i = 0; i < 4; ++i) {     a[i] = b[i] + c[i]; } 

    would unroll into the equivalent:

    a[0] = b[0] + c[0]; a[1] = b[1] + c[1]; a[2] = b[2] + c[2]; a[3] = b[3] + c[3]; 

    It appears to me that whoever was being quoted by Wikipedia was using the phrase in a somewhat metaphorical sense. So, in that sense…

    Your sample would normally be invoked inside a interpreter that is walking a tree of AST nodes, which might look something like this:

     ASSIGN     |  +--+---+  |      | REF   MINUS  |      |  x   +--+---+      |      |     VAR    PLUS      |      |      a   +--+--+          |     |         VAR  CONST          |     |          b     3 

    and the interpret function would have additional options:

    int interpret(node) {     switch(node) {         case PLUS:              return interpret(child(0))+interpret(child(1));         case MINUS:              return interpret(child(0))-interpret(child(1));                case ASSIGN:              return set(child(0), interpret(child(1));         case VAR:              return fetch(child(0));         case CONST:              return value(child(0));         ...     } } 

    If you walk the AST with that interpet function (actually performing the operations), you’re interpreting. But if the function records the actions to be performed, rather than executing them, you’re compiling. In pseudocode (actually, pseudocode twice, as I’m assuming a hypothetical stack machine as the compilation target):

    string compile(node) {     switch(node) {         case PLUS:              return(compile(child(0))) + compile(child(1)) + ADD);         case MINUS:              return(compile(child(0))) + compile(child(1)) + SUB);         case ASSIGN:              return(PUSHA(child(0))) + compile(child(1)) + STORE);         case REF:              return(PUSHA(child(0)));         case VAR:              return(PUSHA(child(0)) + FETCH);         case CONST:              return(PUSHLIT + value(child(0)));         ...     } } 

    Invoking compile on that AST (ignoring any pseudocode typos 😉 would spit out something like:

    PUSHA x PUSHA a FETCH PUSHA b FETCH PUSHLIT 3 ADD  SUB STORE 

    FWIW, I’d tend to think of that as unrolling the AST, rather than unrolling the interpreter, but won’t criticize somebody else’s metaphor without reading it in context.

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

Sidebar

Ask A Question

Stats

  • Questions 107k
  • Answers 107k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The error is in your formfield_for_dbfield, it should read: def… May 11, 2026 at 9:00 pm
  • Editorial Team
    Editorial Team added an answer A quick test shows that you could do this: <?xml… May 11, 2026 at 9:00 pm
  • Editorial Team
    Editorial Team added an answer This is possible with NHibernate; what you're looking for is… May 11, 2026 at 9:00 pm

Related Questions

I believe several of us have already worked on a project where not only
There is a similar question going around, but it just got the same old
This morning, I was reading Steve Yegge's: When Polymorphism Fails , when I came
I have what I believe is a killer idea for an application. By definition,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.