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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:21:54+00:00 2026-05-12T12:21:54+00:00

I am developing an interpreter of a simple programming language. There are tree-structured dynamic

  • 0

I am developing an interpreter of a simple programming language.

  1. There are tree-structured dynamic data, where each of the data nodes has an associated (owned) type-object.
  2. There are several kinds of the types – ListType, StructType etc. – and one special – TypeRef. The TypeRef holds a name (a string) which refers to some concrete type.
  3. There is a (nearly) global map (dictionary) – I call it the environment – (std::map<string, Type*>) that translates type-names into type-objects.

The problem is, that there might be several programs loaded and each of them might have different types associated with the same names. This single assumption makes it impossible to have one global (static) environment, which would otherwise be a perfect solution.

Therefore, it seems that I need either (#1) a pointer to an environment in each type-object or (#2) to perform every operation in the context of the environment (e.g. by providing it everywhere as the first argument).

The problems I see:
(#1) Information redundancy, because all connected data nodes would have the same environment. Environments would only be different for strictly separate data.
(#2) A lot of trivial passing of the environment to subroutines, obfuscating the code.

It seems to me that this problem matches a general pattern I would call nearly static data. Any ideas what would be the best solution?

  • 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-12T12:21:54+00:00Added an answer on May 12, 2026 at 12:21 pm

    The idea of using thread-local storage is interesting, but I have finally end up with another solution:

    I use the types in two phases: first they are all created and then they are “compiled”. Compilation requires an environment, but is performed only once. It consist in translating all type-names into proper type-objects. After the compilation the environment is no longer needed.

    Nevertheless, I think it is still more a workaround than a general solution.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No for VB.NET and VS2008. http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=477562 May 12, 2026 at 7:57 pm
  • Editorial Team
    Editorial Team added an answer The [ and ] are special regular expression characters. Escape… May 12, 2026 at 7:57 pm
  • Editorial Team
    Editorial Team added an answer Upload it to PyPI. See the tutorial. May 12, 2026 at 7:57 pm

Related Questions

I'm developing a gae application on a windows machine. to have session handling I
I am developing a GPL-licensed application in Python and need to know if the
I have been tasked to write a device driver for an embedded device which
I'm considering developing for the iPhone and i wanted to know; what codebase does

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.