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

Struct field alias #215

Open
donderom opened this issue Aug 2, 2023 · 5 comments
Open

Struct field alias #215

donderom opened this issue Aug 2, 2023 · 5 comments

Comments

@donderom
Copy link

donderom commented Aug 2, 2023

Is there any way to map the following definition

case class foo(type: Int, value: Int) derives Struct

where type is a keyword in Scala?

@azolotko
Copy link

azolotko commented Aug 2, 2023

@donderom Have you tried

case class foo(`type`: Int, value: Int) derives Struct

?

@donderom
Copy link
Author

donderom commented Aug 2, 2023

It might work but I can only pass such a structure, and it looks like, in this case, the field name doesn't even matter.

@markehammons
Copy link
Collaborator

markehammons commented Aug 3, 2023

Field names don't matter for struct defiinitions, only the order of members.

re: `type`, this works, but using backtick names in Scala is always a bit clumsy. If you want to name a struct member this way, go ahead, but I'd suggest using a name that will not require wrapping it in backticks.

@donderom
Copy link
Author

donderom commented Aug 3, 2023

Ok, so it's only function names that matter, isn't it?

@markehammons
Copy link
Collaborator

Yes. Function names are used for symbol lookup. There are ways to do platform specific overrides of symbol lookup though.

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

3 participants