10 Dec 2005 03:58
Re: Type system edge cases: underenthusiastic deflection or individual bugs?
> ? def map := [5 => 10]; null
>
> Both of the following seem to me to be bugs of a similar form:
> suitable arguments are rejected because the argument and the
> recipient are both ordinary Java objects which must implement each
> interface, whereas E objects get the Deflection mechanism.
> [...]
> ? for i in 0..10 { println(map.fetch(i, __continue)) }
> # problem: <ClassCastException: Ejector doesn't coerce to a Thunk>
> [...]
> ? int.coerce("1", throw)
> # problem: <ClassCastException: Thrower doesn't coerce to an
> OneArgFunc>
>
>
> I see two possible fixes:
>
> 1. Have Thrower implement OneArgFunc and Ejector implement Thunk.
> This would fix these particular cases but not the general problem.
>
> 2. Any object passed to a Java method is subject to deflection,
> whether or not it is an E object. This would eliminate all problems
> like this but hide "real" interface mismatches.
Your diagnosis of the bug is correct. #2 is the right fix. All Java
interfaces except Marker interfaces (explained below) are considered
to only be part of Java's static type system, which E should ignore.
Those Java interfaces which directly implement org.erights.e.elib.serial.Marker
http://www.erights.org/javadoc/org/erights/e/elib/serial/Marker.html
are considered by E to act like E auditors & guards. Only for these,
deflection is not automatic, and interface mismatches should be
caught.
--
Text by me above is hereby placed in the public domain
Cheers,
--MarkM
RSS Feed