Path: news.daimi.aau.dk!olm From: olm@daimi.aau.dk (Ole Lehrmann Madsen) Newsgroups: comp.lang.beta Subject: Re: Mantatory argument Date: 14 Jun 1997 16:54:01 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 80 Distribution: y Message-ID: <5nuib9$lrb$1@gjallar.daimi.aau.dk> References: NNTP-Posting-Host: ariel.daimi.aau.dk X-Newsreader: NN version 6.5.1 (NOV) Xref: news.daimi.aau.dk comp.lang.beta:11146 In Alf-Ivar Holm writes: You are right, that this kind of error may be a problem, and it would be nice to catch it at compile-time. There is actually a suggestion for a syntax for this: Optional enter/exit parts: foo: (# ... enter?(x,y) do ... exit? z #) Mandatory enter/exit parts: bar: (# enter(x,y) do ... exit z #) The enter/exit lists of foo are defined as optional, in the sense that input/output arguments may be specified. The enter/exit list of bar are mandatory meaning that enter/exit arguments must be supplied. The current enter/exit parts of BETA thus correspond to the optional enter/exit parts, even if the current syntax is the same as the one for mandatory. Of course an optional enter-part can be combined with a mandatory exit part and vice versa. This proposal was, however, never implemented. BETA has always beeen guided by a minimalistic approach, i.e. as few constructs as possible. For mandatory enter/exit parts we decided to find out how much of a problem it would be. So far few people have complained. I have been beaten by it myself and maybe others have the same experience? ---olm >I have a library with some functions. These functions does only >provide something useful if given an argument. If I, by mistake, >don't assign any values to these functions, the program continues, but >the value(s) produces by the functions may break something else later >on. >Two problems: > 1) The error is not catched where it occurred, and > 2) The error is not found before run-time. >Problem 1) may by fixed by adding something extra to each function >that give a warning or error at runtime if the functions are not >called with an argument. Something like: > myFunc: > (# in, out: @integer; > entered: @boolean; > enter (# enter in do true->entered #) > do (if not(entered) then notification(# ... #) else ... if); > exit out > #); >This is still no remedy for problem 2). I have to wait for the >erroneous statement to occur run-time. What I would like were some >kind of construct that would let me say that some patterns must be >assigned values. It may be a bit non-Beta-ish to prevent patterns from >being used as any evaluation type. OTOH, Beta does catch a lot of >errors compile-time, and this seems to be another case where it would >not be too hard for the compiler to find the error, given some >indication that the pattern must evaluate it's enter part. >Is it only me who would like this? Have I missed something? > Affi