Path: news.cs.au.dk!not-for-mail From: Peter Andersen Newsgroups: comp.lang.beta Subject: Re: IO-redirection? Date: 26 Jun 2000 13:26:09 -0000 Organization: University of Aarhus, Department of Computer Science (DAIMI) Lines: 87 Approved: mailtonews@cs.au.dk Distribution: world Message-ID: <20000626132609.18947.qmail@noatun.mjolner.dk> Reply-To: Peter Andersen NNTP-Posting-Host: daimi.cs.au.dk X-Trace: xinwen.cs.au.dk 962026034 555361 255.255.255.255 (26 Jun 2000 13:27:14 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 26 Jun 2000 13:27:14 GMT Xref: news.cs.au.dk comp.lang.beta:12489 Atle writes: > Hello, honorable members of the Beta community! > > I have a small, quick problem, I should know this, but somehow my intuition doesn't ssem to work. > I want to do the > printON(FILE* strm) > { > fprintf(strm, "This and that\n"); > ... and so on .. > } > > I thought this was the way > > printON: > (# > strm: ##STREAM; > > 'This and that'->strm.putLine; > ... and so on ... > > #) > > this compiles, but > > screen##->printON; > > does not? > > I know I'm doing something ver wrong here, but .. what? First of all you are missing a specification of the enter list of printON: enter ##strm BUT: the notation ##STREAM means a "pattern reference" to the pattern stream. In the application "strm.putLine" this would mean "instantiate a new object corresponding to the pattern referenced, and then invoke the putLine method of that object". And the syntax screen##->printON would mean: "Obtain the pattern information (i.e. type information) of the screen object, assign this pattern information to the enter parameter of printON, and invoke the do-part of printON". This would probably work, but it is inefficient to first extract the type information of the screen-object and then instantiate an instance of it (which will immediately become garbage after the printON has completed). Instead you should use *object references* as in: printON: (# strm: ^STREAM; enter strm[] (* stream to print on *) do 'This and that'->strm.putLine; ... and so on ... #) .... do screen[] -> printON The the existing screen object will be used, and the only objects instantiated would be the printON and putLine objects. For an overview of the BETA constructs you may also wish to consult the "BETA Terminology" and "BETA Quick Reference Card" which can be found in your "doc/beta-intro" directory. For the latest versions see http://www.mjolner.com/mjolner-system/documentation/tutorials.html which refers these documents. Sincerely, Peter Andersen, Mjolner Informatics