Path: news.daimi.aau.dk!news.uni-c.dk!sunic!ugle.unit.no!trane.uninett.no!nntp.uio.no!ifi.uio.no!nntp!alfh From: alfh@byleist.ifi.uio.no (Alf-Ivar Holm) Newsgroups: comp.lang.beta Subject: Pattern variables Followup-To: comp.lang.beta Date: 06 Feb 1995 17:48:11 GMT Organization: Dept. of Informatics, University of Oslo, Norway Lines: 52 Message-ID: NNTP-Posting-Host: byleist.ifi.uio.no CC: I have seen (a version of) the following program as an example of using pattern variables in BETA: ORIGIN '~beta/basiclib/current/betaenv'; --- PROGRAM : descriptor --- (# intFunc: (# x,y: @integer enter x do inner exit y #); comp: (# f,g: ##intFunc; h: intFunc(# do x -> f -> g -> y #) enter (f##, g##) exit h## #); a: intFunc(# do x+x -> y #); b: intFunc(# do x*x -> y #); ab: ##intFunc; in: @integer; do (a##, b##) -> &comp -> ab##; 'In: ' -> putText; getInt -> in; 'Out: ' -> putText; in -> ab -> putInt; newline; #) As far as I can see, the program below is doing the same, but now with objects and dynamic references instead of pattern variables: ORIGIN '~beta/basiclib/current/betaenv'; --- PROGRAM : descriptor --- (# intFunc: (# x,y: @integer enter x do inner exit y #); comp: (# f,g: ^intFunc; h: intFunc(# do x -> f -> g -> y #) enter (f[], g[]) exit &h[] #); a: intFunc(# do x+x -> y #); b: intFunc(# do x*x -> y #); ab: ^intFunc; in: @integer; do (&a[], &b[]) -> &comp -> ab[]; 'In: ' -> putText; getInt -> in; 'Out: ' -> putText; in -> ab -> putInt; newline; #) Can someone please enlighten me on why pattern variables is the thing to use in this context? Affi