Path: news.daimi.aau.dk!not-for-mail From: Lars Balker Rasmussen Newsgroups: comp.lang.beta Subject: [comp.lang.beta] Re: leaving a pattern? Date: Thu, 4 Sep 1997 13:06:34 +0200 (MET DST) Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 101 Approved: mailtonews@daimi.aau.dk Distribution: world Message-ID: <199709041106.NAA02058@noatun.mjolner.dk> Reply-To: Lars Balker Rasmussen NNTP-Posting-Host: daimi.daimi.aau.dk Xref: news.daimi.aau.dk comp.lang.beta:11252 This posting was made to comp.lang.beta, but was not propagated to the mailing list due to a configuration problem. This configuration problem has also caused normal mail to the list to bounce, so in the unlikely event that you have sent anything (which bounced), please resend. Naturally, if you get to see this mail the list should work normally again :-) Cheers, Lars / Mjølner Informatics PS: My apoligies to the readers of comp.lang.beta, who are subjected to Eriks article a second time. ;-) ------- Start of forwarded message ------- From: Erik Ernst Newsgroups: comp.lang.beta Subject: Re: leaving a pattern? Date: 03 Sep 1997 19:04:02 +0200 Organization: DAIMI, Computer Science Dept. of Aarhus Univ. Message-ID: References: <5tguc5$r4n$1@gjallar.daimi.aau.dk> <5tiboo$2h6$1@gjallar.daimi.aau.dk> jlk@daimi.aau.dk (Jorgen Lindskov Knudsen) writes: > > In <5tguc5$r4n$1@gjallar.daimi.aau.dk> jojo@daimi.aau.dk (Johanna Wiederhold) writes: > > >transaction: > > (# > > abort :(# do leave transaction #); > > ... > > do > > INNER > > #); > > >[causes an] error message: > > >leave transaction > >***** "leave P" or "restart P", where "P" is a pattern, > > is only legal in the do-part of "P" > > > >If you know a solution, let me know. > >[..] > > There is no real good solution to this. > > Why does this not work as one might expect (as you definitely thought). > Let us elaborate a little on your example: > > (# myTrans: @transaction; > ... > do ... > myTrans.abort; > ... > #) > > This shows why...when executing myTrans.about, myTrans is not on the > execution stack, leaving the semantics of 'leave transaction' > undefined (what should it 'leave'). > > This restriction in the compiler is inserted to avoid these (and > similar) problems. But since we could simply do (# pv: ##object do L: (# p: (# do leave L #) do p##->pv## #); pv (* 'leave L', but the inserted item is not on the stack now *) #) executing "homeless" leave/restart instructions is generally possible anyway. We don't have to use pattern variables, dynamic references would do, of course. It just causes an 'attempt to leave basic component' error message, because the stack unwinding machinery did not find an appropriate object on the stack to stop at. Not really worse than "divide by zero", and not better either.. Another thing is that it ought to stop the current thread, not the entire program, both when "divide by zero" and "leaving last component" happens. I believe this will happen as soon as somebody gets it implemented, though. So I think it should be allowed. Forbidding it is almost taking a safety-by-obscurity approach, which is usually not a clean solution to anything. And certain things _are_ easier to express with it, like your example. I have used a similar construct as my "L"/"p" example above several times, and it works nicely. It shouldn't be hard to implement either, at least it was no problem to support it in my interpreter ;-) -- Erik Ernst eernst@daimi.aau.dk Computer Science Department of Aarhus University, Denmark Check ------- End of forwarded message -------