diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-05-03 19:29:24 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-05-03 19:29:24 +0300 |
commit | 8f79856a02dd3e3ba8fc00a6e3086a367ca0cdf4 (patch) | |
tree | 24af6e2e9be60d3c48e9ad32d81459dfcc15b9d7 | |
parent | a95aad26e785335f6cca2d9009388f4a74ae3635 (diff) | |
download | egawk-8f79856a02dd3e3ba8fc00a6e3086a367ca0cdf4.tar.gz egawk-8f79856a02dd3e3ba8fc00a6e3086a367ca0cdf4.tar.bz2 egawk-8f79856a02dd3e3ba8fc00a6e3086a367ca0cdf4.zip |
Add initial doc for @/.../ and typeof.
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/gawk.info | 1231 | ||||
-rw-r--r-- | doc/gawk.texi | 125 | ||||
-rw-r--r-- | doc/gawktexi.in | 125 |
4 files changed, 914 insertions, 572 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index f38b795a..5a444252 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2015-05-03 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Add initial documentation for strongly typed + regexps and for `typeof'. + 2015-04-29 Arnold D. Robbins <arnold@skeeve.com> * 4.1.2: Release tar ball made. diff --git a/doc/gawk.info b/doc/gawk.info index c7fd5c36..ee547e65 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -175,6 +175,7 @@ entitled "GNU Free Documentation License". * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. * Records:: Controlling how data is split into records. @@ -3327,6 +3328,7 @@ you specify more complicated classes of strings. * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. @@ -4031,7 +4033,7 @@ No options default. -File: gawk.info, Node: Case-sensitivity, Next: Regexp Summary, Prev: GNU Regexp Operators, Up: Regexp +File: gawk.info, Node: Case-sensitivity, Next: Strong Regexp Constants, Prev: GNU Regexp Operators, Up: Regexp 3.8 Case Sensitivity in Matching ================================ @@ -4105,10 +4107,73 @@ obscure and we don't recommend it. means that `gawk' does the right thing. -File: gawk.info, Node: Regexp Summary, Prev: Case-sensitivity, Up: Regexp +File: gawk.info, Node: Strong Regexp Constants, Next: Regexp Summary, Prev: Case-sensitivity, Up: Regexp -3.9 Summary -=========== +3.9 Strongly Typed Regexp Constants +=================================== + +This minor node describes a `gawk'-specific feature. + + Regexp constants (`/.../') hold a strange position in the `awk' +language. In most contexts, they act like an expression: `$0 ~ /.../'. +In other contexts, they denote only a regexp to be matched. In no case +are they really a "first class citizen" of the language. That is, you +cannot define a scalar variable whose type is "regexp" in the same +sense that you can define a variable to be a number or a string: + + num = 42 Numeric variable + str = "hi" String variable + re = /foo/ Wrong! re is the result of $0 ~ /foo/ + + For a number of more advanced use cases (described later on in this +Info file), it would be nice to have regexp constants that are +"strongly typed"; in other words, that denote a regexp useful for +matching, and not an expression. + + `gawk' provides this feature. A strongly typed regexp constant +looks almost like a regular regexp constant, except that it is preceded +by an `@' sign: + + re = @/foo/ Regexp variable + + Strongly typed regexp constants _cannot_ be used eveywhere that a +regular regexp constant can, because this would make the language even +more confusing. Instead, you may use them only in certain contexts: + + * On the righthand side of the `~' and `!~' operators: `some_var ~ + @/foo/' (*note Regexp Usage::). + + * In the `case' part of a `switch' statement (*note Switch + Statement::). + + * As an argument to one of the built-in functions that accept regexp + constants: `gensub()', `gsub()', `match()', `patsplit()', + `split()', and `sub()' (*note String Functions::). + + * As a parameter in a call to a user-defined function. (*note + User-defined::). + + * On the righthand side of an assignment to a variable: `some_var = + @/foo/'. In this case, the type of `some_var' is regexp. + Additionally, `some_var' can be used with `~' and `!~', passed to + one of the built-in functions listed above, or passed as a + parameter to a user-defined function. + + You may use the `typeof()' built-in function (*note Type Functions::) +to determine if a variable or function parameter is a regexp variable. + + The true power of this feature comes from the ability to create +variables that have regexp type. Such variables can be passed on to +user-defined functions, without the confusing aspects of computed +regular expressions created from strings or string constants. They may +also be passed through indirect function calls (*note Indirect Calls::) +onto the built-in functions that accept regexp constants. + + +File: gawk.info, Node: Regexp Summary, Prev: Strong Regexp Constants, Up: Regexp + +3.10 Summary +============ * Regular expressions describe sets of strings to be matched. In `awk', regular expression constants are written enclosed between @@ -4141,6 +4206,9 @@ File: gawk.info, Node: Regexp Summary, Prev: Case-sensitivity, Up: Regexp sensitivity of regexp matching. In other `awk' versions, use `tolower()' or `toupper()'. + * Strongly typed regexp constants (`@/.../') enable certain advanced + use cases to be described later on in the Info file. + File: gawk.info, Node: Reading Files, Next: Printing, Prev: Regexp, Up: Top @@ -13499,14 +13567,33 @@ File: gawk.info, Node: Type Functions, Next: I18N Functions, Prev: Bitwise Fu 9.1.7 Getting Type Information ------------------------------ -`gawk' provides a single function that lets you distinguish an array -from a scalar variable. This is necessary for writing code that -traverses every element of an array of arrays (*note Arrays of -Arrays::). +`gawk' provides two functions that lets you distinguish the type of a +variable. This is necessary for writing code that traverses every +element of an array of arrays (*note Arrays of Arrays::), and in other +contexts. `isarray(X)' Return a true value if X is an array. Otherwise, return false. +`typeof(X)' + Return one of the following strings, depending upon the type of X: + + `"array"' + X is an array. + + `"regexp"' + X is a strongly typed regexp (*note Strong Regexp + Constants::). + + `"scalar_n"' + X is a number. + + `"scalar_s"' + X is a string. + + `"untyped"' + X has not yet been given a type. + `isarray()' is meant for use in two circumstances. The first is when traversing a multidimensional array: you can test if an element is itself an array or not. The second is inside the body of a @@ -13520,6 +13607,14 @@ test if a parameter is an array or not. variable that has not been previously used to `isarray()', `gawk' ends up turning it into a scalar. + The `typeof()' function is general; it allows you to determine if a +variable or function parameter is a scalar, an array, or a strongly +typed regexp. + + `isarray()' is deprecated; you should use `typeof()' instead. You +should replace any existing uses of `isarray(var)' in your code with +`typeof(var) == "array"'. + File: gawk.info, Node: I18N Functions, Prev: Type Functions, Up: Built-in @@ -34728,6 +34823,8 @@ Index * trunc-mod operation: Arithmetic Ops. (line 66) * truth values: Truth Values. (line 6) * type conversion: Strings And Numbers. (line 21) +* type, of variable: Type Functions. (line 14) +* typeof: Type Functions. (line 14) * u debugger command (alias for until): Debugger Execution Control. (line 83) * unassigned array elements: Reference to Elements. @@ -34774,6 +34871,7 @@ Index * values, numeric: Basic Data Typing. (line 13) * values, string: Basic Data Typing. (line 13) * variable assignments and input files: Other Arguments. (line 26) +* variable type: Type Functions. (line 14) * variable typing: Typing and Comparison. (line 9) * variables <1>: Basic Data Typing. (line 6) @@ -34897,563 +34995,564 @@ Index Tag Table: Node: Top1204 -Node: Foreword342451 -Node: Foreword446895 -Node: Preface48426 -Ref: Preface-Footnote-151297 -Ref: Preface-Footnote-251404 -Ref: Preface-Footnote-351637 -Node: History51779 -Node: Names54130 -Ref: Names-Footnote-155224 -Node: This Manual55370 -Ref: This Manual-Footnote-161870 -Node: Conventions61970 -Node: Manual History64307 -Ref: Manual History-Footnote-167300 -Ref: Manual History-Footnote-267341 -Node: How To Contribute67415 -Node: Acknowledgments68544 -Node: Getting Started73410 -Node: Running gawk75849 -Node: One-shot77039 -Node: Read Terminal78303 -Node: Long80334 -Node: Executable Scripts81847 -Ref: Executable Scripts-Footnote-184636 -Node: Comments84739 -Node: Quoting87221 -Node: DOS Quoting92739 -Node: Sample Data Files93414 -Node: Very Simple96009 -Node: Two Rules100908 -Node: More Complex102794 -Node: Statements/Lines105656 -Ref: Statements/Lines-Footnote-1110111 -Node: Other Features110376 -Node: When111312 -Ref: When-Footnote-1113066 -Node: Intro Summary113131 -Node: Invoking Gawk114015 -Node: Command Line115529 -Node: Options116327 -Ref: Options-Footnote-1132122 -Ref: Options-Footnote-2132351 -Node: Other Arguments132376 -Node: Naming Standard Input135324 -Node: Environment Variables136417 -Node: AWKPATH Variable136975 -Ref: AWKPATH Variable-Footnote-1140382 -Ref: AWKPATH Variable-Footnote-2140427 -Node: AWKLIBPATH Variable140687 -Node: Other Environment Variables141943 -Node: Exit Status145574 -Node: Include Files146250 -Node: Loading Shared Libraries149839 -Node: Obsolete151266 -Node: Undocumented151958 -Node: Invoking Summary152225 -Node: Regexp153888 -Node: Regexp Usage155342 -Node: Escape Sequences157379 -Node: Regexp Operators163608 -Ref: Regexp Operators-Footnote-1171018 -Ref: Regexp Operators-Footnote-2171165 -Node: Bracket Expressions171263 -Ref: table-char-classes173278 -Node: Leftmost Longest176220 -Node: Computed Regexps177522 -Node: GNU Regexp Operators180951 -Node: Case-sensitivity184623 -Ref: Case-sensitivity-Footnote-1187508 -Ref: Case-sensitivity-Footnote-2187743 -Node: Regexp Summary187851 -Node: Reading Files189318 -Node: Records191480 -Node: awk split records192213 -Node: gawk split records197142 -Ref: gawk split records-Footnote-1201681 -Node: Fields201718 -Ref: Fields-Footnote-1204496 -Node: Nonconstant Fields204582 -Ref: Nonconstant Fields-Footnote-1206820 -Node: Changing Fields207023 -Node: Field Separators212954 -Node: Default Field Splitting215658 -Node: Regexp Field Splitting216775 -Node: Single Character Fields220125 -Node: Command Line Field Separator221184 -Node: Full Line Fields224401 -Ref: Full Line Fields-Footnote-1225922 -Ref: Full Line Fields-Footnote-2225968 -Node: Field Splitting Summary226069 -Node: Constant Size228143 -Node: Splitting By Content232722 -Ref: Splitting By Content-Footnote-1236687 -Node: Multiple Line236850 -Ref: Multiple Line-Footnote-1242731 -Node: Getline242910 -Node: Plain Getline245380 -Node: Getline/Variable248020 -Node: Getline/File249169 -Node: Getline/Variable/File250554 -Ref: Getline/Variable/File-Footnote-1252157 -Node: Getline/Pipe252244 -Node: Getline/Variable/Pipe254922 -Node: Getline/Coprocess256053 -Node: Getline/Variable/Coprocess257317 -Node: Getline Notes258056 -Node: Getline Summary260850 -Ref: table-getline-variants261262 -Node: Read Timeout262091 -Ref: Read Timeout-Footnote-1265994 -Node: Retrying Input266052 -Node: Command-line directories267251 -Node: Input Summary268158 -Node: Input Exercises271543 -Node: Printing272271 -Node: Print274106 -Node: Print Examples275563 -Node: Output Separators278342 -Node: OFMT280360 -Node: Printf281715 -Node: Basic Printf282500 -Node: Control Letters284072 -Node: Format Modifiers288057 -Node: Printf Examples294063 -Node: Redirection296549 -Node: Special FD303387 -Ref: Special FD-Footnote-1306553 -Node: Special Files306627 -Node: Other Inherited Files307244 -Node: Special Network308244 -Node: Special Caveats309106 -Node: Close Files And Pipes310055 -Ref: Close Files And Pipes-Footnote-1317240 -Ref: Close Files And Pipes-Footnote-2317388 -Node: Nonfatal317538 -Node: Output Summary319863 -Node: Output Exercises321084 -Node: Expressions321764 -Node: Values322953 -Node: Constants323630 -Node: Scalar Constants324321 -Ref: Scalar Constants-Footnote-1325183 -Node: Nondecimal-numbers325433 -Node: Regexp Constants328443 -Node: Using Constant Regexps328969 -Node: Variables332132 -Node: Using Variables332789 -Node: Assignment Options334700 -Node: Conversion336575 -Node: Strings And Numbers337099 -Ref: Strings And Numbers-Footnote-1340164 -Node: Locale influences conversions340273 -Ref: table-locale-affects343019 -Node: All Operators343611 -Node: Arithmetic Ops344240 -Node: Concatenation346745 -Ref: Concatenation-Footnote-1349564 -Node: Assignment Ops349671 -Ref: table-assign-ops354650 -Node: Increment Ops355960 -Node: Truth Values and Conditions359391 -Node: Truth Values360474 -Node: Typing and Comparison361523 -Node: Variable Typing362339 -Node: Comparison Operators366006 -Ref: table-relational-ops366416 -Node: POSIX String Comparison369911 -Ref: POSIX String Comparison-Footnote-1370983 -Node: Boolean Ops371122 -Ref: Boolean Ops-Footnote-1375600 -Node: Conditional Exp375691 -Node: Function Calls377429 -Node: Precedence381309 -Node: Locales384969 -Node: Expressions Summary386601 -Node: Patterns and Actions389172 -Node: Pattern Overview390292 -Node: Regexp Patterns391971 -Node: Expression Patterns392514 -Node: Ranges396294 -Node: BEGIN/END399401 -Node: Using BEGIN/END400162 -Ref: Using BEGIN/END-Footnote-1402898 -Node: I/O And BEGIN/END403004 -Node: BEGINFILE/ENDFILE405319 -Node: Empty408225 -Node: Using Shell Variables408542 -Node: Action Overview410815 -Node: Statements413141 -Node: If Statement414989 -Node: While Statement416484 -Node: Do Statement418512 -Node: For Statement419660 -Node: Switch Statement422818 -Node: Break Statement425200 -Node: Continue Statement427293 -Node: Next Statement429120 -Node: Nextfile Statement431501 -Node: Exit Statement434129 -Node: Built-in Variables436540 -Node: User-modified437673 -Ref: User-modified-Footnote-1445307 -Node: Auto-set445369 -Ref: Auto-set-Footnote-1459601 -Ref: Auto-set-Footnote-2459806 -Node: ARGC and ARGV459862 -Node: Pattern Action Summary464080 -Node: Arrays466513 -Node: Array Basics467842 -Node: Array Intro468686 -Ref: figure-array-elements470623 -Ref: Array Intro-Footnote-1473246 -Node: Reference to Elements473374 -Node: Assigning Elements475836 -Node: Array Example476327 -Node: Scanning an Array478086 -Node: Controlling Scanning481109 -Ref: Controlling Scanning-Footnote-1486503 -Node: Numeric Array Subscripts486819 -Node: Uninitialized Subscripts489004 -Node: Delete490621 -Ref: Delete-Footnote-1493370 -Node: Multidimensional493427 -Node: Multiscanning496524 -Node: Arrays of Arrays498113 -Node: Arrays Summary502867 -Node: Functions504958 -Node: Built-in505997 -Node: Calling Built-in507075 -Node: Numeric Functions509070 -Ref: Numeric Functions-Footnote-1513903 -Ref: Numeric Functions-Footnote-2514260 -Ref: Numeric Functions-Footnote-3514308 -Node: String Functions514580 -Ref: String Functions-Footnote-1538081 -Ref: String Functions-Footnote-2538210 -Ref: String Functions-Footnote-3538458 -Node: Gory Details538545 -Ref: table-sub-escapes540326 -Ref: table-sub-proposed541841 -Ref: table-posix-sub543203 -Ref: table-gensub-escapes544740 -Ref: Gory Details-Footnote-1545573 -Node: I/O Functions545724 -Ref: I/O Functions-Footnote-1552960 -Node: Time Functions553107 -Ref: Time Functions-Footnote-1563616 -Ref: Time Functions-Footnote-2563684 -Ref: Time Functions-Footnote-3563842 -Ref: Time Functions-Footnote-4563953 -Ref: Time Functions-Footnote-5564065 -Ref: Time Functions-Footnote-6564292 -Node: Bitwise Functions564558 -Ref: table-bitwise-ops565120 -Ref: Bitwise Functions-Footnote-1569448 -Node: Type Functions569620 -Node: I18N Functions570772 -Node: User-defined572419 -Node: Definition Syntax573224 -Ref: Definition Syntax-Footnote-1578883 -Node: Function Example578954 -Ref: Function Example-Footnote-1581875 -Node: Function Caveats581897 -Node: Calling A Function582415 -Node: Variable Scope583373 -Node: Pass By Value/Reference586366 -Node: Return Statement589863 -Node: Dynamic Typing592842 -Node: Indirect Calls593771 -Ref: Indirect Calls-Footnote-1604014 -Node: Functions Summary604142 -Node: Library Functions606844 -Ref: Library Functions-Footnote-1610452 -Ref: Library Functions-Footnote-2610595 -Node: Library Names610766 -Ref: Library Names-Footnote-1614224 -Ref: Library Names-Footnote-2614447 -Node: General Functions614533 -Node: Strtonum Function615636 -Node: Assert Function618658 -Node: Round Function621982 -Node: Cliff Random Function623523 -Node: Ordinal Functions624539 -Ref: Ordinal Functions-Footnote-1627602 -Ref: Ordinal Functions-Footnote-2627854 -Node: Join Function628065 -Ref: Join Function-Footnote-1629835 -Node: Getlocaltime Function630035 -Node: Readfile Function633779 -Node: Shell Quoting635751 -Node: Data File Management637152 -Node: Filetrans Function637784 -Node: Rewind Function641880 -Node: File Checking643266 -Ref: File Checking-Footnote-1644599 -Node: Empty Files644800 -Node: Ignoring Assigns646779 -Node: Getopt Function648329 -Ref: Getopt Function-Footnote-1659793 -Node: Passwd Functions659993 -Ref: Passwd Functions-Footnote-1668833 -Node: Group Functions668921 -Ref: Group Functions-Footnote-1676818 -Node: Walking Arrays677023 -Node: Library Functions Summary680029 -Node: Library Exercises681431 -Node: Sample Programs682711 -Node: Running Examples683481 -Node: Clones684209 -Node: Cut Program685433 -Node: Egrep Program695153 -Ref: Egrep Program-Footnote-1702656 -Node: Id Program702766 -Node: Split Program706442 -Ref: Split Program-Footnote-1709896 -Node: Tee Program710024 -Node: Uniq Program712813 -Node: Wc Program720232 -Ref: Wc Program-Footnote-1724482 -Node: Miscellaneous Programs724576 -Node: Dupword Program725789 -Node: Alarm Program727820 -Node: Translate Program732625 -Ref: Translate Program-Footnote-1737188 -Node: Labels Program737458 -Ref: Labels Program-Footnote-1740809 -Node: Word Sorting740893 -Node: History Sorting744963 -Node: Extract Program746798 -Node: Simple Sed754322 -Node: Igawk Program757392 -Ref: Igawk Program-Footnote-1771718 -Ref: Igawk Program-Footnote-2771919 -Ref: Igawk Program-Footnote-3772041 -Node: Anagram Program772156 -Node: Signature Program775217 -Node: Programs Summary776464 -Node: Programs Exercises777685 -Ref: Programs Exercises-Footnote-1781816 -Node: Advanced Features781907 -Node: Nondecimal Data783889 -Node: Array Sorting785479 -Node: Controlling Array Traversal786179 -Ref: Controlling Array Traversal-Footnote-1794545 -Node: Array Sorting Functions794663 -Ref: Array Sorting Functions-Footnote-1798549 -Node: Two-way I/O798745 -Ref: Two-way I/O-Footnote-1803690 -Ref: Two-way I/O-Footnote-2803876 -Node: TCP/IP Networking803958 -Node: Profiling806830 -Node: Advanced Features Summary815101 -Node: Internationalization817034 -Node: I18N and L10N818514 -Node: Explaining gettext819200 -Ref: Explaining gettext-Footnote-1824225 -Ref: Explaining gettext-Footnote-2824409 -Node: Programmer i18n824574 -Ref: Programmer i18n-Footnote-1829450 -Node: Translator i18n829499 -Node: String Extraction830293 -Ref: String Extraction-Footnote-1831424 -Node: Printf Ordering831510 -Ref: Printf Ordering-Footnote-1834296 -Node: I18N Portability834360 -Ref: I18N Portability-Footnote-1836816 -Node: I18N Example836879 -Ref: I18N Example-Footnote-1839682 -Node: Gawk I18N839754 -Node: I18N Summary840398 -Node: Debugger841738 -Node: Debugging842760 -Node: Debugging Concepts843201 -Node: Debugging Terms845011 -Node: Awk Debugging847583 -Node: Sample Debugging Session848489 -Node: Debugger Invocation849023 -Node: Finding The Bug850408 -Node: List of Debugger Commands856887 -Node: Breakpoint Control858219 -Node: Debugger Execution Control861896 -Node: Viewing And Changing Data865255 -Node: Execution Stack868631 -Node: Debugger Info870266 -Node: Miscellaneous Debugger Commands874311 -Node: Readline Support879312 -Node: Limitations880206 -Node: Debugging Summary882321 -Node: Arbitrary Precision Arithmetic883495 -Node: Computer Arithmetic884911 -Ref: table-numeric-ranges888488 -Ref: Computer Arithmetic-Footnote-1889012 -Node: Math Definitions889069 -Ref: table-ieee-formats892364 -Ref: Math Definitions-Footnote-1892968 -Node: MPFR features893073 -Node: FP Math Caution894744 -Ref: FP Math Caution-Footnote-1895794 -Node: Inexactness of computations896163 -Node: Inexact representation897122 -Node: Comparing FP Values898480 -Node: Errors accumulate899562 -Node: Getting Accuracy900994 -Node: Try To Round903698 -Node: Setting precision904597 -Ref: table-predefined-precision-strings905281 -Node: Setting the rounding mode907110 -Ref: table-gawk-rounding-modes907474 -Ref: Setting the rounding mode-Footnote-1910926 -Node: Arbitrary Precision Integers911105 -Ref: Arbitrary Precision Integers-Footnote-1916021 -Node: POSIX Floating Point Problems916170 -Ref: POSIX Floating Point Problems-Footnote-1920049 -Node: Floating point summary920087 -Node: Dynamic Extensions922274 -Node: Extension Intro923826 -Node: Plugin License925091 -Node: Extension Mechanism Outline925888 -Ref: figure-load-extension926316 -Ref: figure-register-new-function927796 -Ref: figure-call-new-function928800 -Node: Extension API Description930787 -Node: Extension API Functions Introduction932321 -Node: General Data Types937190 -Ref: General Data Types-Footnote-1943090 -Node: Memory Allocation Functions943389 -Ref: Memory Allocation Functions-Footnote-1946228 -Node: Constructor Functions946327 -Node: Registration Functions948066 -Node: Extension Functions948751 -Node: Exit Callback Functions951048 -Node: Extension Version String952296 -Node: Input Parsers952959 -Node: Output Wrappers962834 -Node: Two-way processors967347 -Node: Printing Messages969610 -Ref: Printing Messages-Footnote-1970686 -Node: Updating `ERRNO'970838 -Node: Requesting Values971578 -Ref: table-value-types-returned972305 -Node: Accessing Parameters973262 -Node: Symbol Table Access974496 -Node: Symbol table by name975010 -Node: Symbol table by cookie977030 -Ref: Symbol table by cookie-Footnote-1981175 -Node: Cached values981238 -Ref: Cached values-Footnote-1984734 -Node: Array Manipulation984825 -Ref: Array Manipulation-Footnote-1985915 -Node: Array Data Types985952 -Ref: Array Data Types-Footnote-1988607 -Node: Array Functions988699 -Node: Flattening Arrays992558 -Node: Creating Arrays999460 -Node: Redirection API1004231 -Node: Extension API Variables1007056 -Node: Extension Versioning1007689 -Node: Extension API Informational Variables1009580 -Node: Extension API Boilerplate1010645 -Node: Finding Extensions1014454 -Node: Extension Example1015014 -Node: Internal File Description1015786 -Node: Internal File Ops1019853 -Ref: Internal File Ops-Footnote-11031604 -Node: Using Internal File Ops1031744 -Ref: Using Internal File Ops-Footnote-11034127 -Node: Extension Samples1034400 -Node: Extension Sample File Functions1035928 -Node: Extension Sample Fnmatch1043609 -Node: Extension Sample Fork1045097 -Node: Extension Sample Inplace1046312 -Node: Extension Sample Ord1048398 -Node: Extension Sample Readdir1049234 -Ref: table-readdir-file-types1050111 -Node: Extension Sample Revout1050922 -Node: Extension Sample Rev2way1051511 -Node: Extension Sample Read write array1052251 -Node: Extension Sample Readfile1054191 -Node: Extension Sample Time1055286 -Node: Extension Sample API Tests1056634 -Node: gawkextlib1057125 -Node: Extension summary1059572 -Node: Extension Exercises1063261 -Node: Language History1064757 -Node: V7/SVR3.11066413 -Node: SVR41068566 -Node: POSIX1070000 -Node: BTL1071381 -Node: POSIX/GNU1072112 -Node: Feature History1077951 -Node: Common Extensions1091941 -Node: Ranges and Locales1093313 -Ref: Ranges and Locales-Footnote-11097932 -Ref: Ranges and Locales-Footnote-21097959 -Ref: Ranges and Locales-Footnote-31098194 -Node: Contributors1098415 -Node: History summary1103955 -Node: Installation1105334 -Node: Gawk Distribution1106280 -Node: Getting1106764 -Node: Extracting1107587 -Node: Distribution contents1109224 -Node: Unix Installation1115326 -Node: Quick Installation1116009 -Node: Shell Startup Files1118420 -Node: Additional Configuration Options1119499 -Node: Configuration Philosophy1121303 -Node: Non-Unix Installation1123672 -Node: PC Installation1124130 -Node: PC Binary Installation1125450 -Node: PC Compiling1127298 -Ref: PC Compiling-Footnote-11130319 -Node: PC Testing1130428 -Node: PC Using1131604 -Node: Cygwin1135719 -Node: MSYS1136489 -Node: VMS Installation1136990 -Node: VMS Compilation1137782 -Ref: VMS Compilation-Footnote-11139011 -Node: VMS Dynamic Extensions1139069 -Node: VMS Installation Details1140753 -Node: VMS Running1143004 -Node: VMS GNV1145844 -Node: VMS Old Gawk1146579 -Node: Bugs1147049 -Node: Other Versions1150938 -Node: Installation summary1157372 -Node: Notes1158431 -Node: Compatibility Mode1159296 -Node: Additions1160078 -Node: Accessing The Source1161003 -Node: Adding Code1162438 -Node: New Ports1168595 -Node: Derived Files1173077 -Ref: Derived Files-Footnote-11178552 -Ref: Derived Files-Footnote-21178586 -Ref: Derived Files-Footnote-31179182 -Node: Future Extensions1179296 -Node: Implementation Limitations1179902 -Node: Extension Design1181150 -Node: Old Extension Problems1182304 -Ref: Old Extension Problems-Footnote-11183821 -Node: Extension New Mechanism Goals1183878 -Ref: Extension New Mechanism Goals-Footnote-11187238 -Node: Extension Other Design Decisions1187427 -Node: Extension Future Growth1189535 -Node: Old Extension Mechanism1190371 -Node: Notes summary1192133 -Node: Basic Concepts1193319 -Node: Basic High Level1194000 -Ref: figure-general-flow1194272 -Ref: figure-process-flow1194871 -Ref: Basic High Level-Footnote-11198100 -Node: Basic Data Typing1198285 -Node: Glossary1201613 -Node: Copying1233542 -Node: GNU Free Documentation License1271098 -Node: Index1296234 +Node: Foreword342524 +Node: Foreword446968 +Node: Preface48499 +Ref: Preface-Footnote-151370 +Ref: Preface-Footnote-251477 +Ref: Preface-Footnote-351710 +Node: History51852 +Node: Names54203 +Ref: Names-Footnote-155297 +Node: This Manual55443 +Ref: This Manual-Footnote-161943 +Node: Conventions62043 +Node: Manual History64380 +Ref: Manual History-Footnote-167373 +Ref: Manual History-Footnote-267414 +Node: How To Contribute67488 +Node: Acknowledgments68617 +Node: Getting Started73483 +Node: Running gawk75922 +Node: One-shot77112 +Node: Read Terminal78376 +Node: Long80407 +Node: Executable Scripts81920 +Ref: Executable Scripts-Footnote-184709 +Node: Comments84812 +Node: Quoting87294 +Node: DOS Quoting92812 +Node: Sample Data Files93487 +Node: Very Simple96082 +Node: Two Rules100981 +Node: More Complex102867 +Node: Statements/Lines105729 +Ref: Statements/Lines-Footnote-1110184 +Node: Other Features110449 +Node: When111385 +Ref: When-Footnote-1113139 +Node: Intro Summary113204 +Node: Invoking Gawk114088 +Node: Command Line115602 +Node: Options116400 +Ref: Options-Footnote-1132195 +Ref: Options-Footnote-2132424 +Node: Other Arguments132449 +Node: Naming Standard Input135397 +Node: Environment Variables136490 +Node: AWKPATH Variable137048 +Ref: AWKPATH Variable-Footnote-1140455 +Ref: AWKPATH Variable-Footnote-2140500 +Node: AWKLIBPATH Variable140760 +Node: Other Environment Variables142016 +Node: Exit Status145647 +Node: Include Files146323 +Node: Loading Shared Libraries149912 +Node: Obsolete151339 +Node: Undocumented152031 +Node: Invoking Summary152298 +Node: Regexp153961 +Node: Regexp Usage155480 +Node: Escape Sequences157517 +Node: Regexp Operators163746 +Ref: Regexp Operators-Footnote-1171156 +Ref: Regexp Operators-Footnote-2171303 +Node: Bracket Expressions171401 +Ref: table-char-classes173416 +Node: Leftmost Longest176358 +Node: Computed Regexps177660 +Node: GNU Regexp Operators181089 +Node: Case-sensitivity184761 +Ref: Case-sensitivity-Footnote-1187655 +Ref: Case-sensitivity-Footnote-2187890 +Node: Strong Regexp Constants187998 +Node: Regexp Summary190754 +Node: Reading Files192361 +Node: Records194523 +Node: awk split records195256 +Node: gawk split records200185 +Ref: gawk split records-Footnote-1204724 +Node: Fields204761 +Ref: Fields-Footnote-1207539 +Node: Nonconstant Fields207625 +Ref: Nonconstant Fields-Footnote-1209863 +Node: Changing Fields210066 +Node: Field Separators215997 +Node: Default Field Splitting218701 +Node: Regexp Field Splitting219818 +Node: Single Character Fields223168 +Node: Command Line Field Separator224227 +Node: Full Line Fields227444 +Ref: Full Line Fields-Footnote-1228965 +Ref: Full Line Fields-Footnote-2229011 +Node: Field Splitting Summary229112 +Node: Constant Size231186 +Node: Splitting By Content235765 +Ref: Splitting By Content-Footnote-1239730 +Node: Multiple Line239893 +Ref: Multiple Line-Footnote-1245774 +Node: Getline245953 +Node: Plain Getline248423 +Node: Getline/Variable251063 +Node: Getline/File252212 +Node: Getline/Variable/File253597 +Ref: Getline/Variable/File-Footnote-1255200 +Node: Getline/Pipe255287 +Node: Getline/Variable/Pipe257965 +Node: Getline/Coprocess259096 +Node: Getline/Variable/Coprocess260360 +Node: Getline Notes261099 +Node: Getline Summary263893 +Ref: table-getline-variants264305 +Node: Read Timeout265134 +Ref: Read Timeout-Footnote-1269037 +Node: Retrying Input269095 +Node: Command-line directories270294 +Node: Input Summary271201 +Node: Input Exercises274586 +Node: Printing275314 +Node: Print277149 +Node: Print Examples278606 +Node: Output Separators281385 +Node: OFMT283403 +Node: Printf284758 +Node: Basic Printf285543 +Node: Control Letters287115 +Node: Format Modifiers291100 +Node: Printf Examples297106 +Node: Redirection299592 +Node: Special FD306430 +Ref: Special FD-Footnote-1309596 +Node: Special Files309670 +Node: Other Inherited Files310287 +Node: Special Network311287 +Node: Special Caveats312149 +Node: Close Files And Pipes313098 +Ref: Close Files And Pipes-Footnote-1320283 +Ref: Close Files And Pipes-Footnote-2320431 +Node: Nonfatal320581 +Node: Output Summary322906 +Node: Output Exercises324127 +Node: Expressions324807 +Node: Values325996 +Node: Constants326673 +Node: Scalar Constants327364 +Ref: Scalar Constants-Footnote-1328226 +Node: Nondecimal-numbers328476 +Node: Regexp Constants331486 +Node: Using Constant Regexps332012 +Node: Variables335175 +Node: Using Variables335832 +Node: Assignment Options337743 +Node: Conversion339618 +Node: Strings And Numbers340142 +Ref: Strings And Numbers-Footnote-1343207 +Node: Locale influences conversions343316 +Ref: table-locale-affects346062 +Node: All Operators346654 +Node: Arithmetic Ops347283 +Node: Concatenation349788 +Ref: Concatenation-Footnote-1352607 +Node: Assignment Ops352714 +Ref: table-assign-ops357693 +Node: Increment Ops359003 +Node: Truth Values and Conditions362434 +Node: Truth Values363517 +Node: Typing and Comparison364566 +Node: Variable Typing365382 +Node: Comparison Operators369049 +Ref: table-relational-ops369459 +Node: POSIX String Comparison372954 +Ref: POSIX String Comparison-Footnote-1374026 +Node: Boolean Ops374165 +Ref: Boolean Ops-Footnote-1378643 +Node: Conditional Exp378734 +Node: Function Calls380472 +Node: Precedence384352 +Node: Locales388012 +Node: Expressions Summary389644 +Node: Patterns and Actions392215 +Node: Pattern Overview393335 +Node: Regexp Patterns395014 +Node: Expression Patterns395557 +Node: Ranges399337 +Node: BEGIN/END402444 +Node: Using BEGIN/END403205 +Ref: Using BEGIN/END-Footnote-1405941 +Node: I/O And BEGIN/END406047 +Node: BEGINFILE/ENDFILE408362 +Node: Empty411268 +Node: Using Shell Variables411585 +Node: Action Overview413858 +Node: Statements416184 +Node: If Statement418032 +Node: While Statement419527 +Node: Do Statement421555 +Node: For Statement422703 +Node: Switch Statement425861 +Node: Break Statement428243 +Node: Continue Statement430336 +Node: Next Statement432163 +Node: Nextfile Statement434544 +Node: Exit Statement437172 +Node: Built-in Variables439583 +Node: User-modified440716 +Ref: User-modified-Footnote-1448350 +Node: Auto-set448412 +Ref: Auto-set-Footnote-1462644 +Ref: Auto-set-Footnote-2462849 +Node: ARGC and ARGV462905 +Node: Pattern Action Summary467123 +Node: Arrays469556 +Node: Array Basics470885 +Node: Array Intro471729 +Ref: figure-array-elements473666 +Ref: Array Intro-Footnote-1476289 +Node: Reference to Elements476417 +Node: Assigning Elements478879 +Node: Array Example479370 +Node: Scanning an Array481129 +Node: Controlling Scanning484152 +Ref: Controlling Scanning-Footnote-1489546 +Node: Numeric Array Subscripts489862 +Node: Uninitialized Subscripts492047 +Node: Delete493664 +Ref: Delete-Footnote-1496413 +Node: Multidimensional496470 +Node: Multiscanning499567 +Node: Arrays of Arrays501156 +Node: Arrays Summary505910 +Node: Functions508001 +Node: Built-in509040 +Node: Calling Built-in510118 +Node: Numeric Functions512113 +Ref: Numeric Functions-Footnote-1516946 +Ref: Numeric Functions-Footnote-2517303 +Ref: Numeric Functions-Footnote-3517351 +Node: String Functions517623 +Ref: String Functions-Footnote-1541124 +Ref: String Functions-Footnote-2541253 +Ref: String Functions-Footnote-3541501 +Node: Gory Details541588 +Ref: table-sub-escapes543369 +Ref: table-sub-proposed544884 +Ref: table-posix-sub546246 +Ref: table-gensub-escapes547783 +Ref: Gory Details-Footnote-1548616 +Node: I/O Functions548767 +Ref: I/O Functions-Footnote-1556003 +Node: Time Functions556150 +Ref: Time Functions-Footnote-1566659 +Ref: Time Functions-Footnote-2566727 +Ref: Time Functions-Footnote-3566885 +Ref: Time Functions-Footnote-4566996 +Ref: Time Functions-Footnote-5567108 +Ref: Time Functions-Footnote-6567335 +Node: Bitwise Functions567601 +Ref: table-bitwise-ops568163 +Ref: Bitwise Functions-Footnote-1572491 +Node: Type Functions572663 +Node: I18N Functions574516 +Node: User-defined576163 +Node: Definition Syntax576968 +Ref: Definition Syntax-Footnote-1582627 +Node: Function Example582698 +Ref: Function Example-Footnote-1585619 +Node: Function Caveats585641 +Node: Calling A Function586159 +Node: Variable Scope587117 +Node: Pass By Value/Reference590110 +Node: Return Statement593607 +Node: Dynamic Typing596586 +Node: Indirect Calls597515 +Ref: Indirect Calls-Footnote-1607758 +Node: Functions Summary607886 +Node: Library Functions610588 +Ref: Library Functions-Footnote-1614196 +Ref: Library Functions-Footnote-2614339 +Node: Library Names614510 +Ref: Library Names-Footnote-1617968 +Ref: Library Names-Footnote-2618191 +Node: General Functions618277 +Node: Strtonum Function619380 +Node: Assert Function622402 +Node: Round Function625726 +Node: Cliff Random Function627267 +Node: Ordinal Functions628283 +Ref: Ordinal Functions-Footnote-1631346 +Ref: Ordinal Functions-Footnote-2631598 +Node: Join Function631809 +Ref: Join Function-Footnote-1633579 +Node: Getlocaltime Function633779 +Node: Readfile Function637523 +Node: Shell Quoting639495 +Node: Data File Management640896 +Node: Filetrans Function641528 +Node: Rewind Function645624 +Node: File Checking647010 +Ref: File Checking-Footnote-1648343 +Node: Empty Files648544 +Node: Ignoring Assigns650523 +Node: Getopt Function652073 +Ref: Getopt Function-Footnote-1663537 +Node: Passwd Functions663737 +Ref: Passwd Functions-Footnote-1672577 +Node: Group Functions672665 +Ref: Group Functions-Footnote-1680562 +Node: Walking Arrays680767 +Node: Library Functions Summary683773 +Node: Library Exercises685175 +Node: Sample Programs686455 +Node: Running Examples687225 +Node: Clones687953 +Node: Cut Program689177 +Node: Egrep Program698897 +Ref: Egrep Program-Footnote-1706400 +Node: Id Program706510 +Node: Split Program710186 +Ref: Split Program-Footnote-1713640 +Node: Tee Program713768 +Node: Uniq Program716557 +Node: Wc Program723976 +Ref: Wc Program-Footnote-1728226 +Node: Miscellaneous Programs728320 +Node: Dupword Program729533 +Node: Alarm Program731564 +Node: Translate Program736369 +Ref: Translate Program-Footnote-1740932 +Node: Labels Program741202 +Ref: Labels Program-Footnote-1744553 +Node: Word Sorting744637 +Node: History Sorting748707 +Node: Extract Program750542 +Node: Simple Sed758066 +Node: Igawk Program761136 +Ref: Igawk Program-Footnote-1775462 +Ref: Igawk Program-Footnote-2775663 +Ref: Igawk Program-Footnote-3775785 +Node: Anagram Program775900 +Node: Signature Program778961 +Node: Programs Summary780208 +Node: Programs Exercises781429 +Ref: Programs Exercises-Footnote-1785560 +Node: Advanced Features785651 +Node: Nondecimal Data787633 +Node: Array Sorting789223 +Node: Controlling Array Traversal789923 +Ref: Controlling Array Traversal-Footnote-1798289 +Node: Array Sorting Functions798407 +Ref: Array Sorting Functions-Footnote-1802293 +Node: Two-way I/O802489 +Ref: Two-way I/O-Footnote-1807434 +Ref: Two-way I/O-Footnote-2807620 +Node: TCP/IP Networking807702 +Node: Profiling810574 +Node: Advanced Features Summary818845 +Node: Internationalization820778 +Node: I18N and L10N822258 +Node: Explaining gettext822944 +Ref: Explaining gettext-Footnote-1827969 +Ref: Explaining gettext-Footnote-2828153 +Node: Programmer i18n828318 +Ref: Programmer i18n-Footnote-1833194 +Node: Translator i18n833243 +Node: String Extraction834037 +Ref: String Extraction-Footnote-1835168 +Node: Printf Ordering835254 +Ref: Printf Ordering-Footnote-1838040 +Node: I18N Portability838104 +Ref: I18N Portability-Footnote-1840560 +Node: I18N Example840623 +Ref: I18N Example-Footnote-1843426 +Node: Gawk I18N843498 +Node: I18N Summary844142 +Node: Debugger845482 +Node: Debugging846504 +Node: Debugging Concepts846945 +Node: Debugging Terms848755 +Node: Awk Debugging851327 +Node: Sample Debugging Session852233 +Node: Debugger Invocation852767 +Node: Finding The Bug854152 +Node: List of Debugger Commands860631 +Node: Breakpoint Control861963 +Node: Debugger Execution Control865640 +Node: Viewing And Changing Data868999 +Node: Execution Stack872375 +Node: Debugger Info874010 +Node: Miscellaneous Debugger Commands878055 +Node: Readline Support883056 +Node: Limitations883950 +Node: Debugging Summary886065 +Node: Arbitrary Precision Arithmetic887239 +Node: Computer Arithmetic888655 +Ref: table-numeric-ranges892232 +Ref: Computer Arithmetic-Footnote-1892756 +Node: Math Definitions892813 +Ref: table-ieee-formats896108 +Ref: Math Definitions-Footnote-1896712 +Node: MPFR features896817 +Node: FP Math Caution898488 +Ref: FP Math Caution-Footnote-1899538 +Node: Inexactness of computations899907 +Node: Inexact representation900866 +Node: Comparing FP Values902224 +Node: Errors accumulate903306 +Node: Getting Accuracy904738 +Node: Try To Round907442 +Node: Setting precision908341 +Ref: table-predefined-precision-strings909025 +Node: Setting the rounding mode910854 +Ref: table-gawk-rounding-modes911218 +Ref: Setting the rounding mode-Footnote-1914670 +Node: Arbitrary Precision Integers914849 +Ref: Arbitrary Precision Integers-Footnote-1919765 +Node: POSIX Floating Point Problems919914 +Ref: POSIX Floating Point Problems-Footnote-1923793 +Node: Floating point summary923831 +Node: Dynamic Extensions926018 +Node: Extension Intro927570 +Node: Plugin License928835 +Node: Extension Mechanism Outline929632 +Ref: figure-load-extension930060 +Ref: figure-register-new-function931540 +Ref: figure-call-new-function932544 +Node: Extension API Description934531 +Node: Extension API Functions Introduction936065 +Node: General Data Types940934 +Ref: General Data Types-Footnote-1946834 +Node: Memory Allocation Functions947133 +Ref: Memory Allocation Functions-Footnote-1949972 +Node: Constructor Functions950071 +Node: Registration Functions951810 +Node: Extension Functions952495 +Node: Exit Callback Functions954792 +Node: Extension Version String956040 +Node: Input Parsers956703 +Node: Output Wrappers966578 +Node: Two-way processors971091 +Node: Printing Messages973354 +Ref: Printing Messages-Footnote-1974430 +Node: Updating `ERRNO'974582 +Node: Requesting Values975322 +Ref: table-value-types-returned976049 +Node: Accessing Parameters977006 +Node: Symbol Table Access978240 +Node: Symbol table by name978754 +Node: Symbol table by cookie980774 +Ref: Symbol table by cookie-Footnote-1984919 +Node: Cached values984982 +Ref: Cached values-Footnote-1988478 +Node: Array Manipulation988569 +Ref: Array Manipulation-Footnote-1989659 +Node: Array Data Types989696 +Ref: Array Data Types-Footnote-1992351 +Node: Array Functions992443 +Node: Flattening Arrays996302 +Node: Creating Arrays1003204 +Node: Redirection API1007975 +Node: Extension API Variables1010800 +Node: Extension Versioning1011433 +Node: Extension API Informational Variables1013324 +Node: Extension API Boilerplate1014389 +Node: Finding Extensions1018198 +Node: Extension Example1018758 +Node: Internal File Description1019530 +Node: Internal File Ops1023597 +Ref: Internal File Ops-Footnote-11035348 +Node: Using Internal File Ops1035488 +Ref: Using Internal File Ops-Footnote-11037871 +Node: Extension Samples1038144 +Node: Extension Sample File Functions1039672 +Node: Extension Sample Fnmatch1047353 +Node: Extension Sample Fork1048841 +Node: Extension Sample Inplace1050056 +Node: Extension Sample Ord1052142 +Node: Extension Sample Readdir1052978 +Ref: table-readdir-file-types1053855 +Node: Extension Sample Revout1054666 +Node: Extension Sample Rev2way1055255 +Node: Extension Sample Read write array1055995 +Node: Extension Sample Readfile1057935 +Node: Extension Sample Time1059030 +Node: Extension Sample API Tests1060378 +Node: gawkextlib1060869 +Node: Extension summary1063316 +Node: Extension Exercises1067005 +Node: Language History1068501 +Node: V7/SVR3.11070157 +Node: SVR41072310 +Node: POSIX1073744 +Node: BTL1075125 +Node: POSIX/GNU1075856 +Node: Feature History1081695 +Node: Common Extensions1095685 +Node: Ranges and Locales1097057 +Ref: Ranges and Locales-Footnote-11101676 +Ref: Ranges and Locales-Footnote-21101703 +Ref: Ranges and Locales-Footnote-31101938 +Node: Contributors1102159 +Node: History summary1107699 +Node: Installation1109078 +Node: Gawk Distribution1110024 +Node: Getting1110508 +Node: Extracting1111331 +Node: Distribution contents1112968 +Node: Unix Installation1119070 +Node: Quick Installation1119753 +Node: Shell Startup Files1122164 +Node: Additional Configuration Options1123243 +Node: Configuration Philosophy1125047 +Node: Non-Unix Installation1127416 +Node: PC Installation1127874 +Node: PC Binary Installation1129194 +Node: PC Compiling1131042 +Ref: PC Compiling-Footnote-11134063 +Node: PC Testing1134172 +Node: PC Using1135348 +Node: Cygwin1139463 +Node: MSYS1140233 +Node: VMS Installation1140734 +Node: VMS Compilation1141526 +Ref: VMS Compilation-Footnote-11142755 +Node: VMS Dynamic Extensions1142813 +Node: VMS Installation Details1144497 +Node: VMS Running1146748 +Node: VMS GNV1149588 +Node: VMS Old Gawk1150323 +Node: Bugs1150793 +Node: Other Versions1154682 +Node: Installation summary1161116 +Node: Notes1162175 +Node: Compatibility Mode1163040 +Node: Additions1163822 +Node: Accessing The Source1164747 +Node: Adding Code1166182 +Node: New Ports1172339 +Node: Derived Files1176821 +Ref: Derived Files-Footnote-11182296 +Ref: Derived Files-Footnote-21182330 +Ref: Derived Files-Footnote-31182926 +Node: Future Extensions1183040 +Node: Implementation Limitations1183646 +Node: Extension Design1184894 +Node: Old Extension Problems1186048 +Ref: Old Extension Problems-Footnote-11187565 +Node: Extension New Mechanism Goals1187622 +Ref: Extension New Mechanism Goals-Footnote-11190982 +Node: Extension Other Design Decisions1191171 +Node: Extension Future Growth1193279 +Node: Old Extension Mechanism1194115 +Node: Notes summary1195877 +Node: Basic Concepts1197063 +Node: Basic High Level1197744 +Ref: figure-general-flow1198016 +Ref: figure-process-flow1198615 +Ref: Basic High Level-Footnote-11201844 +Node: Basic Data Typing1202029 +Node: Glossary1205357 +Node: Copying1237286 +Node: GNU Free Documentation License1274842 +Node: Index1299978 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 501aacde..7e53a1e4 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -562,6 +562,7 @@ particular records in a file and perform operations upon them. * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. * Records:: Controlling how data is split into records. @@ -4999,6 +5000,7 @@ regular expressions work, we present more complicated instances. * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. @end menu @@ -6246,6 +6248,85 @@ The value of @code{IGNORECASE} has no effect if @command{gawk} is in compatibility mode (@pxref{Options}). Case is always significant in compatibility mode. +@node Strong Regexp Constants +@section Strongly Typed Regexp Constants + +This @value{SECTION} describes a @command{gawk}-specific feature. + +Regexp constants (@code{/@dots{}/}) hold a strange position in the +@command{awk} language. In most contexts, they act like an expression: +@samp{$0 ~ /@dots{}/}. In other contexts, they denote only a regexp to +be matched. In no case are they really a ``first class citizen'' of the +language. That is, you cannot define a scalar variable whose type is +``regexp'' in the same sense that you can define a variable to be a +number or a string: + +@example +num = 42 @ii{Numeric variable} +str = "hi" @ii{String variable} +re = /foo/ @ii{Wrong!} re @ii{is the result of} $0 ~ /foo/ +@end example + +For a number of more advanced use cases (described later on in this +@value{DOCUMENT}), it would be nice to have regexp constants that +are @dfn{strongly typed}; in other words, that denote a regexp useful +for matching, and not an expression. + +@command{gawk} provides this feature. A strongly typed regexp constant +looks almost like a regular regexp constant, except that it is preceded +by an @samp{@@} sign: + +@example +re = @@/foo/ @ii{Regexp variable} +@end example + +Strongly typed regexp constants @emph{cannot} be used eveywhere that a +regular regexp constant can, because this would make the language even more +confusing. Instead, you may use them only in certain contexts: + +@itemize @bullet +@item +On the righthand side of the @samp{~} and @samp{!~} operators: @samp{some_var ~ @@/foo/} +(@pxref{Regexp Usage}). + +@item +In the @code{case} part of a @code{switch} statement +(@pxref{Switch Statement}). + +@item +As an argument to one of the built-in functions that accept regexp constants: +@code{gensub()}, +@code{gsub()}, +@code{match()}, +@code{patsplit()}, +@code{split()}, +and +@code{sub()} +(@pxref{String Functions}). + +@item +As a parameter in a call to a user-defined function. +(@pxref{User-defined}). + +@item +On the righthand side of an assignment to a variable: @samp{some_var = @@/foo/}. +In this case, the type of @code{some_var} is regexp. Additionally, @code{some_var} +can be used with @samp{~} and @code{!~}, passed to one of the built-in functions +listed above, or passed as a parameter to a user-defined function. +@end itemize + +You may use the @code{typeof()} built-in function +(@pxref{Type Functions}) +to determine if a variable or function parameter is +a regexp variable. + +The true power of this feature comes from the ability to create variables that +have regexp type. Such variables can be passed on to user-defined functions, +without the confusing aspects of computed regular expressions created from +strings or string constants. They may also be passed through indirect function +calls (@pxref{Indirect Calls}) +onto the built-in functions that accept regexp constants. + @node Regexp Summary @section Summary @@ -6289,6 +6370,11 @@ treated as regular expressions). case sensitivity of regexp matching. In other @command{awk} versions, use @code{tolower()} or @code{toupper()}. +@item +Strongly typed regexp constants (@code{@@/.../}) enable +certain advanced use cases to be described later on in the +@value{DOCUMENT}. + @end itemize @@ -19384,16 +19470,41 @@ results of the @code{compl()}, @code{lshift()}, and @code{rshift()} functions. @node Type Functions @subsection Getting Type Information -@command{gawk} provides a single function that lets you distinguish -an array from a scalar variable. This is necessary for writing code +@command{gawk} provides two functions that lets you distinguish +the type of a variable. +This is necessary for writing code that traverses every element of an array of arrays -(@pxref{Arrays of Arrays}). +(@pxref{Arrays of Arrays}), and in other contexts. @table @code @cindexgawkfunc{isarray} @cindex scalar or array @item isarray(@var{x}) Return a true value if @var{x} is an array. Otherwise, return false. + +@cindexgawkfunc{typeof} +@cindex variable type +@cindex type, of variable +@item typeof(@var{x}) +Return one of the following strings, depending upon the type of @var{x}: + +@c nested table +@table @code +@item "array" +@var{x} is an array. + +@item "regexp" +@var{x} is a strongly typed regexp (@pxref{Strong Regexp Constants}). + +@item "scalar_n" +@var{x} is a number. + +@item "scalar_s" +@var{x} is a string. + +@item "untyped" +@var{x} has not yet been given a type. +@end table @end table @code{isarray()} is meant for use in two circumstances. The first is when @@ -19411,6 +19522,14 @@ that has not been previously used to @code{isarray()}, @command{gawk} ends up turning it into a scalar. @end quotation +The @code{typeof()} function is general; it allows you to determine +if a variable or function parameter is a scalar, an array, or a strongly +typed regexp. + +@code{isarray()} is deprecated; you should use @code{typeof()} instead. +You should replace any existing uses of @samp{isarray(var)} in your +code with @samp{typeof(var) == "array"}. + @node I18N Functions @subsection String-Translation Functions @cindex @command{gawk}, string-translation functions diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 663353d4..89c4e7bf 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -557,6 +557,7 @@ particular records in a file and perform operations upon them. * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. * Records:: Controlling how data is split into records. @@ -4910,6 +4911,7 @@ regular expressions work, we present more complicated instances. * Computed Regexps:: Using Dynamic Regexps. * GNU Regexp Operators:: Operators specific to GNU software. * Case-sensitivity:: How to do case-insensitive matching. +* Strong Regexp Constants:: Strongly typed regexp constants. * Regexp Summary:: Regular expressions summary. @end menu @@ -6030,6 +6032,85 @@ The value of @code{IGNORECASE} has no effect if @command{gawk} is in compatibility mode (@pxref{Options}). Case is always significant in compatibility mode. +@node Strong Regexp Constants +@section Strongly Typed Regexp Constants + +This @value{SECTION} describes a @command{gawk}-specific feature. + +Regexp constants (@code{/@dots{}/}) hold a strange position in the +@command{awk} language. In most contexts, they act like an expression: +@samp{$0 ~ /@dots{}/}. In other contexts, they denote only a regexp to +be matched. In no case are they really a ``first class citizen'' of the +language. That is, you cannot define a scalar variable whose type is +``regexp'' in the same sense that you can define a variable to be a +number or a string: + +@example +num = 42 @ii{Numeric variable} +str = "hi" @ii{String variable} +re = /foo/ @ii{Wrong!} re @ii{is the result of} $0 ~ /foo/ +@end example + +For a number of more advanced use cases (described later on in this +@value{DOCUMENT}), it would be nice to have regexp constants that +are @dfn{strongly typed}; in other words, that denote a regexp useful +for matching, and not an expression. + +@command{gawk} provides this feature. A strongly typed regexp constant +looks almost like a regular regexp constant, except that it is preceded +by an @samp{@@} sign: + +@example +re = @@/foo/ @ii{Regexp variable} +@end example + +Strongly typed regexp constants @emph{cannot} be used eveywhere that a +regular regexp constant can, because this would make the language even more +confusing. Instead, you may use them only in certain contexts: + +@itemize @bullet +@item +On the righthand side of the @samp{~} and @samp{!~} operators: @samp{some_var ~ @@/foo/} +(@pxref{Regexp Usage}). + +@item +In the @code{case} part of a @code{switch} statement +(@pxref{Switch Statement}). + +@item +As an argument to one of the built-in functions that accept regexp constants: +@code{gensub()}, +@code{gsub()}, +@code{match()}, +@code{patsplit()}, +@code{split()}, +and +@code{sub()} +(@pxref{String Functions}). + +@item +As a parameter in a call to a user-defined function. +(@pxref{User-defined}). + +@item +On the righthand side of an assignment to a variable: @samp{some_var = @@/foo/}. +In this case, the type of @code{some_var} is regexp. Additionally, @code{some_var} +can be used with @samp{~} and @code{!~}, passed to one of the built-in functions +listed above, or passed as a parameter to a user-defined function. +@end itemize + +You may use the @code{typeof()} built-in function +(@pxref{Type Functions}) +to determine if a variable or function parameter is +a regexp variable. + +The true power of this feature comes from the ability to create variables that +have regexp type. Such variables can be passed on to user-defined functions, +without the confusing aspects of computed regular expressions created from +strings or string constants. They may also be passed through indirect function +calls (@pxref{Indirect Calls}) +onto the built-in functions that accept regexp constants. + @node Regexp Summary @section Summary @@ -6073,6 +6154,11 @@ treated as regular expressions). case sensitivity of regexp matching. In other @command{awk} versions, use @code{tolower()} or @code{toupper()}. +@item +Strongly typed regexp constants (@code{@@/.../}) enable +certain advanced use cases to be described later on in the +@value{DOCUMENT}. + @end itemize @@ -18505,16 +18591,41 @@ results of the @code{compl()}, @code{lshift()}, and @code{rshift()} functions. @node Type Functions @subsection Getting Type Information -@command{gawk} provides a single function that lets you distinguish -an array from a scalar variable. This is necessary for writing code +@command{gawk} provides two functions that lets you distinguish +the type of a variable. +This is necessary for writing code that traverses every element of an array of arrays -(@pxref{Arrays of Arrays}). +(@pxref{Arrays of Arrays}), and in other contexts. @table @code @cindexgawkfunc{isarray} @cindex scalar or array @item isarray(@var{x}) Return a true value if @var{x} is an array. Otherwise, return false. + +@cindexgawkfunc{typeof} +@cindex variable type +@cindex type, of variable +@item typeof(@var{x}) +Return one of the following strings, depending upon the type of @var{x}: + +@c nested table +@table @code +@item "array" +@var{x} is an array. + +@item "regexp" +@var{x} is a strongly typed regexp (@pxref{Strong Regexp Constants}). + +@item "scalar_n" +@var{x} is a number. + +@item "scalar_s" +@var{x} is a string. + +@item "untyped" +@var{x} has not yet been given a type. +@end table @end table @code{isarray()} is meant for use in two circumstances. The first is when @@ -18532,6 +18643,14 @@ that has not been previously used to @code{isarray()}, @command{gawk} ends up turning it into a scalar. @end quotation +The @code{typeof()} function is general; it allows you to determine +if a variable or function parameter is a scalar, an array, or a strongly +typed regexp. + +@code{isarray()} is deprecated; you should use @code{typeof()} instead. +You should replace any existing uses of @samp{isarray(var)} in your +code with @samp{typeof(var) == "array"}. + @node I18N Functions @subsection String-Translation Functions @cindex @command{gawk}, string-translation functions |