Path: news.daimi.aau.dk!news.daimi.aau.dk!miksen From: miksen@peseta.daimi.aau.dk (Michael Thomsen) Newsgroups: comp.lang.beta Subject: Re: polymorphism Date: 30 Dec 1995 17:10:06 GMT Organization: DAIMI, Computer Science Dept. of Aarhus Univ. Lines: 76 Message-ID: References: <4bnjm4$cvg@krone.daimi.aau.dk> <4bp52o$kp4@netnews.upenn.edu> NNTP-Posting-Host: peseta.daimi.aau.dk In-reply-to: Wolfgang Ziller's message of 26 Dec 1995 15:41:12 GMT In article <4bp52o$kp4@netnews.upenn.edu> Wolfgang Ziller writes: # # Albertina Lourenci wrote: # >Hi, all| # > Could someone tell me if BETA supports polymorphism? If yes, # >can you demonstrate how? Special thanks. # # Yes, polymorphism is a vital part of Object-Oriented # Technology. BETA does support it and I believe the # following code is correct: # # polygon: (# draw:< (# do inner #) #); # circle: (# draw:<< (# do (* draw a circle *) #); # square: (# draw:<< (# do (* draw a sqare *) #); # # (# # a_polygon: @polygon; # a_circle: @circle; # a_square: @sqaure; # do # a_circle -> a_polygon; # a_polygon.draw; # a_square -> a_polygon; # a_polygon.draw; # #); # Well it should probably be a bit more like: (# polygon: (# draw:< (# do 'polygon ' -> puttext; inner #) #); circle: polygon(# draw::< (# do 'circle' -> putline; (* draw a circle *) #); #); square: polygon(# draw::< (# do 'square' -> putline; (* draw a sqare *) #); #); a_polygon: ^polygon; a_circle: @circle; a_square: @square; do a_circle[] -> a_polygon[]; a_polygon.draw; a_square[] -> a_polygon[]; a_polygon.draw; #) Which would print: polygon circle polygon square # That's roughly the idea. I'm not sure if the above code is # totally correct (esp. the a_polygon.draw parts. Also not # sure if you could condense the above and write # a_circle -> a_polygon.draw). Anyway, BETA definately # supports polymorphism. If you mean: a_circle[] -> a_poly.draw[] , then the answer is no. This would mean: assign the reference to a_circle to the enter part of a_poly.draw. Clearly a_poly.draw hasn't got an enter part. # # Regards, # Wolfgang Ziller Kind Regards, Michael Thomsen... -- -------------------------------------------------------------------- Michael Thomsen, Skejby Vaenge 10 B, DK-8200 Aarhus N, Denmark Phone: (+45) 86 78 22 93 Email: miksen@daimi.aau.dk --------------------------------------------------------------------