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

add union by default #13318

Open
furesoft opened this issue Sep 12, 2016 · 1 comment
Open

add union by default #13318

furesoft opened this issue Sep 12, 2016 · 1 comment

Comments

@furesoft
Copy link

furesoft commented Sep 12, 2016

pls add a c-like union macro by default.

sample:

union color {
      r : int;
      g: int;
      value: long;
}

will produce a struct with structlayout and struct and fieldoffset

@NN---
Copy link
Member

NN--- commented Sep 13, 2016

Current Nemerle implementation doesn't allow to make namespace level macro.
It means that supporting unions requires compiler change.
It is possible to do it using macro-attribute such as:

[Union]
struct color { r : int; g : int; value : long; }

For example 'Dto' macro converts all fields to be public and creates a constructor using 'Record' macroattribute:

// Default visibility is private, changed to public by macro
[Dto] class Task { Name : string; IsDone : bool }  

def t = Task("A", true);

https://github.com/NemerleWeb/NemerleWeb/blob/master/NemerleWeb.Macros/Data/Dto.n

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

No branches or pull requests

2 participants