Skip to content

Conversation

@cseiler
Copy link

@cseiler cseiler commented Apr 29, 2016

Hello Mario,
great work! However I have an issue with the VisitorLambda example:
your main construct is to have a Map of Function<Object, A> and later cast functions of type Function<B,A> to Function<Object, A> (happens in Acceptor.then, it is just obscured by the fact that you use the raw type LambdaVisitor thus disabling the type system).
My Problem: this cast is unsound! If your Map<Class<?>, Function<Object, A>> ever escapes its scope (which it doesn't do, thus the example works) you are headed for ClassCastExceptions.
You also get a NPE if there is no Visitor registered for a specific class.

I came up with a different Implementation. You will see that there are still "unchecked" warnings, however the cast is checked at run time (which is arguably preferable).
Thanks! Christian

@jbgi
Copy link

jbgi commented May 15, 2016

this is better because partiality is expressed in the types, but still, the implementation would not work for generic classes and we want totality to be equivalent to the gof visitor.

See #2 for a proper fix.

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.

2 participants