diff options
Diffstat (limited to 'doc/gawk.texi')
-rw-r--r-- | doc/gawk.texi | 75 |
1 files changed, 1 insertions, 74 deletions
diff --git a/doc/gawk.texi b/doc/gawk.texi index df4a1942..5e40e86a 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -6295,70 +6295,6 @@ 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 @samp{!~}, 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. - -When used in numeric conversions, strongly typed regexp variables convert -to zero. When used in string conversions, they convert to the string -value of the original regexp text. - @node Regexp Summary @section Summary @@ -6402,11 +6338,6 @@ 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 @@ -19575,9 +19506,6 @@ Return one of the following strings, depending upon the type of @var{x}: @item "array" @var{x} is an array. -@item "regexp" -@var{x} is a strongly typed regexp (@pxref{Strong Regexp Constants}). - @item "number" @var{x} is a number. @@ -19634,8 +19562,7 @@ 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. +if a variable or function parameter is a scalar, an array. @code{isarray()} is deprecated; you should use @code{typeof()} instead. You should replace any existing uses of @samp{isarray(var)} in your |