Few newbie syntax questions 
Author Message
 Few newbie syntax questions

I've just started to learn eiffel so excuse me if any of my questions
are goofy. Until now I was mainly C++/java guy.

1) Is there anything similar to namespaces/packages in eiffel ? I can
just prefix class names with package abbreviation (which seems to be
case in few eiffel libraries I've seen), but it is not scalable and with
longer prefixes can be tiring to type in.

2) Is there any way to force variable to be reference type if class is
defined as expanded ? (Opposite of expanded keyword in variable
definition).

3) Let's suppose that there is class A, class B inheriting from A, class
X, class Y inheriting from X. Class Y has method onlyInY. Class A has
method m(x:X). Class B redefines method m using covariance to m(y:Y) and
calls onlyInY inside this method.
Now somewhere in program we have variable a:A; , which is in fact
instance of B (real type was lost somewhere due to parameter passing,
storing in array or anything). Now I call a.m(x). B.m() should be used I
think - it is redefined after all. But B.m() relies on features that
appear only in Y. Something is broken. How eiffel resolves that ?

Maybe B.m(y:Y) do not really redefine A.m(x:X) only adds another method
which will be choosen at runtime depending on parameter class ? Or
methods are alwyas called depending on static context (it would be very
not-OO) ? I'm lost here.

Artur



Fri, 05 Apr 2002 03:00:00 GMT  
 Few newbie syntax questions

On Mon, 18 Oct 1999 10:55:36 +0200,

Quote:

>1) Is there anything similar to namespaces/packages in eiffel ? I can
>just prefix class names with package abbreviation (which seems to be
>case in few eiffel libraries I've seen), but it is not scalable and with
>longer prefixes can be tiring to type in.

No. Eiffel intentionally uses the class as only organisatorical unit.
Classes can be grouped into clusters though. In case of name clashes,
most compilers offer a mechanism to rename classes at compile time. In
case you are using ISE Eiffel, this can be done in the Ace files using
the "adapt/rename" meachnism.

Quote:
>2) Is there any way to force variable to be reference type if class is
>defined as expanded ? (Opposite of expanded keyword in variable
>definition).

Non-expanded typed are always reference types.

Quote:
>3) Let's suppose that there is class A, class B inheriting from A, class
>X, class Y inheriting from X. Class Y has method onlyInY. Class A has
>method m(x:X). Class B redefines method m using covariance to m(y:Y) and
>calls onlyInY inside this method.
>Now somewhere in program we have variable a:A; , which is in fact
>instance of B (real type was lost somewhere due to parameter passing,
>storing in array or anything). Now I call a.m(x). B.m() should be used I
>think - it is redefined after all. But B.m() relies on features that
>appear only in Y. Something is broken. How eiffel resolves that ?

If I understand your description right, we have a so-called polymorphic
catcall. There have been some efforts to detect such calls at compile
time, but no compiler-enforcable rules have been found yet. In the
chapter about typing in OOSC2, you find more information on this issue.

Best regards,
Patrick

--
----------------------------------------
Patrick Schoenbach
Interactive Software Engineering, Inc.

URL: http://www.eiffel.com



Fri, 05 Apr 2002 03:00:00 GMT  
 Few newbie syntax questions

Thanks for other answer, but this one still bugs me.

Quote:
> >2) Is there any way to force variable to be reference type if class is
> >defined as expanded ? (Opposite of expanded keyword in variable
> >definition).

> Non-expanded typed are always reference types.

Yes, but I'm talking about class itself being declared as expanded, not
local variable. Is it possible to force local variable to be reference
to such class, or another CLASS_REF has to be created (as it is done
with INTEGER and friends).

BTW, is expanded status inherited ? What if one superclass is expanded
and second isn't ?

Artur



Sat, 06 Apr 2002 03:00:00 GMT  
 Few newbie syntax questions
On Tue, 19 Oct 1999 17:08:29 +0200,

Quote:


>Thanks for other answer, but this one still bugs me.

[...]

Quote:
>Yes, but I'm talking about class itself being declared as expanded, not
>local variable. Is it possible to force local variable to be reference
>to such class, or another CLASS_REF has to be created (as it is done
>with INTEGER and friends).

No, this is not possible. If you do not want all instances of class X to
be an expanded type, you will have to use declarations like

        foo: expanded X

and not declare class X as expanded.

Quote:
>BTW, is expanded status inherited ? What if one superclass is expanded
>and second isn't ?

No. The expanded status is not inherited.

Best regards,
Patrick

--
----------------------------------------
Patrick Schoenbach
Interactive Software Engineering, Inc.

URL: http://www.eiffel.com



Sat, 06 Apr 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. A few syntax questions

2. A few more newbie questions..

3. A few newbie questions...

4. a few newbie questions...

5. newbie....a few questions

6. Please asm newbie with few questions

7. Newbie here, a few questions

8. A few newbie questions

9. A few more newbie questions

10. A few newbie questions

11. Newbie has a few questions

12. newbie syntax tree question

 

 
Powered by phpBB® Forum Software