comp.lang.ada
 help / color / mirror / Atom feed
From: mbk@jt3ws1.etd.ornl.gov (Kennel)
Subject: Re: Current state of the language
Date: 28 Mar 1995 18:36:52 GMT
Date: 1995-03-28T18:36:52+00:00	[thread overview]
Message-ID: <3l9l04$l9m@stc06.ctd.ornl.gov> (raw)
In-Reply-To: 3l6jil$12kj@watnews1.watson.ibm.com

Norman H. Cohen (ncohen@watson.ibm.com) wrote:

> In Eiffel, the need to use classes for packaging leads to a nonsensical
> way of importing math routines.  You inherit from a class whose instances
> have no data, but do have methods like sine and square_root.

So what? 

It's no more nonsensical than "#include <math.h>".

And Sather lets you MATH::cos() anyway.

>  Sometimes,
> an abstraction consists of two or more closely related types, perhaps
> defined recursively in terms of each other, and it is often convenient to
> package them in the same module.  Then a language which requires a
> separate module for each class gets in the way.

> (Example: An abstraction
> for family trees consists of a type for persons and a type for pairings
> (traditionally, marriages).  Each person is a participant in zero or more
> pairings and each pairing has zero or more persons who are offspring of
> the pairing.  Many of the operations for this abstraction, e.g.
> iterating over all of a person's marriages or determining the pairing of
> which a person is an offspring, involve operands of both types, and
> artificially assigning each operation to one type or the other would be
> pointless.)

It doesn't seem so bad to me.   In fact it divides up reasonably
naturally in my opinion.

Certainly you need the ability for two classes to know about the existence
of each other but that is taken for granted.

----------------------------------------------
-- Sather
----------------------------------------------
class PERSON is

	private attr pairings: LIST{PAIR}; -- may be null.
	private attr genesis: PAIR;  -- who made me.

	marriages!:PAIR is loop yield(pairings.elts!) end;

	children!:PERSON is
	-- all direct level children by all marriages.
	loop m ::= marriages!; -- for each marriage
	     loop yield(m.children!); end; -- yield all children from it.
	end;

	ancestors!: PERSON is
	-- *all* ancestors.  This routine may have infinite loops if
        -- your family comes from Arkansas.  Need a special routine for that.
	  loop
	    p ::= children!;
	    yield(p);	 -- yield direct children
	    loop yield(p.ancestors!); end; 
		 -- yield ancestors of your children.
	  end;
	end;

	siblings!: PERSON is
	-- blood brothers and sisters
	  loop yield(genesis.children!) end;
	end;

	siblings_and_half_siblings!: PERSON is
	  father ::= genesis.t1; -- first of tuple
  	  mother ::= genesis.t2; -- second of tuple
	  loop yield(father.children!); end; -- on father's side
	  loop yield(mother.children!); end; -- mother's side
	end;

end; -- class PERSON;

class PAIR is

	attr participants:TUP{PERSON,PERSON}; -- father and mother
	private attr offspring: LIST{PERSON}; -- from this marriage.
	
	children!:PERSON is
	-- children from *this* pairing
	  loop yield(offspring.elts!); end;
	end;

end;	

-----

Children of a person are different than children of a pairing.

Now what is the problem?

Modules seem necessary at a macro level (hundreds of classes), but in the 
relationships between individual classes I feel that empirical
evidence shows it to be quite feasible.  The sort of module automatically
provided by Sather and Eiffel classes is very freuqently the one you want.


> --
> Norman H. Cohen    ncohen@watson.ibm.com



  reply	other threads:[~1995-03-28 18:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3j5p3p$nc1@netnews.upenn.edu>
     [not found] ` <3k0u6r$e05@miranda.gmrc.gecm.com>
     [not found]   ` <MATT.95Mar15122202@physics2.berkeley.edu>
     [not found]     ` <3k9s2j$iq8@moon.src.honeywell.com>
     [not found]       ` <1995Mar17.092345@lglsun.epfl.ch>
1995-03-17 15:02         ` Current state of the language Kennel
1995-03-20 13:38           ` Robb Nebbe
1995-03-28 16:57             ` "types" vs "classes" (was: Re: Current state of the language) Fergus Henderson
1995-03-23 15:09 ` Current state of the language Whitney de Vries
1995-03-24 20:58   ` Tucker Taft
1995-03-27 14:54     ` Norman H. Cohen
1995-03-28 18:36       ` Kennel [this message]
1995-03-28 18:42         ` Kennel
1995-03-25 18:01   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox