Pascal (programming language): Difference between revisions

Content deleted Content added
No edit summary
m caps
Line 159:
| floating-point numbers
|-
| [[booleanBoolean type|booleanBoolean]]
| the values True or False
|-
Line 166:
|-
| [[set (computer science)|set]]
| equivalent to an array of [[booleanBoolean type|booleanBoolean]] values
|-
| [[Array data type|array]]
Line 178:
|}
 
The range of values allowed for the basic types (except booleanBoolean) is implementation defined. Functions are provided for some data conversions. For conversion of <code>real</code> to <code>integer</code>, the following functions are available: <code>round</code> (which rounds to integer using [[banker's rounding]]) and <code>trunc</code> (rounds towards zero).
 
The programmer has the freedom to define other commonly used data types (e.g. byte, string, etc.) in terms of the predefined types using Pascal's type declaration facility, for example
Line 502:
 
===Early criticism===
While very popular in the 1980s and early 1990s, implementations of Pascal that closely followed Wirth's initial definition of the language were widely criticized as being unsuitable for use outside teaching. [[Brian Kernighan]], who popularized the [[C (programming language)|C language]], outlined his most notable criticisms of Pascal as early as 1981 in his article "Why Pascal is Not My Favorite Programming Language".<ref>Brian W. Kernighan (1981). [http://www.lysator.liu.se/c/bwk-on-pascal.html "Why Pascal is Not My Favorite Programming Language"]. {{webarchive |url=https://web.archive.org/web/20090428163341/https://www.princeton.edu/~mike/unixhistory |date=2009-04-28}}</ref> The most serious problem Kernighan described was that array sizes and string lengths were part of the type, so it was not possible to write a function that would accept variable-length arrays or even strings as parameters. This made it unfeasible to write, for example, a sorting library. Kernighan also criticized the unpredictable order of evaluation of booleanBoolean expressions, poor library support, and lack of [[static variable]]s, and raised a number of smaller issues. Also, he stated that the language did not provide any simple constructs to "escape" (knowingly and forcibly ignore) restrictions and limitations. More general complaints from other sources<ref name="Hoare.Sneeringer.Welsh.1977"/><ref>O. Lecarme, P. Desjardins, "More Comments on the Programming Language Pascal", ''Acta Informatica 4'', pp. 231–243 (1975).</ref> noted that the scope of declarations was not clearly defined in the original language definition, which sometimes had serious consequences when using [[forward declaration]]s to define pointer types, or when record declarations led to [[Recursive data type|mutual recursion]], or when an identifier may or may not have been used in an enumeration list. Another difficulty was that, like [[ALGOL 60]], the language did not allow procedures or functions passed as parameters to predefine the expected type of their parameters.
 
Despite initial criticisms, Pascal continued to evolve, and most of Kernighan's points do not apply to versions of the language which were enhanced to be suitable for commercial product development, such as Borland's [[Turbo Pascal]]. As Kernighan predicted in his article, most of the extensions to fix these issues were incompatible from compiler to compiler. Since the early 1990s, however, most of the varieties seem condensed into two categories: ISO and Borland-like. Extended Pascal addresses many of these early criticisms. It supports variable-length strings, variable initialization, separate compilation, short-circuit booleanBoolean operators, and default (<code>otherwise</code>) clauses for case statements.<ref>{{Cite web |url=http://pascal-central.com/ppl/chapter3.html#Extended |title=Extended Pascal |url-status=dead |archive-url=https://web.archive.org/web/20151018023934/http://www.pascal-central.com/ppl/chapter3.html |archive-date=2015-10-18}}</ref>
 
==See also==