Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Embedded allocation of a reference type within another reference type #241

Closed
ygc369 opened this issue Mar 10, 2017 · 2 comments
Closed

Comments

@ygc369
Copy link

ygc369 commented Mar 10, 2017

We can call this "inline". An inline class should act as a struct with same fields.
For example:

class A
{
    int a;
}

class B
{
    int b;
    inline A aa; 
}

/* The compiler should translate code above to code below */
class A
{
    int a;
}

class B
{
    int b;
    struct {
        int a;
    } aa; //pseudo-code of C style, just to show my idea. 
}
@orthoxerox
Copy link

  1. What's the point of inlining classes beyond the base class?
  2. Class A must be sealed, or its length at runtime will be indeterminate.

@ygc369 ygc369 closed this as completed Mar 10, 2017
@benaadams
Copy link
Member

struct will inline this way

create class and struct with same data and implement their methods via generic by ref extensions (#186) if they were also available on classes (readonly by ref extensions?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants