Path: utzoo!attcan!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!jos From: jos@cs.vu.nl (Jos Warmer) Newsgroups: comp.lang.eiffel Subject: Re: Eiffel type system <133@eiffel.UUCP> Keywords: Eiffel type system, double precision, C interface, composite objects, copy semantics Message-ID: <2717@vlot.cs.vu.nl> Date: 8 Jun 89 13:55:58 GMT References: <132@eiffel.UUCP> <133@eiffel.UUCP> <154@eiffel.UUCP> Reply-To: jos@cs.vu.nl (Jos Warmer) Organization: VU Informatica, Amsterdam Lines: 63 In article <154@eiffel.UUCP> bertrand@eiffel.UUCP (Bertrand Meyer) writes: > > As an aside, note that release 2.2 provides > further support for more powerful interaction > between Eiffel and other languages. In > particular, a simple syntactical extension makes > it possible to pass the address of an Eiffel > routine to an external routine. The notation is > @f, where f is a routine of the enclosing class; > such an expression is only valid as actual > argument to an external routine. > I guess/hope that this can be used as an efficient interface for calling Eiffel routines from C. But I don't understand the meaning of this. An Eiffel routine has meaning only when it is called on an Eiffel object as in 'object.routine'. An Eiffel routine can never be called as a standalone function as C routines can. Besides, because of the dynamic binding in Eiffel, you can never be sure what implementation of a routine is called. Even when the names of the routines are equal and they are called on an object of the same entity type, they can be different implementations. So, how can this address be used by the external routines ? They (or hopefully the Eiffel runtime system) must ensure that the routine will only be called on an Eiffel object of the correct (dynamic) type. If the routine address is used by the external routine to call it directly, this check cannot be performed by the Eiffel runtime system. This means that the external routines can easily corrupt internal Eiffel structures. If the routine address cannot be used by the external routine to call it directly, what use is it? ____ABOUT_THE_EFFICIENCY_ISSUE____ Some time ago, I mentioned to ISE that the way of calling Eiffel routines from C was very inefficient. In version 2.1b this is accomplished by the C routine `eif_rout', which is declared as follows: DATUM eif_rout (Objptr, r_name, arg1, ... OBJPTR Objptr; char *r_name; `Objptr' is a pointer to the eiffel-object and `r_name' is the name of the routine that must be performed on `Objptr'. In the implementation of `eif_rout', the array containing the names of all applyable routines for `Objptr' is searched for `r_name'. If `r_name' is found, the corresponding routine is called. This means that a number of string-comparisons will have to take place for each function call. I am not a fan for efficiency at each cost, but when this interface must be used heavily, this is prohibitive. Jos Warmer jos@cs.vu.nl ...uunet!mcvax!cs.vu.nl!jos -- Jos Warmer jos@cs.vu.nl ...uunet!mcvax!cs.vu.nl!jos