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

Const reference-type function/lambda parameters. #69

Closed
base58ed opened this issue Apr 19, 2017 · 4 comments
Closed

Const reference-type function/lambda parameters. #69

base58ed opened this issue Apr 19, 2017 · 4 comments

Comments

@base58ed
Copy link

A Function/lambda should be able to take a const parameter which is read-only. This will enable certain optimizations and will remove the need to copy references.

This feature will also enable a lot of gains when value-types are actually implemented in Kotlin but, they're not dependent on the availability of value-types in the language. But it's arguable if this feature depends on the availability of const val reference types (heap object that cannot be changed).

Keyword: Kotlin's const keyword can be used so there's no need to add a new one.

The strawman syntax should make it look like the following:

fun foo(const bar: Bar)...

@yole
Copy link
Contributor

yole commented Apr 19, 2017

KEEP issues are intended to be used for discussing specific KEEP proposals. If you want to make a suggestion for adding a feature to Kotlin and aren't ready to write a complete design proposal, please file a YouTrack issue.

@yole yole closed this as completed Apr 19, 2017
@ilya-g
Copy link
Member

ilya-g commented Apr 19, 2017

What does this "read-only" means? What particular restrictions it imposes on bar parameter?

@base58ed
Copy link
Author

bar param should be immutable/read-only.

@yole
Copy link
Contributor

yole commented Apr 19, 2017

Let's not discuss this here, please.

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