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 a proposal for "data objects" #316

Merged
merged 9 commits into from
Sep 12, 2022

Conversation

strangepleasures
Copy link
Contributor

No description provided.

@fvasco
Copy link

fvasco commented Aug 5, 2022

The @hash part is meaningless even for non-ADT objects, because object is a singleton

On JVM, a data object is a singleton in each ClassLoader, so multiple objects with the same FQN (and maybe the same code) can coexist in the same process.
The hash part is useful to detect different instances of the "same singleton".
This kind of issue occurs when multiple ClassLoaders are used, ie OSGi.
I note that only for completeness, but I don't think that the Kotlin language should address this issue.

copy makes no sense because it’s a singleton. Or should it be generated and always return this?

the copy method should never return this

@elizarov elizarov mentioned this pull request Aug 8, 2022
proposals/data-objects.md Show resolved Hide resolved
proposals/data-objects.md Show resolved Hide resolved
proposals/data-objects.md Outdated Show resolved Hide resolved
Co-authored-by: Niklas Baudy <[email protected]>
proposals/data-objects.md Outdated Show resolved Hide resolved
proposals/data-objects.md Show resolved Hide resolved
@strangepleasures
Copy link
Contributor Author

The hash part is useful to detect different instances of the "same singleton".

Wouldn't it be more natural to use the === operator for that?

@strangepleasures strangepleasures changed the base branch from master to data-objects September 12, 2022 08:19
@strangepleasures strangepleasures merged commit b5fb26b into Kotlin:data-objects Sep 12, 2022
@Zhuinden
Copy link

Zhuinden commented Jan 5, 2023

    kotlinOptions {
        jvmTarget = '1.8'
        languageVersion = '1.9' // data objects
    }

kotlin.sourceSets.all {
    it.languageSettings.enableLanguageFeature("DataObjects")
}

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

Successfully merging this pull request may close these issues.

6 participants