goer@ellis.uchicago.edu (Richard L. Goerwitz) (05/15/91)
I've always wondered why Icon uses the brace notation (rather than begin ... end;) for most groupings, but yet for procedures, a kind of mixed procedure name(vars)...end notation is used. I'm also a bit curious why the notion of functions and procedures was collap- sed into procedures, and yet with retention of the notion that a procedure is a value (i.e. like what we normally associate with fun- ctions). Just curious. -- -Richard L. Goerwitz goer%sophist@uchicago.bitnet goer@sophist.uchicago.edu rutgers!oddjob!gide!sophist!goer
gudeman@CS.ARIZONA.EDU (David Gudeman) (05/15/91)
>From: Richard L. Goerwitz >... I'm also a >bit curious why the notion of functions and procedures was collap- >sed into procedures, and yet with retention of the notion that a >procedure is a value (i.e. like what we normally associate with fun- >ctions). I assume you are talking about the Pascal distinction that functions are expression (things that return values) and procedures are statements (things that change variables but don't return values). But Icon doesn't have statements --only expressions-- so there is no such distinction to make. As to procedures being values, there is nothing unlikely about procedures-as-values even for Pascal-style procedures. It's just not traditional for Pascal-like languages to have procedures or functions as first-class values.
ka@felix.UUCP (Kenneth Almquist) (05/23/91)
goer@ellis.uchicago.edu (Richard L. Goerwitz) writes: > I've always wondered why Icon uses the brace notation (rather than > begin ... end;) for most groupings, but yet for procedures, a kind > of mixed procedure name(vars)...end notation is used. My guess is that this produces better diagnostics when braces are omitted. If you omit an open brace in C, the compiler will eventually encounter a closing brace in the middle of the procedure which appears to match the start of the procedure. None of the C compilers that I have seen are capable of recognizing this situation and determining that the procedure hasn't actually ended. Instead, they treat the procedure as ended and squawk about every line from the closing brace until the actual end of the procedure. Using something other than a closing brace to mark the end of a procedure avoids this problem. > I'm also a bit curious why the notion of functions and procedures > was collapsed into procedures, and yet with retention of the notion > that a procedure is a value (i.e. like what we normally associate > with functions). I'm not sure what you mean by a procedure being a value. Calling ICON procedures "functions" would be a mistake because the term "function" is defined by mathematicians to be something that returns exactly one value. In contrast, "procedure" is defined by usage within the compu- ter science community. In Algol and Pascal, a procedure can return values by setting parameters, but not by returning a value using the syntax for returning a value from a function. In PL/1 (which is more widely used than either Algol or Pascal) this restriction was lifted and a procedure can return a value using a "return" statement. So ICON's use of the term "procedure" to refer to something that can return zero or more values is a natural extension of prior practice. Kenneth Almquist