diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/ChangeLog | 6 | ||||
-rw-r--r-- | doc/awkforai.txt | 158 | ||||
-rw-r--r-- | doc/gawk.info | 148 | ||||
-rw-r--r-- | doc/gawk.texi | 13 |
4 files changed, 165 insertions, 160 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index 685338b3..34457ad4 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2012-12-09 Arnold D. Robbins <arnold@skeeve.com> + + * awkforai.txt: Changed content to be pointers to the article + to avoid copyright issues. + * gawk.texi: Updated description of awkforai.txt. + 2012-12-07 Arnold D. Robbins <arnold@skeeve.com> * gawk.texi (I/O Functions): Document that fflush() is now part diff --git a/doc/awkforai.txt b/doc/awkforai.txt index 3fca3204..2908da56 100644 --- a/doc/awkforai.txt +++ b/doc/awkforai.txt @@ -1,150 +1,18 @@ -Draft for ACM SIGPLAN Patterns (Language Trends) +Sun Dec 9 11:58:23 IST 2012 +============================ -1996 +The original of this file was a draft of an article written in 1996 by +Ronald P. Lui for an ACM Sigplan publication, explaining why he used +gawk for teaching introductory Artificial Intelligence courses. -Why GAWK for AI? +Since it was not clear as to copying permissions and so on, it has been +removed from the gawk distribution. -Ronald P. Loui +A quick web search shows that this same draft is available at +http://www.cs.wustl.edu/~loui/sigplan and the final article is available +from the ACM: http://dl.acm.org/citation.cfm?id=242908 -Most people are surprised when I tell them what language we use in our -undergraduate AI programming class. That's understandable. We use -GAWK. GAWK, Gnu's version of Aho, Weinberger, and Kernighan's old -pattern scanning language isn't even viewed as a programming language by -most people. Like PERL and TCL, most prefer to view it as a "scripting -language." It has no objects; it is not functional; it does no built-in -logic programming. Their surprise turns to puzzlement when I confide -that (a) while the students are allowed to use any language they want; -(b) with a single exception, the best work consistently results from -those working in GAWK. (footnote: The exception was a PASCAL -programmer who is now an NSF graduate fellow getting a Ph.D. in -mathematics at Harvard.) Programmers in C, C++, and LISP haven't even -been close (we have not seen work in PROLOG or JAVA). +The article itself is recommended reading. -Why GAWK? - -There are some quick answers that have to do with the pragmatics of -undergraduate programming. Then there are more instructive answers that -might be valuable to those who debate programming paradigms or to those -who study the history of AI languages. And there are some deep -philosophical answers that expose the nature of reasoning and symbolic -AI. I think the answers, especially the last ones, can be even more -surprising than the observed effectiveness of GAWK for AI. - -First it must be confessed that PERL programmers can cobble together AI -projects well, too. Most of GAWK's attractiveness is reproduced in -PERL, and the success of PERL forebodes some of the success of GAWK. -Both are powerful string-processing languages that allow the programmer -to exploit many of the features of a UNIX environment. Both provide -powerful constructions for manipulating a wide variety of data in -reasonably efficient ways. Both are interpreted, which can reduce -development time. Both have short learning curves. The GAWK manual can -be consumed in a single lab session and the language can be mastered by -the next morning by the average student. GAWK's automatic -initialization, implicit coercion, I/O support and lack of pointers -forgive many of the mistakes that young programmers are likely to make. -Those who have seen C but not mastered it are happy to see that GAWK -retains some of the same sensibilities while adding what must be -regarded as spoonsful of syntactic sugar. Some will argue that -PERL has superior functionality, but for quick AI applications, the -additional functionality is rarely missed. In fact, PERL's terse syntax -is not friendly when regular expressions begin to proliferate and -strings contain fragments of HTML, WWW addresses, or shell commands. -PERL provides new ways of doing things, but not necessarily ways of -doing new things. - -In the end, despite minor difference, both PERL and GAWK minimize -programmer time. Neither really provides the programmer the setting in -which to worry about minimizing run-time. - -There are further simple answers. Probably the best is the fact that -increasingly, undergraduate AI programming is involving the Web. Oren -Etzioni (University of Washington, Seattle) has for a while been arguing -that the "softbot" is replacing the mechanical engineers' robot as the -most glamorous AI testbed. If the artifact whose behavior needs to be -controlled in an intelligent way is the software agent, then a language -that is well-suited to controlling the software environment is the -appropriate language. That would imply a scripting language. If the -robot is KAREL, then the right language is "turn left; turn right." If -the robot is Netscape, then the right language is something that can -generate "netscape -remote 'openURL(http://cs.wustl.edu/~loui)'" with -elan. - -Of course, there are deeper answers. Jon Bentley found two pearls in -GAWK: its regular expressions and its associative arrays. GAWK asks -the programmer to use the file system for data organization and the -operating system for debugging tools and subroutine libraries. There is -no issue of user-interface. This forces the programmer to return to the -question of what the program does, not how it looks. There is no time -spent programming a binsort when the data can be shipped to /bin/sort -in no time. (footnote: I am reminded of my IBM colleague Ben Grosof's -advice for Palo Alto: Don't worry about whether it's highway 101 or 280. -Don't worry if you have to head south for an entrance to go north. Just -get on the highway as quickly as possible.) - -There are some similarities between GAWK and LISP that are illuminating. -Both provided a powerful uniform data structure (the associative array -implemented as a hash table for GAWK and the S-expression, or list of -lists, for LISP). Both were well-supported in their environments (GAWK -being a child of UNIX, and LISP being the heart of lisp machines). Both -have trivial syntax and find their power in the programmer's willingness -to use the simple blocks to build a complex approach. - -Deeper still, is the nature of AI programming. AI is about -functionality and exploratory programming. It is about bottom-up design -and the building of ambitions as greater behaviors can be demonstrated. -Woe be to the top-down AI programmer who finds that the bottom-level -refinements, "this subroutine parses the sentence," cannot actually be -implemented. Woe be to the programmer who perfects the data structures -for that heapsort when the whole approach to the high-level problem -needs to be rethought, and the code is sent to the junkheap the next day. - -AI programming requires high-level thinking. There have always been a few -gifted programmers who can write high-level programs in assembly language. -Most however need the ambient abstraction to have a higher floor. - -Now for the surprising philosophical answers. First, AI has discovered -that brute-force combinatorics, as an approach to generating intelligent -behavior, does not often provide the solution. Chess, neural nets, and -genetic programming show the limits of brute computation. The -alternative is clever program organization. (footnote: One might add -that the former are the AI approaches that work, but that is easily -dismissed: those are the AI approaches that work in general, precisely -because cleverness is problem-specific.) So AI programmers always want -to maximize the content of their program, not optimize the efficiency -of an approach. They want minds, not insects. Instead of enumerating -large search spaces, they define ways of reducing search, ways of -bringing different knowledge to the task. A language that maximizes -what the programmer can attempt rather than one that provides tremendous -control over how to attempt it, will be the AI choice in the end. - -Second, inference is merely the expansion of notation. No matter whether -the logic that underlies an AI program is fuzzy, probabilistic, deontic, -defeasible, or deductive, the logic merely defines how strings can be -transformed into other strings. A language that provides the best -support for string processing in the end provides the best support for -logic, for the exploration of various logics, and for most forms of -symbolic processing that AI might choose to call "reasoning" instead of -"logic." The implication is that PROLOG, which saves the AI programmer -from having to write a unifier, saves perhaps two dozen lines of GAWK -code at the expense of strongly biasing the logic and representational -expressiveness of any approach. - -I view these last two points as news not only to the programming language -community, but also to much of the AI community that has not reflected on -the past decade's lessons. - -In the puny language, GAWK, which Aho, Weinberger, and Kernighan thought -not much more important than grep or sed, I find lessons in AI's trends, -AI's history, and the foundations of AI. What I have found not only -surprising but also hopeful, is that when I have approached the AI -people who still enjoy programming, some of them are not the least bit -surprised. - - -R. Loui (loui@ai.wustl.edu) is Associate Professor of Computer Science, -at Washington University in St. Louis. He has published in AI Journal, -Computational Intelligence, ACM SIGART, AI Magazine, AI and Law, the ACM -Computing Surveys Symposium on AI, Cognitive Science, Minds and -Machines, Journal of Philosophy, and is on this year's program -committees for AAAI (National AI conference) and KR (Knowledge -Representation and Reasoning). +Arnold Robbins +arnold@skeeve.com diff --git a/doc/gawk.info b/doc/gawk.info index 09f30433..2e542fd9 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -21829,16 +21829,14 @@ operations: in `gawkapi.h'. For correct use, you must therefore include the corresponding standard header file _before_ including `gawkapi.h': - C Entity Header File - ----------------------------- - `FILE' `<stdio.h>' - `NULL' `<stddef.h>' - `malloc()' `<stdlib.h>' - `memset()',`<string.h>' - `memcpy()' - `size_t' `<sys/types.h>' - `struct `<sys/stat.h>' - stat' + C Entity Header File + ------------------------------------------- + `FILE' `<stdio.h>' + `NULL' `<stddef.h>' + `malloc()' `<stdlib.h>' + `memset()', `memcpy()' `<string.h>' + `size_t' `<sys/types.h>' + `struct stat' `<sys/stat.h>' Due to portability concerns, especially to systems that are not fully standards-compliant, it is your responsibility to include @@ -22185,12 +22183,19 @@ Extension functions are described by the following record: The name of the new function. `awk' level code calls the function by this name. This is a regular C string. + Function names must obey the rules for `awk' identifiers. That is, + they must begin with either a letter or an underscore, which may + be followed by any number of letters, digits, and underscores. + `awk_value_t *(*function)(int num_actual_args, awk_value_t *result);' This is a pointer to the C function that provides the desired functionality. The function must fill in the result with either a number or a string. `awk' takes ownership of any string memory. As mentioned earlier, string memory *must* come from `malloc()'. + The `num_actual_args' argument tells the C function how many + actual parameters were passed from the calling `awk' code. + The function must return the value of `result'. This is for the convenience of the calling code inside `gawk'. @@ -25564,8 +25569,9 @@ Various `.c', `.y', and `.h' files does not. `doc/awkforai.txt' - A short article describing why `gawk' is a good language for - Artificial Intelligence (AI) programming. + Pointers to the original draft of a short article describing why + `gawk' is a good language for Artificial Intelligence (AI) + programming. `doc/bc_notes' A brief description of `gawk''s "byte code" internals. @@ -31579,7 +31585,7 @@ Index * testbits.awk program: Bitwise Functions. (line 70) * Texinfo <1>: Adding Code. (line 99) * Texinfo <2>: Distribution contents. - (line 79) + (line 80) * Texinfo <3>: Extract Program. (line 12) * Texinfo <4>: Dupword Program. (line 17) * Texinfo <5>: Library Functions. (line 22) @@ -32726,6 +32732,7 @@ Ref: call-new-function876677 Node: Extension Future Growth878671 Node: Extension API Description879489 Node: Extension API Functions Introduction880817 +<<<<<<< HEAD Node: General Data Types885517 Ref: General Data Types-Footnote-1891119 Node: Requesting Values891418 @@ -32840,5 +32847,120 @@ Node: Copying1120790 Node: GNU Free Documentation License1158347 Node: Index1183484 >>>>>>> master +======= +Node: General Data Types885595 +Ref: General Data Types-Footnote-1891197 +Node: Requesting Values891496 +Ref: table-value-types-returned892227 +Node: Constructor Functions893181 +Node: Registration Functions896177 +Node: Extension Functions896862 +Node: Exit Callback Functions899036 +Node: Extension Version String900279 +Node: Input Parsers900929 +Node: Output Wrappers909516 +Node: Two-way processors913932 +Node: Printing Messages916062 +Ref: Printing Messages-Footnote-1917139 +Node: Updating `ERRNO'917291 +Node: Accessing Parameters918030 +Node: Symbol Table Access919260 +Node: Symbol table by name919772 +Ref: Symbol table by name-Footnote-1921942 +Node: Symbol table by cookie922022 +Ref: Symbol table by cookie-Footnote-1926151 +Node: Cached values926214 +Ref: Cached values-Footnote-1929657 +Node: Array Manipulation929748 +Ref: Array Manipulation-Footnote-1930846 +Node: Array Data Types930885 +Ref: Array Data Types-Footnote-1933588 +Node: Array Functions933680 +Node: Flattening Arrays937446 +Node: Creating Arrays944279 +Node: Extension API Variables949074 +Node: Extension Versioning949710 +Node: Extension API Informational Variables951611 +Node: Extension API Boilerplate952697 +Node: Finding Extensions956528 +Node: Extension Example957075 +Node: Internal File Description957813 +Node: Internal File Ops961501 +Ref: Internal File Ops-Footnote-1972948 +Node: Using Internal File Ops973088 +Ref: Using Internal File Ops-Footnote-1975441 +Node: Extension Samples975707 +Node: Extension Sample File Functions977150 +Node: Extension Sample Fnmatch985623 +Node: Extension Sample Fork987349 +Node: Extension Sample Ord988563 +Node: Extension Sample Readdir989339 +Node: Extension Sample Revout990843 +Node: Extension Sample Rev2way991436 +Node: Extension Sample Read write array992126 +Node: Extension Sample Readfile994009 +Node: Extension Sample API Tests994764 +Node: Extension Sample Time995289 +Node: gawkextlib996596 +Node: Language History998977 +Node: V7/SVR3.11000499 +Node: SVR41002820 +Node: POSIX1004262 +Node: BTL1005270 +Node: POSIX/GNU1006075 +Node: Common Extensions1011610 +Node: Ranges and Locales1012669 +Ref: Ranges and Locales-Footnote-11017287 +Ref: Ranges and Locales-Footnote-21017314 +Ref: Ranges and Locales-Footnote-31017574 +Node: Contributors1017795 +Node: Installation1022091 +Node: Gawk Distribution1022985 +Node: Getting1023469 +Node: Extracting1024295 +Node: Distribution contents1025987 +Node: Unix Installation1031248 +Node: Quick Installation1031865 +Node: Additional Configuration Options1033827 +Node: Configuration Philosophy1035304 +Node: Non-Unix Installation1037646 +Node: PC Installation1038104 +Node: PC Binary Installation1039403 +Node: PC Compiling1041251 +Node: PC Testing1044195 +Node: PC Using1045371 +Node: Cygwin1049556 +Node: MSYS1050556 +Node: VMS Installation1051070 +Node: VMS Compilation1051673 +Ref: VMS Compilation-Footnote-11052680 +Node: VMS Installation Details1052738 +Node: VMS Running1054373 +Node: VMS Old Gawk1055980 +Node: Bugs1056454 +Node: Other Versions1060306 +Node: Notes1065621 +Node: Compatibility Mode1066280 +Node: Additions1067063 +Node: Accessing The Source1067990 +Node: Adding Code1069593 +Node: New Ports1075635 +Node: Derived Files1079770 +Ref: Derived Files-Footnote-11085078 +Ref: Derived Files-Footnote-21085112 +Ref: Derived Files-Footnote-31085712 +Node: Future Extensions1085810 +Node: Implementation Limitations1086391 +Node: Basic Concepts1087618 +Node: Basic High Level1088299 +Ref: figure-general-flow1088570 +Ref: figure-process-flow1089169 +Ref: Basic High Level-Footnote-11092398 +Node: Basic Data Typing1092583 +Node: Glossary1095938 +Node: Copying1121249 +Node: GNU Free Documentation License1158806 +Node: Index1183943 +>>>>>>> master End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 5b6ea931..fca7cebb 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -28722,7 +28722,7 @@ The following types and/or macros and/or functions are referenced in @file{gawkapi.h}. For correct use, you must therefore include the corresponding standard header file @emph{before} including @file{gawkapi.h}: -@multitable {C Entity} {@code{<sys/types.h>}} +@multitable {@code{memset()}, @code{memcpy()}} {@code{<sys/types.h>}} @headitem C Entity @tab Header File @item @code{FILE} @tab @code{<stdio.h>} @item @code{NULL} @tab @code{<stddef.h>} @@ -29110,6 +29110,11 @@ The name of the new function. @command{awk} level code calls the function by this name. This is a regular C string. +Function names must obey the rules for @command{awk} +identifiers. That is, they must begin with either a letter +or an underscore, which may be followed by any number of +letters, digits, and underscores. + @item awk_value_t *(*function)(int num_actual_args, awk_value_t *result); This is a pointer to the C function that provides the desired functionality. @@ -29117,6 +29122,9 @@ The function must fill in the result with either a number or a string. @command{awk} takes ownership of any string memory. As mentioned earlier, string memory @strong{must} come from @code{malloc()}. +The @code{num_actual_args} argument tells the C function how many +actual parameters were passed from the calling @command{awk} code. + The function must return the value of @code{result}. This is for the convenience of the calling code inside @command{gawk}. @@ -33114,7 +33122,8 @@ as a list of things that the POSIX standard should describe but does not. @cindex artificial intelligence@comma{} @command{gawk} and @item doc/awkforai.txt -A short article describing why @command{gawk} is a good language for +Pointers to the original draft of +a short article describing why @command{gawk} is a good language for Artificial Intelligence (AI) programming. @item doc/bc_notes |