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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:07:34+00:00 2026-05-13T14:07:34+00:00

Assuming the interpreter for the language (Can be anything from PHP to Ruby) is

  • 0

Assuming the interpreter for the language (Can be anything from PHP to Ruby) is written in C.
How are variables (or more complex data structures not only containg name and value), which are defined by the script that is currently being executed, stored and read out?

I, with my rather poor knowledge of C, would end up with the conclusion that this can only be done with an array.

// Variable type definition would go here
var* variables;

The var type would contain two strings name and value.

Okay. So a script defines e.g.: 30 variables. Now, if one of the variables has to be read out, the function getVar (or something similar) would have to walk through all 30 variables and compare their names with the name of the requested variable. Imagine that with a loop that requests

  • Am I getting it totally wrong? If yes, how do (modern?) scripting languages handle variables? How are they stored and read out?

  • In languages where variables are clearly defined by the syntax (PHP: $myVar), the interpreter could replace all variables by numerical values during the parsing process. (Am I right with that?)
    Is this the case?

  • 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-13T14:07:34+00:00Added an answer on May 13, 2026 at 2:07 pm

    Hashtables, scope linked lists, references … there is alot to it.

    What you are asking is half-abstract, and the implementation is variable.

    Depending on the implementation:

    1. Identifiers may be compiled into memory addresses, or relative memory addresses, or nameless locations referenced by bytecode.
    2. Identifiers may be looked-up dynamically in the scope at runtime

    In a basic scripting language, variable names when encoutered would be put into a scope structure such as a linked-list containing a hashtable implementation for looking up identifiers in that scope.

    When a variable is referenced, the runtime code looks it up in the hashtable and obtains some value (a memory address of a struct for example) which relates to that value. Structs can be used to implement scalar variables:

    enum stype = { INT, STRING, FLOAT, BOOL };
    struct scalar {
        enum stype type;
        generic_blob_t *heap_blob;
    };
    

    Or some variation of my poor example source.

    Some good books are “Modern Compiler Implementation in C” and the Dragon Book. Reading up on this topic is a good idea; I would recommend it to any programmer.

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

Sidebar

Related Questions

Assuming a program is written in 2 different languages: In a language interpreted from
from the interpreter i can issue >>> from MySQLdb just fine. so, I'm assuming
Assuming that parsing the equation would not be a problem, how can I make
Assuming I can telnet to gitorious.org port 9418 (default for git), but not on
Assuming i have a post model with created_at, title, and id. How can i
Assuming that I have to write to a binary file. I can use the
In C99, equality == does not seem ever to be undefined. It can produce
Assuming you can't use LINQ for whatever reason, is it a better practice to
Assuming you have two 32-bit DWORD x and y, how can you detect if
Assuming I have a numerical string: var foo = 0; Assume I want 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.