--* From postmaster%watson.vnet.ibm.com@yktvmv.watson.ibm.com  Mon Sep  5 09:58:52 1994
--* Received: from yktvmv-ob.watson.ibm.com by asharp.watson.ibm.com (AIX 3.2/UCB 5.64/930311)
--*           id AA21294; Mon, 5 Sep 1994 09:58:52 -0400
--* Received: from watson.vnet.ibm.com by yktvmv.watson.ibm.com (IBM VM SMTP V2R3)
--*    with BSMTP id 9583; Mon, 05 Sep 94 09:58:57 EDT
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id <A.CLAIRE.NOTE.YKTVMV.2881.Sep.05.09:58:56.-0400>
--*           for asbugs@watson; Mon, 05 Sep 94 09:58:56 -0400
--* Received: from imag.imag.fr by watson.ibm.com (IBM VM SMTP V2R3) with TCP;
--*    Mon, 05 Sep 94 09:58:55 EDT
--* Received: from blizzard.imag.fr by imag.imag.fr with SMTP id AA10282
--*   (5.65c8/IDA-1.4.4 for <asbugs@watson.ibm.com>); Mon, 5 Sep 1994 15:54:53 +0200
--* Received: by blizzard.imag.fr (AIX 3.2/UCB 5.64/5.17)
--* 	id AA12822; Mon, 5 Sep 1994 15:50:50 +0200
--* Date: Mon, 5 Sep 1994 15:50:50 +0200
--* From: Claire.Dicrescenzo@imag.fr (Claire Di Crescenzo)
--* Message-Id: <9409051350.AA12822@blizzard.imag.fr>
--* To: asbugs@watson.ibm.com
--* Subject: [1] ther is a problem with Union using local definetypes [test.as][3.2-0.36.0]

--@ Fixed  by:  PAB   Mon Sep 5 22:39:55 EDT 1994 
--@ Tested by:  cascade1.as 
--@ Summary:    Fixed in version v0.36.5 

--+
--+ test.as : complete programme. The Union type does not run with the local
--+ 	  type Serie,....
--+
--+ when I cut the file in 2 files one with the type Serie ,... and the other
--+ one with the Union all is OK :
--+ 	test2.as file with the type definitions
--+ 	test1.as file withe the Union definition
-------------------------------  test.as  ------------------------------------

#include "aslib.as"

macro { SI == SingleInteger ;
	F == DoubleFloat ;
	CF == Complex DoubleFloat ;
      }

Method : BasicType  with {
    	     typeFunc? : % -> Boolean ;
	     typeSerie? : % -> Boolean ;
  } == add {
     import from SI, F, CF, List F ;

     ParamFunc ==> Record(func: CF -> CF) ;
     ParamSerie ==> Record(nbterm: SI,
		        combli: List F, dirresom: F) ;

     Fonction: BasicType with {
	  --coerce : % -> ParamFunc ;
	  coerce : ParamFunc -> % ;
	} == add {
	  Rep ==> ParamFunc ;
	  import from Rep, DoubleFloatElementaryFunctions ;

	  (p1:%) = (p2:%):Boolean == true ;--rep p1 = rep p2 ;

	  (p:TextWriter) << (s:%): TextWriter == {
		--rs:= rep s ;
		p << "Function:" ;
	      }

	  --coerce(f: %):ParamFunc == rep f ;

	  coerce(f:ParamFunc): % == per f ;

	  sample:% == per [exp] ;
        }
	
     Serie: BasicType with {
	  coerce : % -> ParamSerie ;
	  coerce : ParamSerie -> % ;
	} == add {
	  Rep ==> ParamSerie ;
	  import from Rep ;

	  (p1:%) = (p2:%):Boolean == {
		rp1:= rep p1 ;
		rp2:= rep p2 ;
		rp1.nbterm=rp2.nbterm and
			rp1.combli=rp2.combli and rp1.dirresom=rp2.dirresom ;
	      }
	  (p:TextWriter) << (s:%): TextWriter == {
		rs:= rep s ;
		import from String ;
		p << ", combli: " << rs.combli ;
		p << ", dirresom: " << rs.dirresom << ")";
	      }
	  sample:% == per [21,empty(),0.0] ;

	  coerce(m:%): ParamSerie == rep m ;

	  coerce(m:ParamSerie): % == per m ;
        }


     Rep ==> Union(serie:Serie, funct:Fonction) ;

     import from Rep ;

     typeFunc?(m:%):Boolean == { rep(m) case funct => true ;
				  false ;
			      }

     typeSerie?(m:%):Boolean == { rep(m) case serie => true ;
				   false ;
			       }

     (p:TextWriter) << (m:%): TextWriter == {
		rm :=rep(m);
		rm case funct => p << (rm.funct) ;
		rm case serie => p << (rm.serie) ;
		p ;
	      }

     (m1:%) = (m2:%): Boolean == {
		rm1 := rep m1;
		rm2 := rep m2 ;
		(rm1 case funct) and (rm2 case funct) => rm1.funct = rm2.funct ;
		(rm1 case serie) and (rm2 case serie) => rm1.serie = rm2.serie;
		false ;
	      }

     sample: % == {
	  ex:ParamSerie := [21,empty(),0.0];
	  per [coerce(ex)$Serie] ;
	}
	
  }	
 
