UNIX — универсальная среда программирования - Керниган Брайан Уилсон
На этом ресурсе Вы можете бесплатно читать книгу онлайн UNIX — универсальная среда программирования - Керниган Брайан Уилсон. Жанр: ОС и Сети / Интернет . На сайте booksdaily.club Вы можете онлайн читать полную версию книги без регистрации и sms. Так же Вы можете ознакомится с содержанием, описанием, предисловием о произведении
lfCW n l.fBTable 3:fP Built-in Constants.sp .5DEG 57.29577951308232087680 @180/ [email protected], degrees per radianE 2.71828182845904523536 @[email protected], base of natural logarithmsGAMMA 0.57721566490153286060 @[email protected], Euler-Mascheroni constantPHI 1.61803398874989484820 @( sqrt 5 +1)/[email protected], the golden ratioPI 3.14159265358979323846 @[email protected], circular transcendental number.ТЕ.ix table~of [hoc] constants.NHStatements and Control Flow.PP.I Hocstatements have the following grammar:.DS.Istmt: expr | variable = expr | procedure ( arglist ) | while ( expr ) stmt | if ( expr ) stmt | if ( expr ) stmt else stmt | { stmtlist } | print expr-list | return optional-exprstmtlist: fR(nothing)fI | stmlist stmt.R.DEAn assignment is parsed by default as a statement rather thanan expression, so assignments typed interactivelydo not print their value..PPNote that semicolons are not special to.ix [hoc] input~format@[email protected]: statements are terminated by newlines.This causes some peculiar behavior.The following are legal.IT ifstatements:.DS.ft CWif (x < 0) print(y) else print(z)if (x < 0) { print(y)} else { print(z)}.ft.DEIn the second example, the braces are mandatory:the newline after the.I ifwould terminate the statement and produce a syntax error werethe brace omitted..PPThe syntax and semantics of @[email protected]control flow facilities are basically the same as in C.The.I whileand.I ifstatements are just as in C, except there are no @[email protected] or@[email protected] statements..NHInput and Output: @[email protected] and @[email protected].PP.ix [hoc] [read]~statement.ix [hoc] [print]~statementThe input function @[email protected], like the other built-ins,takes a single argument. Unlike the built-ins, though, the argumentis not ал expression: it is the name of a variable.The next number (as defined above) is read from the standard inputand assigned to the named variable.The return value of @[email protected] is 1 (true) if a value was read, and 0 (false)if @[email protected] encountered end of file or an error..PPOutput is generated with the ©print© statement.The arguments to @[email protected] are a comma-separated list of expressionsand strings in double quotes, as in C.Newlines must be supplied;they are never provided automatically by @[email protected].PPNote that @[email protected] is a special built-in function, and therefore takesa single parenthesized argument, while @[email protected] is a statement that takesa comma-separated, unparenthesized list:.DS.ft CWwhile (read(x)) { print "value is ", x, "n"}.ft.DE.NHFunctions and Procedures.PPFunctions and procedures are distinct in @[email protected],although they are defined by the same mechanism.This distinction is simply for run-time error checking:it is an error for a procedure to return a value,and for a function @[email protected] to return one..PPThe definition syntax is:.ix [hoc] function~definition.ix [hoc] procedure~definition.DS