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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:15:50+00:00 2026-05-17T17:15:50+00:00

Inside of this first step towards a bootstrapped scheme interpreter I find the following

  • 0

Inside of this first step towards a bootstrapped scheme interpreter I find the following set of typedef, struct, union, and enum definitions:

typedef enum {FIXNUM} object_type;

typedef struct object {
    object_type type;
    union {
        struct {
            long value;
        } fixnum;
    } data;
} object;

In particular, I’m not sure I understand the point of the struct inside the union (struct { long value; } fixnum;) — a struct with only one field, to hold a single long? Very strange.

But I’m not really sure I understand the larger point, too. I think what’s going on with the enum definition is that he’s setting up a number of possible type values for lexical entities, and that object is a way of holding these, but perhaps somebody with more practice in C than I have can offer a more detailed explanation.

Thanks!

  • 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-17T17:15:50+00:00Added an answer on May 17, 2026 at 5:15 pm

    You’re right, the struct-inside-a-union-inside-a-struct is rather useless in this code, but the author is using it as a stepping stone for the later code. Since he knows what the future code is going to look like, he can prepare the earlier code to make the changes as minimal as possible.

    In the second part of the tutorial, the definition expands to this:

    typedef enum {BOOLEAN, FIXNUM} object_type;
    
    typedef struct object {
        object_type type;
        union {
            struct {
                char value;
            } boolean;
            struct {
                long value;
            } fixnum;
        } data;
    } object;
    

    Now an object can hold two different values (a boolean or an integer), so the union now serves a purpose. The inner structures are still redundant, though. Notice how none of the code dealing with fixnums has to change.

    I suspect that the inner structures are there just for parallelism. In v0.6, the author adds the pair type, which consists of a structure of two pointers.

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

Sidebar

Related Questions

I have ASP.Net code similar to the following (this is inside a FIELDSET): <ol>
i need some code for the next step..this my first step: <script> $(#mod).change(function() {
I am trying to play video inside a UIView , so my first step
I have a Panel and I am adding controls inside this panel. But there
I've got a function inside of a class that returns a string. Inside this
I have a ListBox that has a style defined for ListBoxItems. Inside this style,
Using asp.net MVC I'd like to do this inside a view: <%= Html.TextBox(textbox1, null,
When I specify a height in the style for any element inside of this,
I have this code inside a class that is used by an application and
Inside VS2005, our whole programming staff gets this error message sporadically and it is

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.