Difference between revisions of "External types"

From Liberty Eiffel Wiki
Jump to navigation Jump to search
(added a few comments)
(No difference)

Revision as of 15:17, 17 July 2007

There are currently two competing mechanisms. Their expressivity is roughly the same (when you have one it is easy to emulate the other).

External attributes

A special marker is used to tell the Eiffel compiler that an attribute should be represented by a user-specified external type. The only meaningful thing that can be done with it is passing it as a parameter to external routines.

Issues:

  • what is the Eiffel type of the attribute?
  • when "passing" the attribute, do we pass a copy or a reference?

External classes

A special marker is used to tell the Eiffel compile that a class should be represented by a user-specified external type. Methods of that class can be implemented by passing Current as a parameter to external routines. Whether Current is passed by copy or by reference could be determined by the reference/expanded status of the external class.

Issues:

  • Forces the programmer to write one class for each external type they want to wrap
  • It wouldn't be possible to inherit from/insert that kind of class
  • such classes should not inherit/insert other classes (ANY?)
  • Implementing some of ANY's operations for external types might be difficult
  • How are native eiffel attributes in such a class handled?
    • Forbid them is not nice, since this may yield to to need to write two classes in special cases, also this would be a special case, which is not nice in general.
    • Allowing, would force a dedicated ordering in the generated struct for the eiffel object

Inline external types

I think we should not call them inline external classes Ramack 16:17, 17 Jul 2007 (CEST) Ok, so there are actually three mechanisms, but this one is hybrid between the previous two (give the external attribute an Eiffel type that doesn't need to be defined anywhere else)

With this approach we can even allow this type for external features, which would solve the pass-by-value/reference question: do a copy or use a pointer to it.

Issues:

  • What is the scope of such a type? Only visible in the class it is written in? Are two external types with the same "name" in different classes the same?