slinc
slinc copied to clipboard
Struct field alias
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?
@donderom Have you tried
case class foo(`type`: Int, value: Int) derives Struct
?
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.
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.
Ok, so it's only function names that matter, isn't it?
Yes. Function names are used for symbol lookup. There are ways to do platform specific overrides of symbol lookup though.