Path: news.cs.au.dk!not-for-mail From: Kasper Dupont Newsgroups: comp.lang.beta Subject: Re: Virtual attribute gives Seg Fault when accessed from pattern ref Date: Mon, 03 May 1999 10:01:33 +0200 Organization: cs.au.dk Lines: 102 Message-ID: <372D57DD.41C6@cs.au.dk> References: <7gi6gi$99i$1@nnrp1.dejanews.com> NNTP-Posting-Host: aries.cs.au.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: xinwen.cs.au.dk 925718493 2107847 255.255.255.255 (3 May 1999 08:01:33 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 3 May 1999 08:01:33 GMT X-Mailer: Mozilla 3.04 (X11; I; IRIX64 6.5 IP30) Xref: news.cs.au.dk comp.lang.beta:11911 Andrew Klaassen wrote: > > Greetings: > > I don't have a great handle on all of BETA's 'big words' (it > took me half an hour just to find the words I needed for my > subject line ), so I'll have to explain my question with > code. The first program below compiles and runs. The second > program compiles, but crashed with a 'Segmentation Fault' at > the indicated point. Why? > > The first program: > > ORIGIN '~beta/basiclib/v1.6/betaenv'; > ---program:descriptor--- > (* This program compiles and runs. *) > (# > > Function: (* a simple pattern *) > (# a: @integer; > Printname: (# do 'Function' -> putline; #); > enter a > do > a -> putint; newline; > #); > > PatRef: ##Function; > > do > > Function## -> PatRef##; > 3 -> PatRef; > PatRef.Printname; > > #) > > The second program, which is very similar to the first: > > ORIGIN '~beta/basiclib/v1.6/betaenv'; > ---program:descriptor--- > (* compiles but crashes *) > (# > > Function: > (# a: @integer; > (* Printname is now a virtual pattern *) > Printname:< (# do inner #); > enter a > do > a -> putint; newline; > #); > > (* And we have a subpattern of Function, F1, which does > a final binding on Printname. *) > F1: Function (# Printname:: (# do 'Function' -> putline; #); #); > > PatRef: ##Function; > > do > > F1## -> PatRef##; > 3 -> PatRef; (* works *) > PatRef.Printname; (* crashed the program with a > 'Segmentation Fault' *) > > #) > > I'm not very familiar with the use of ## - there aren't many > references to it in the BETA Language Intro, Tutorial, FAQ, etc - > so I might be using it incorrectly. If anyone could explain > what's happening when the second program tries to execute > PatRef.Printname, it would be much appreciated. > > Thanks! > > -----------== Posted via Deja News, The Discussion Network ==---------- > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own You can not use an attribute on a pattern directly, you must first create an object from the pattern before you can use the attribute. Both your examples should get an "An object is expected here" error at compilation. To me it looks like a bug in the compiler. (**** should not compile ****) PatRef.Printname; (**** this should work ****) (# TempObject: ^Function; do &PatRef[]->TempObject[]; TempObject.Printname; #); /KD