Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
ALGOL
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Examples and portability== {{expand section | with = further annotation indicating sources of code samples, as Wikipedia disallows presentation of individual editor creations or other original research | small = no |date=February 2024}} ===Code sample comparisons=== ====ALGOL 60==== (The way the bold text has to be written depends on the implementation, e.g. 'INTEGER'—quotation marks included—for integer. This is known as [[stropping (programming)|stropping]].) '''procedure''' Absmax(a) Size:(n, m) Result:(y) Subscripts:(i, k); '''value''' n, m; '''array''' a; '''integer''' n, m, i, k; '''real''' y; '''comment''' The absolute greatest element of the matrix a, of size n by m, is copied to y, and the subscripts of this element to i and k; '''begin''' '''integer''' p, q; y := 0; i := k := 1; '''for''' p := 1 '''step''' 1 '''until''' n '''do''' '''for''' q := 1 '''step''' 1 '''until''' m '''do''' '''if''' abs(a[p, q]) > y '''then''' '''begin''' y := abs(a[p, q]); i := p; k := q '''end''' '''end''' Absmax Here is an example of how to produce a [[Table (information)|table]] using Elliott 803 ALGOL.<ref>[http://www.billp.org/ccs/A104/ "803 ALGOL"] {{webarchive|url=https://web.archive.org/web/20100529063048/http://www.billp.org/ccs/A104/ |date=29 May 2010}}, the manual for Elliott 803 ALGOL</ref> FLOATING POINT ALGOL TEST' BEGIN REAL A,B,C,D' READ D' FOR A:= 0.0 STEP D UNTIL 6.3 DO BEGIN PRINT {{abbr|PUNCH(3)|sends output to the teleprinter rather than the tape punch.}},££L??' B := SIN(A)' C := COS(A)' PRINT PUNCH(3),{{abbr|SAMELINE|suppresses the carriage return + line feed normally printed between arguments.}},{{abbr|ALIGNED(1,6)|controls the format of the output with one digit before and six after the decimal point.}},A,B,C' END END' ====ALGOL 68==== The following code samples are ALGOL 68 versions of the above ALGOL 60 code samples. ALGOL 68 implementations used ALGOL 60's approaches to [[stropping (programming)|stropping]]. In ALGOL 68's case tokens with the bold typeface are reserved words, types (modes) or operators. '''proc''' abs max = ([,]'''real''' a, '''ref''' '''real''' y, '''ref''' '''int''' i, k)'''real''': '''comment''' The absolute greatest element of the matrix a, of size ⌈a by 2⌈a is transferred to y, and the subscripts of this element to i and k; '''comment''' '''begin''' '''real''' y := 0; i := ⌊a; k := 2⌊a; '''for''' p '''from''' ⌊a '''to''' ⌈a '''do''' '''for''' q '''from''' 2⌊a '''to''' 2⌈a '''do''' '''if''' '''abs''' a[p, q] > y '''then''' y := '''abs''' a[p, q]; i := p; k := q '''fi''' '''od''' '''od'''; y '''end''' # abs max # Note: lower (⌊) and upper (⌈) bounds of an array, and array slicing, are directly available to the programmer. floating point algol68 test: ( '''real''' a,b,c,d; # ''printf'' – sends output to the '''file''' ''stand out''. # # ''printf($p$);'' – selects a ''new page'' # printf(($pg$,"Enter d:")); read(d); '''for''' step '''from''' 0 '''while''' a:=step*d; a <= 2*pi '''do''' printf($l$); # ''$l$'' - selects a ''new line''. # b := sin(a); c := cos(a); printf(($z-d.6d$,a,b,c)) # formats output with 1 digit before and 6 after the decimal point. # '''od''' ) ===Timeline: Hello world=== The variations and lack of portability of the programs from one implementation to another is easily demonstrated by the classic [[hello world program]].{{citation needed|date = February 2024}} ====ALGOL 58 (IAL)==== {{main|ALGOL 58}} ALGOL 58 had no I/O facilities. ====ALGOL 60 family==== {{main|ALGOL 60}} Since ALGOL 60 had no I/O facilities, there is no portable [[hello world program]] in ALGOL. The next three examples are in Burroughs Extended Algol. The first two direct output at the interactive terminal they are run on. The first uses a character array, similar to C. The language allows the array identifier to be used as a pointer to the array, and hence in a REPLACE statement. {{sxhl|2=m2|1= BEGIN FILE F(KIND=REMOTE); EBCDIC ARRAY E[0:11]; REPLACE E BY "HELLO WORLD!"; WRITE(F, *, E); END. }} A simpler program using an inline format: {{sxhl|2=m2|1= BEGIN FILE F(KIND=REMOTE); WRITE(F, <"HELLO WORLD!">); END. }} An even simpler program using the Display statement. Note that its output would end up at the system console ('SPO'): {{sxhl|2=m2|1= BEGIN DISPLAY("HELLO WORLD!") END.}} An alternative example, using Elliott Algol I/O is as follows. Elliott Algol used different characters for "open-string-quote" and "close-string-quote", represented here by {{color box|rgba(255,255,255,0)|border=silver|[[‘]]}} and {{color box|rgba(255,255,255,0)|border=silver|[[Single quotation mark|’]]}}. {{sxhl|2=pascal|1= program HiFolks; begin print ‘Hello world’ end; }} Below is a version from Elliott 803 Algol (A104). The standard Elliott 803 used five-hole paper tape and thus only had upper case. The code lacked any quote characters so £ (UK Pound Sign) was used for open quote and ? (Question Mark) for close quote. Special sequences were placed in double quotes (e.g£. £L?? produced a new line on the teleprinter). HIFOLKS' BEGIN PRINT £HELLO WORLD£L??' END' The [[ICT 1900 series]] Algol I/O version allowed input from paper tape or punched card. Paper tape 'full' mode allowed lower case. Output was to a line printer. The open and close quote characters were represented using '(' and ')' and spaces by %.<ref>{{cite web|url=http://www.icl1900.co.uk/techpub/tp3340.djvu|title=ICL 1900 series: Algol Language|publisher=ICL Technical Publication 3340|year=1965}}</ref> 'BEGIN' WRITE TEXT('('HELLO%WORLD')'); 'END' ====ALGOL 68==== {{main|ALGOL 68}} '''ALGOL 68''' code was published with reserved words typically in lowercase, but bolded or underlined. '''begin''' printf(($gl$,"Hello, world!")) '''end''' In the language of the "Algol 68 Report" the [[input/output]] facilities were collectively called the "Transput". ===Timeline of ALGOL special characters=== {{Contains special characters | alt = Decimal Exponent Symbol | link = http://mailcom.com/unicode/DecimalExponent.ttf | special = Unicode 6.0 "[https://www.unicode.org/charts/PDF/U2300.pdf Miscellaneous Technical]" characters | fix = Unicode#External_links | characters = something like "₁₀" ([http://mailcom.com/unicode/DecimalExponent.ttf Decimal Exponent Symbol U+23E8 TTF]) }} The ALGOLs were conceived at a time when character sets were diverse and evolving rapidly; also, the ALGOLs were defined so that only ''uppercase'' letters were required. 1960: [[IFIP]] – The Algol 60 language and report included several mathematical symbols which are available on modern computers and operating systems, but, unfortunately, were unsupported on most computing systems at the time. For instance: ×, ÷, ≤, ≥, ≠, ¬, ∨, ∧, ⊂, ≡, ␣ and ⏨. 1961 September: ASCII – The [[ASCII]] character set, then in an early stage of development, had the [[/|\]] (Back slash) character added to it in order to support ALGOL's [[Boolean data type|Boolean]] operators [[ALGOL 68#Dyadic operators with associated priorities|/\]] and [[ALGOL 68#Dyadic operators with associated priorities|\/]].<ref>[http://www.bobbemer.com/BACSLASH.HTM How ASCII Got Its Backslash] {{webarchive|url=https://web.archive.org/web/20140711225835/http://bobbemer.com/BACSLASH.HTM |date=11 July 2014}}, Bob Bemer</ref> 1962: [[ALCOR]] – This character set included the unusual "᛭"<!-- U+16ED --> runic cross<ref>[https://www.fileformat.info/info/unicode/char/16ed/ iron/runic cross]</ref> character for multiplication and the "⏨" Decimal Exponent Symbol<ref>[http://mailcom.com/unicode/DecimalExponent.ttf Decimal Exponent Symbol]</ref> for floating point notation.<ref>{{cite journal |last=Baumann |first=R. |title=ALGOL Manual of the ALCOR Group, Part 1 |journal=Elektronische Rechenanlagen |date=October 1961 |pages=206–212 |language=de|trans-title=ALGOL Manual of the ALCOR Group}}</ref><ref>{{cite journal |last=Baumann |first=R. |title=ALGOL Manual of the ALCOR Group, Part 2 |journal=Elektronische Rechenanlagen |volume=6 |date=December 1961 |pages=259–265 |language=de|trans-title=ALGOL Manual of the ALCOR Group}}</ref><ref>{{cite journal |last=Baumann |first=R. |title=ALGOL Manual of the ALCOR Group, Part 3 |journal=Elektronische Rechenanlagen |volume=2 |date=April 1962 |language=de|trans-title=ALGOL Manual of the ALCOR Group}}</ref> 1964: [[GOST]] – The 1964 Soviet standard [[GOST 10859]] allowed the encoding of 4-bit, 5-bit, 6-bit and 7-bit characters in ALGOL.<ref>{{cite web|title=GOST 10859 standard |url=http://homepages.cwi.nl/~dik/english/codes/stand.html#gost10859 |access-date=5 June 2007 |archive-url=https://web.archive.org/web/20070616201227/http://homepages.cwi.nl/~dik/english/codes/stand.html |archive-date=16 June 2007 |url-status=dead}}</ref> 1968: The "Algol 68 Report" – used extant ALGOL characters, and further adopted →, ↓, ↑, □, ⌊, ⌈, ⎩, ⎧, ○, ⊥, and ¢ characters which can be found on the [[IBM 2741]] keyboard with ''[[IBM Selectric typewriter|typeball]]'' (or ''golf ball'') [[Printer (computing)#Typewriter-derived printers|print heads]] inserted (such as the [[APL (programming language)#Hardware|APL golf ball]]). These became available in the mid-1960s while ALGOL 68 was being drafted. The report was translated into Russian, German, French, and Bulgarian, and allowed programming in languages with larger character sets, e.g., [[Cyrillic]] alphabet of the Soviet [[BESM]]-4. All ALGOL's characters are also part of the [[Unicode]] standard and most of them are available in several popular [[font]]s. 2009 October: [[Unicode]] – The <code>⏨</code> (Decimal Exponent Symbol) for floating point notation was added to Unicode 5.2 for backward compatibility with historic [[Buran programme]] ALGOL software.<ref>{{cite web |url = https://www.unicode.org/L2/L2008/08030r-subscript10.pdf |title = Revised proposal to encode the decimal exponent symbol |last = Broukhis |first = Leonid |date = 22 January 2008 |website = www.unicode.org |publisher = ISO/IEC JTC 1/SC 2/WG 2 |access-date = 24 January 2016 |quote = This means that the need to transcode GOST-based software and documentation can still arise: legacy numerical algorithms (some of which may be of interest, e.g. for the automatic landing of the Buran shuttle ...) optimized for the non-IEEE floating point representation of BESM-6 cannot be simply recompiled and be expected to work reliably, and some human intervention may be necessary. |url-status = live |archive-url = https://web.archive.org/web/20150731024347/http://www.unicode.org/L2/L2008/08030r-subscript10.pdf |archive-date=31 July 2015 }}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)