[comp.lang.eiffel] Copy semantics for expanded types

jellinghaus-robert@CS.Yale.EDU (Rob Jellinghaus) (05/19/89)

The expanded type facility (defined in a previous posting) seems like
a tremndously useful and powerful extension to the language.  But I
have a question:

In the document as posted, it says that a feature invocation of the form
"a.Copy(b)" will copy the fields of b onto those of a, if both a and b
are of expanded type.  But consider the following:

expanded class X export
	i, set_i
feature
	i: INTEGER;
	set_i(a: like i) is
		do
			i := a
		end
end -- class X

expanded class Y export
	i, set_i, j, set_j
inherit
	X
feature
	j: INTEGER;
	set_j(a: like j) is
		do
			j := a
		end
end -- class Y

Now if we assume a is of type X and b of type Y, and we perform a.Copy(b),
what happens to b's j attribute?  I assume it is not copied?  (The call is
allowed, as b's type is a descendant of a's.)

Now what if Y is redefined as

expanded class Y export
	i, set_i
inherit
	X
		redefine i
feature
	i: REAL
end -- class Y

Now the problem with a.Copy(b) is obvious.  How can one copy a real onto
an integer field?  The call is still valid, but it is not clear to me
what Eiffel will do in this situation.

I eagerly await clarification (and version 2.2 documentation).

On another note:  will it be possible, in version 2.2, to create an object
of some type which is only known at runtime?  For example, if I determine
(using the hazardous class INTERNAL) that some object a has type denoted
by "class_name(a)", how can I define some object b with that same type,
and then (for example) do "b.Copy(a)"?  (This could be useful if one is
attempting to implement a STORABLE class with extensions, or if one simply
wants to be able to duplicate generic objects at runtime.)

Thanks for your assistance.

Rob Jellinghaus                | "Next time you see a lie being spread or a
jellinghaus-robert@CS.Yale.EDU |  bad decision being made out of sheer ignor-
ROBERTJ@{yalecs,yalevm}.BITNET |  ance, pause, and think of hypertext."
{everyone}!decvax!yale!robertj |     -- K. Eric Drexler, _Engines of Creation_