-
Notifications
You must be signed in to change notification settings - Fork 252
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
Deprecate then remove all unsafe API #192
Comments
I do find myself using these regularly because Java lacks a pattern matching mechanism. I think it could be done using the visitor pattern, but List doesn't currently implement the visitor pattern. So I do something like Removing or renaming these methods now would create some headaches for me, and probably others, so some kind of deprecation procedure would be recommended. I'm not sure its worth the pain right now. |
|
👍 Move unsafe functions out, so that if they are not imported, it is more clear that they are not used. |
the road block to completely removing those unsafe functions is the lack of TCO. Eg. Implementing listEqual without |
To clarify what I meant by "some sort of mutable function", here is how one could implement public final Unit foreach(final F<A, Unit> f) {
final class ForEachCons implements F2<A, List<A>, Boolean> {
List<A> as = List.this;
@Override
public Boolean f(A head, List<A> tail) {
as = tail;
f.f(head);
return true;
}
}
ForEachCons forEachCons = new ForEachCons();
while (forEachCons.as.uncons(forEachCons, false)) {}
return unit();
} To be compared with current implementation: public final Unit foreach(final F<A, Unit> f) {
for (List<A> xs = this; xs.isNotEmpty(); xs = xs.tail()) {
f.f(xs.head());
}
return unit();
} I am personally ok-ish with the former implementation but I am guessing not everyone... @functionaljava WDYT? |
I think it's good to leave the door open to optimization. Maybe just rename On Sat, Oct 22, 2016, 4:02 AM JB Giraudeau notifications@github.com wrote:
|
I think it would also be good to give |
+1 from me for this issue. It is hard for me to sell the library to my coworkers as a safe alternative to the Java standard library if it provides unsafe operations. |
or at least move unsafe API under a
Unsafe
nested class (or better: a separate "unsafe" artefact) with all methods prefixed withunsafe
.eg.
List.tail()
,List.head()
should not be part of List public API.maybe for functionaljava 5?
@functionaljava WDYT?
The text was updated successfully, but these errors were encountered: