-
Notifications
You must be signed in to change notification settings - Fork 186
Move IntFunction to scala and don't allow throwing #2200
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
Move IntFunction to scala and don't allow throwing #2200
Conversation
| @SerialVersionUID(1L) | ||
| @FunctionalInterface | ||
| trait IntFunction[T] extends Serializable { | ||
| def apply(value: Int): T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? what's the poin of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a place where we define all of our functional interfaces, its in actor/src/main/scala/org/apache/pekko/japi/function/Function.scala. In your PR you created another implementation in Java which means we have functional interfaces defined in both Scala and Java for no good reason.
Lets keep all of the functional interfaces defined where they already are in actor/src/main/scala/org/apache/pekko/japi/function/Function.scala so its consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is in #2185, ok?
Even Akka-sdk is now Java-first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are Java APIs, so shouldn't they be written in Java? Just because they were done in the past doesn't mean they should be done now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is in #2185, ok? Even Akka-sdk is now Java-first.
If you are going to make a decision like move everything to Java (or to Scala) for that matter, you need to discuss it with community first. You can't just sneak it into PR's because you think its a good idea.
Please discuss this with community first, also whether to throw an exception or not is a separate matter from whether functions can throw exceptions.
|
Check #2185 first And then why can't the Then tell why an |
Its not that Int functions can never throw, its that throwing an exception as a supplier function in a pekko stream doesn't make any sense. |
|
These are common functions. Thanks. Do you actually write Java on a daily basis? How much Java do you write on a daily basis? |
|
And you should never define such a method in Scala , there is already one, In java's stdlib. |
Then we should use that one, I will change the PR to do so.
I write Java/Kotlin frequently, and there is a reason why the Java functional interfaces do not allow exception throwing (albeit they should have also provided alternatives that do allow throwing) |
He-Pin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a Java's IntFunction in stdlib
0bac5cd to
43a2362
Compare
Fixed and pushed |
43a2362 to
4a05322
Compare
4a05322 to
f9a8c96
Compare
pjfanning
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm - I'm ok with this if @He-Pin is happy with this change
|
actually we should just do a revert instead of this. |
He-Pin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
Although this is not the result I want, I can accept it, reduce the change set help anyway. |
In #2198 we defined an
IntFunctionbut there were some issues with the definitionIntFunctionto allow throwing, this is used in retry functions for thedelayFunctionand supplying a function that can throw makes no sense and can lead to undefined behaviour