[e-lang] Type system edge cases: underenthusiastic deflection or individual bugs?

Kevin Reid kpreid at attglobal.net
Sat Dec 3 19:58:21 EST 2005

? 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.

In each example, the first part is the nonworking code and the second  
is a workaround.


   ? for i in 0..10 { println(map.fetch(i, __continue)) }
   # problem: <ClassCastException: Ejector doesn't coerce to a Thunk>

   ? for i in 0..10 { println(map.fetch(i, thunk { __continue() })) }
   # stdout: 10


   ? int.coerce("1", throw)
   # problem: <ClassCastException: Thrower doesn't coerce to an  

   ? int.coerce("1", def _ extends throw {})
   # problem: <ClassCastException: String doesn't coerce to an int>

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.

Kevin Reid                            <http://homepage.mac.com/kpreid/>

More information about the e-lang mailing list