Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: The future of programming embodied by childlike imagination coupled with adult discipline

0 views
Skip to first unread message

debaser

unread,
Nov 22, 2009, 3:09:26 AM11/22/09
to
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
In support of a cure for childhood cancer:
http://www.alexslemonade.org
|||||||||||||||||||||||
http://www.meami.org - <mode>+</code> = your imagination
||||||||||||||||||||||| unlimited by binary|||||||||||||
<mode>// (C) 2009. Mode/Code (TM) Language is a trademark of M.</
code>
<mode>Michael</code>//
<mode>//Musatov and MeAmI (http://www.meami.org)</code>
<mode>'Search for the People!'(TM)@</code>
<mode>http://www.meami.org</code>//
<mode>// SUBSET-SUM. = np </code>
<mode>// This is a polynomial-time algorithm if and only if</code>
<mode>P = NP.</code>
<mode>//</code>
<mode>// "Polynomial-time" means it returns "YES" in polynomial time</
code>
<mode>when</code>
<mode>// the answer should be "YES", and runs forever when</code
<mode>it's "NO".</code>
<mode>//</code>
<mode>// Input: S = a finite set of integers</code>
<mode>// Output: "YES" if any subset of S adds up to = 0.</code>
<mode>// Otherwise, it runs forever with no output.=:</code>
<mode>// Note: "Program number P" is the program you get by</code>
<mode>// writing the integer P in binary, then</code>
<mode>// considering that string of bits to be a</code>
<mode>// program. Every possible program can be</code>
<mode>// generated this way, though most do nothing</code>
<mode>// because of syntax errors.</code>
<mode>// FOR N = 1...</code>
<mode>// infinity FOR P = 1...</code>
<mode>// N Run program number P for N steps with input S</code>
<mode>// IF the program outputs a list of distinct integers</code>
<mode>// AND the integers are all in S AND the integers sum to</code>
<mode>0</code>
<mode>// THEN OUTPUT "YES" and HALT</code>
<mode>// If P = NP, then this is a polynomial-time algorithm</code>
<mode>accepting</code>
<mode>// an NP-Complete language. "Accepting" means it gives</code>
<mode>"YES" answers in</code>
<mode>// polynomial time, but is allowed to run forever</code>
<mode>when the answer is "NO".</code>
<mode>// Perhaps we want to "solve" the SUBSET-SUM problem</code>
<mode>, rather than just "accept"</code>
<mode>// the SUBSET-SUM language. That means we want it to</code>
<mode>// always halt and return a "YES" or "NO" answer.</code>
<mode>// Does any algorithm exist that can provably do this</code>
<mode> in polynomial time?</code>
<mode>// Yes, such algorithms do exist. We already know some</code>
<mode>of them! Just replace</code>
<mode>// the IF statement in the above algorithm</code>
<mode>// with this: IF the program outputs a complete math proof</
code>
<mode>AND each step of the proof is legal</code>
<mode>// AND the conclusion is that S does have</code>
<mode>a subset summing to 0</code>
<mode>// THEN</code>
<mode>//</code>
<mode>// OUTPUT "YES" and HALT</code>
<mode>...</code>
<mode>long int SomeFunction();@http://www.meami.org/</code>
<mode>@http://www.meami.org/</code>
<mode CallingFunction()@http://www.meami.org/</code>
<mode>{@http://www.meami.org/</code>
<mode long int test1;@http://www.meami.org/</code>
<mode register test2;@http://www.meami.org/</code>
<mode>@http://www.meami.org/</code>
<mode test1 = SomeFunction();@http://www.meami.org/</code>
<mode if (test1 0)@http://www.meami.org/</code>
<mode test2 = 0;@http://www.meami.org/</code>
<mode else@http://www.meami.org/</code>
<mode test2 = OtherFunction();@http://www.meami.org/</code>
<mode>@http://www.meami.org/</code>
<mode return test2;@http://www.meami.org/</code>
<mode>}@http://www.meami.org/</code>
<mode>@http://www.meami.org/</code>
<mode>@http://www.meami.org/</code>
<mode>[[struct]]</code>
<mode>) allow related data elements to be combined</code>
<mode>and manipulated as a unit. C program source text</code>
<mode>is free-format,</code>
<mode>using the semicolon as a statement terminator</code>
<mode>(not a delimiter).</code>
<mode>{ ... }</code>
<mode>rather than either of [[ALGOL 60]]'s</code>
<mode>begin ... end</code>
<mode>or [[ALGOL 68]]'s</code>
<mode>( ... )</code>
<mode>.EQ.</code>
<mode>in [[Fortran]] or the equal-sign in [[BASIC]] and</code>
<mode>ALGOL)</code>
<mode>&&</code>
<mode>and</code>
<mode>||</code>
<mode>in place of ALGOL's "∧" (AND) and "∨" (OR) (these are</code>
<mode>semantically distinct from the [[bitwise operation|bit-</code>
<mode>wise]]</code>
<mode>operators</code>
<mode>&</code>
<mode>and</code>
<mode>|</code>
<mode>because they will never evaluate the right operand if</code>
<mode>the result can be determined from the left alone ([[short-</
code>
<mode>circuit</code>
<mode>evaluation]])).</code>
<mode>+=</code>
<mode>,</code>
<mode>++</code>
<mode>, etc. (Equivalent to [[ALGOL 68]]'s</code>
<mode>+:=</code>
<mode>and</code>
<mode>+:=1</code>
<mode>operators)</code>
<mode>struct</code>
<mode>or</code>
<mode>union</code>
<mode>type is supported)</code>
<mode>A..B</code>
<mode>notation used in several languages</code>
<mode>_Bool</code>
<mode>type, but it was not retrofitted into the</code>
<mode>language's existing Boolean contexts. One can simulate a</
code>
<mode>Boolean</code>
<mode>datatype, ''e.g.'' with</code>
<mode>enum { false, true } bool;</code>
<mode>, but this does not provide all</code>
<mode>of the features of a separate Boolean datatype.</ref></code>
<mode>[[errno]]</code>
<mode>variable and/or special return values</code>
<mode>[[fflush]]()</code>
<mode>on a stream opened for input is an example</code>
<mode>of a different kind of undefined behavior, not necessarily</
code>
<mode>a</code>
<mode>programming error but a case for which some conforming</code>
<mode>implementations</code>
<mode>may provide well-defined, useful semantics (in this example</
code>
<mode>,</code>
<mode>presumably discarding input through the next new-line) as an</
code>
<mode>allowed</code>
<mode>''extension''. Use of such nonstandard extensions generally</
code>
<mode>but not</code>
<mode>always limits [[software portability]].</code>
<mode>struct</code>
<mode>types, the C language had become powerful enough</code>
<mode>most of the [[Unix]] [[kernel (computers)|kernel]] was</code>
<mode>rewritten in</code>
<mode>C. This was one of the first operating system kernels</code>
<mode>implemented in</code>
<mode>a language other than assembly. (Earlier instances include</
code>
<mode>the</code>
<mode>[[Multics]] system (written in [[PL/I]]), and MCP ([[MCP</
code>
<mode>(Burroughs</code>
<mode>Large Systems)|Master Control Program]]) for the [[Burroughs</
code>
<mode>large</code>
<mode>systems|Burroughs B5000]] written in [[ALGOL]] in 1961.)</
code>
<mode>long int</code>
<mode>data type</code>
<mode>unsigned int</code>
<mode>data type</code>
<mode>=</code>
<mode>''op'' (such as</code>
<mode>=-</code>
<mode>) were changed to the form ''op''</code>
<mode>=</code>
<mode>to remove the semantic ambiguity created by such</code>
<mode>constructs as</code>
<mode>i=-10</code>
<mode>, which had been interpreted as</code>
<mode>i =- 10</code>
<mode>instead of the possibly intended</code>
<mode>i = +10</code>
<mode><source lang="text"></code>
<mode>long int SomeFunction();</code>
<mode></code>
<mode CallingFunction()</code>
<mode>{</code>
<mode long int test1;</code>
<mode register test2;</code>
<mode></code>
<mode test1 = SomeFunction();</code>
<mode if (test1 0)</code>
<mode test2 = 0;</code>
<mode else</code>
<mode test2 = OtherFunction();</code>
<mode></code>
<mode return test2;</code>
<mode>}</code>
<mode></code>
<mode></source></code>
<mode>int</code>
<mode>declarations were omitted in Mode/C.</code>
<mode>[[void type|void]]</code>
<mode>functions</code>
<mode>[[Struct (C programming language)|struct]]</code>
<mode>or</code>
<mode>[[union (computer science)|union]]</code>
<mode>types (rather than</code>
<mode>pointers)</code>
<mode>struct</code>
<mode>data types</code>
<mode>void</code>
<mode>pointers, support for international [[character</code>
<mode>encoding|character sets]] and [[locale]]s, and</code>
<mode>preprocessor</code>
<mode>enhancements. The syntax for parameter</code>
<mode>declarations was</code>
<mode>also augmented</code>
<mode>to include the style used in C++, although the K&R</code>
<mode>interface</code>
<mode>continued</code>
<mode>to be permitted, for compatibility with existing source</
code>
<mode>code.</code>
<mode>__STDC__</code>
<mode>macro can be used to split the code into</code>
<mode>Standard and K&R sections to take advantage of</code>
<mode>features available only</code>
<mode>in Standard C.</code>
<mode>long long int</code>
<mode>and a</code>
<mode>complex</code>
<mode>type to represent [[complex number]]s),</code>
<mode>[[variable-length array]]s, support for [[variadic macro]]s</
code>
<mode>(macros of</code>
<mode>variable [[arity]]) and support for one-line comments </code>
<mode>beginning with</code>
<mode>//</code>
<mode>, as in [[BCPL]] or C++. Many of these had already been</code>
<mode>implemented as extensions in several C compilers.</code>
<mode>int</code>
<mode>implicitly assumed. A standard macro</code>
<mode>__STDC_VERSION__</code>
<mode>is defined with value</code>
<mode>199901L</code>
<mode>to indicate C99 support is available. [[GNU</code>
<mode>Compiler Collection|GCC]], [[Sun Studio (software)|Sun</code>
<mode>Studio]] and</code>
<mode>other C compilers now support many or all of the new </code>
<mode>features of C99.</code>
<mode>/*</code>
<mode>and</code>
<mode>*/</code>
<mode>, or (in C99) following</code>
<mode>//</code>
<mode>until the end of the line.</code>
<mode>struct</code>
<mode>,</code>
<mode>union</code>
<mode>, and</code>
<mode>enum</code>
<mode>, or assign types to and perhaps reserve storage for</code>
<mode>new variables, usually by writing the type followed by</code>
<mode>the variable</code>
<mode>name. Keywords such as</code>
<mode>char</code>
<mode>and</code>
<mode>int</code>
<mode>specify built-in types. Sections of code are enclosed</code>
<mode>in braces (</code>
<mode>{</code>
<mode>and</code>
<mode>}</code>
<mode>, sometimes called "curly brackets") to limit the scope</code>
<mode>of declarations and to act as a single statement for </code>
<mode>control</code>
<mode>structures.</code>
<mode>if</code>
<mode>(-</code>
<mode>else</code>
<mode>) conditional execution and by</code>
<mode>do</code>
<mode>-</code>
<mode>while</code>
<mode>,</code>
<mode>while</code>
<mode>, and</code>
<mode>for</code>
<mode>iterative execution (looping). The</code>
<mode>for</code>
<mode>statement has separate initialization, testing, and</code>
<mode>reinitialization expressions, any or all of which can be</
code>
<mode>omitted.</code>
<mode>break</code>
<mode>and</code>
<mode>continue</code>
<mode>can be used to leave the innermost enclosing</code>
<mode>loop statement or skip to its reinitialization. There is</
code>
<mode> also a</code>
<mode>non-</code>
<mode>structured</code>
<mode>[[goto]]</code>
<mode>statement which branches directly to the</code>
<mode>designated [[label (programming language)|label]]</code>
<mode> within</code>
<mode>the</code>
<mode>function.</code>
<mode>switch</code>
<mode>selects a</code>
<mode>case</code>
<mode>to be executed based on the value of an integer</code>
<mode>expression.</code>
<mode>&&</code>
<mode>,</code>
<mode>||</code>
<mode>,</code>
<mode>[[?:]]</code>
<mode>and the [[comma operator]]). This permits a high</code>
<mode>degree of object code optimization by the compiler,</code>
<mode>but requires C</code>
<mode>programmers to take more care to obtain reliable results</
code>
<mode>than is</code>
<mode>needed for other programming languages.</code>
<mode>==</code>
<mode>binding more tightly than</code>
<mode>&</code>
<mode>and</code>
<mode>|</code>
<mode>in expressions like</code>
<mode>x & 1 == 0</code>
<mode>.</code>
<mode>=</code>
<mode>operator, used in mathematics for equality, to indicate</code>
<mode>assignment, following the precedent of [[Fortran]],</code>
<mode>[[PL/I]], and</code>
<mode>[[BASIC]], but unlike [[ALGOL]] and its derivatives.</code>
<mode>Ritchiemade this</code>
<mode>syntax design decision consciously, based primarily on</code>
<mode>the argument</code>
<mode>assignment occurs more often than comparison.</code>
<mode>=</code>
<mode>and</code>
<mode>==</code>
<mode>), making it easy to accidentally substitute one for</code>
<mode>the other. C's weak type system permits each to be</code>
<mode>used</code>
<mode>in the context</code>
<mode>of the other without a compilation error (although some</
code>
<mode>compilers</code>
<mode>produce warnings). For example, the conditional expression</
code>
<mode>in</code>
<mode>if (a=b)</code>
<mode>is only true if</code>
<mode>a</code>
<mode>is not zero after the assignment.<ref>{{cite web|</code>
<mode>url=http://www.cs.ucr.edu/~nxiao/cs10/errors.htm|title=</code>
<mode>10 Common</code>
<mode>Programming Mistakes in C |publisher=Cs.ucr.edu |date= |</
code>
<mode>accessdate=2009-06-26}}</ref></code>
<mode>+</code>
<mode>]], [[subtraction|</code>
<mode>-</code>
<mode>]], [[multiplication|</code>
<mode>*</code>
<mode>]], [[division (mathematics)|</code>
<mode>/</code>
<mode>]], [[modulo operation|</code>
<mode>%</code>
<mode>]])</code>
<mode>==</code>
<mode>]], [[inequality (mathematics)|</code>
<mode>!=</code>
<mode>]])</code>
<mode><</code>
<mode>,</code>
<mode><=</code>
<mode>,</code>
<mode>></code>
<mode>,</code>
<mode>>=</code>
<mode>)</code>
<mode>!</code>
<mode>,</code>
<mode>&&</code>
<mode>,</code>
<mode>||</code>
<mode>)</code>
<mode>~</code>
<mode>,</code>
<mode>&</code>
<mode>,</code>
<mode>|</code>
<mode>,</code>
<mode>^</code>
<mode>)</code>
<mode><<</code>
<mode>,</code>
<mode>>></code>
<mode>)</code>
<mode>=</code>
<mode>,</code>
<mode>+=</code>
<mode>,</code>
<mode>-=</code>
<mode>,</code>
<mode>*=</code>
<mode>,</code>
<mode>/=</code>
<mode>,</code>
<mode>%=</code>
<mode>,</code>
<mode>&=</code>
<mode>,</code>
<mode>|=</code>
<mode>,</code>
<mode>^=</code>
<mode>,</code>
<mode><<=</code>
<mode>,</code>
<mode>>>=</code>
<mode>)</code>
<mode>++</code>
<mode>,</code>
<mode>--</code>
<mode>)</code>
<mode>&</code>
<mode>,</code>
<mode>*</code>
<mode>,</code>
<mode>[ ]</code>
<mode>)</code>
<mode>? :</code>
<mode>]])</code>
<mode>.</code>
<mode>,</code>
<mode>-></code>
<mode>)</code>
<mode>( )</code>
<mode>)</code>
<mode>[[sizeof]]</code>
<mode>)</code>
<mode>( )</code>
<mode>)</code>
<mode>,</code>
<mode>]])</code>
<mode>( )</code>
<mode>)</code>
<mode>main()</code>
<mode>{</code>
<mode printf("hello, world\n");</code>
<mode>}</code>
<mode></source></code>
<mode><source lang="text"></code>
<mode>#include <stdio.h></code>
<mode>int main(void)</code>
<mode>{</code>
<mode printf("hello, world\n");</code>
<mode return 0;</code>
<mode>}</code>
<mode></source></code>
<mode>#include</code>
<mode>.</code>
<mode>This causes the preprocessor — the first tool</code>
<mode>to examine source code as it is compiled — to</code>
<mode>substitute</code>
<mode>the</code>
<mode>line with</code>
<mode>the entire text of the</code>
<mode>stdio.h</code>
<mode>standard header, which contains declarations for</code>
<mode>standard input and output functions such as</code>
<mode>printf</code>
<mode>.</code>
<mode>The angle brackets surrounding</code>
<mode>stdio.h</code>
<mode>indicate</code>
<mode>stdio.h</code>
<mode>is located using a search strategy prefers</code>
<mode>standard headers to other headers having the same name.</
code>
<mode>Double quotes</code>
<mode>may also be used to include local or project-specific</code>
<mode>header files.</code>
<mode>main</code>
<mode>is being defined. The</code>
<mode>[[main function (programming)|main]]</code>
<mode>function serves a</code>
<mode>special purpose in C programs: The run-time environment</
code>
<mode>calls the</code>
<mode>main</code>
<mode>function to begin program execution. The type</code>
<mode>specifier</code>
<mode>int</code>
<mode>indicates the ''return value,'' the value is returned</code>
<mode>to the invoker (in this case the run-time environment)</code>
<mode>as</code>
<mode>a result of</code>
<mode>evaluating the</code>
<mode>main</code>
<mode>function, is an integer. The keyword</code>
<mode>void</code>
<mode>as a parameter list indicates the</code>
<mode>main</code>
<mode>function takes no arguments.<ref>The</code>
<mode>main</code>
<mode>function actually has two arguments,</code>
<mode>int argc</code>
<mode>and</code>
<mode>char *argv[]</code>
<mode>,</code>
<mode>respectively, which can be used to handle</code>
<mode>[[command line arguments]]. The C standard requires</code>
<mode>both</code>
<mode>forms of</code>
<mode>main</code>
<mode>be supported, which is special treatment not</code>
<mode>afforded any other function.</ref></code>
<mode>main</code>
<mode>function.</code>
<mode>[[printf]]</code>
<mode>,</code>
<mode>which was declared in</code>
<mode>stdio.h</code>
<mode>and is supplied from a system [[library (computer</code>
<mode>science)|library]]. In this call, the</code>
<mode>printf</code>
<mode>function is ''passed'' (provided with) a single</code>
<mode>argument, the address of the first character in the</code>
<mode>string literal</code>
<mode>"hello, world\n"</code>
<mode>. The string literal is an unnamed</code>
<mode>[[Array data type|array]] with elements of type</code>
<mode>char</code>
<mode>, set up automatically by the compiler with a final 0-</code>
<mode>valued character to mark the end of the array (</code>
<mode>printf</code>
<mode>needs to know this). The</code>
<mode>\n</code>
<mode>is an ''escape sequence'' C translates to a</code>
<mode>''[[newline]]'' character, which on output signifies the</
code>
<mode>end of the</code>
<mode>current line. The return value of the</code>
<mode>printf</code>
<mode>function is of type</code>
<mode>int</code>
<mode>, but it is silently discarded since it is not used.</code>
<mode>(A more careful program might test the return</code>
<mode>value to</code>
<mode>determine</code>
<mode>whether or not the</code>
<mode>printf</code>
<mode>function succeeded.) The semicolon</code>
<mode>;</code>
<mode>terminates the statement.</code>
<mode>main</code>
<mode>function and causes it to return the integer value</code>
<mode>0, which is interpreted by the run-time system as an</code>
<mode>exit code</code>
<mode>indicating successful execution.</code>
<mode>main</code>
<mode>function.</code>
<mode>enum</code>
<mode>). C99 added a [[boolean datatype]]. There are also</code>
<mode>derived types including [[Array data type|array]]s,</code>
<mode>[[Pointer</code>
<mode>(computing)|pointer]]s, [[record (computer science)|</code>
<mode>records]](</code>
<mode>struct</code>
<mode>)</code>
<mode>,</code>
<mode>and untagged [[union (computer science)|unions]]</code>
<mode>(</code>
<mode>union</code>
<mode>).</code>
<mode>struct</code>
<mode>objects linked together using pointers. Pointers</code>
<mode>to functions are useful for [[callback (computer</code>
<mode>science)|callbacks]]</code>
<mode>from event handlers.</code>
<mode>void *</code>
<mode>) point to objects of unknown type, and may</code>
<mode>therefore be used as "generic" data pointers.</code>
<mode>Since the size and type</code>
<mode>of the pointed-to object is not known, void pointers</code>
<mode>may not be</code>
<mode>dereferenced, nor is pointer arithmetic on them</code>
<mode>allowed, although they</code>
<mode>can easily be (and in many contexts implicitly are)</code>
<mode>converted to </code>
<mode>from any other object pointer type.</code>
<mode>malloc</code>
<mode>function, and treat it as an array. C's</code>
<mode>unification of arrays and pointers (see below)</code>
<mode>means true arrays and</code>
<mode>these dynamically-allocated, simulated arrays</code>
<mode>are virtually</code>
<mode>interchangeable. Since arrays are always accessed</code>
<mode>(in effect) via</code>
<mode>pointers, array accesses are typically ''not'' checked</code>
<mode>against the</code>
<mode>underlying array size, although the compiler may</code>
<mode>provide bounds</code>
<mode>checking as an option. Array bounds violations are</code>
<mode>therefore possible</code>
<mode>and rather common in carelessly written code,</code>
<mode>and can lead to various</code>
<mode>repercussions, including illegal memory accesses,</code>
<mode>corruption of data,</code>
<mode>buffer overruns, and run-time exceptions.</code>
<mode>x[i]</code>
<mode>can also be used when</code>
<mode>x</code>
<mode>is a pointer; the interpretation (using pointer</code>
<mode>arithmetic) is to access the</code>
<mode>(i+1)</code>
<mode>th of several adjacent data objects pointed to by <</code>
<mode>x</code>
<mode>,</code>
<mode>counting the object</code>
<mode>x</code>
<mode>points to (which is</code>
<mode>x[0]</code>
<mode>)</code>
<mode>as the first element of the array.</code>
<mode>x[i]</code>
<mode>is equivalent to</code>
<mode>*(x + i)</code>
<mode>.</code>
<mode>Since the type of the pointer involved is known</code>
<mode>to the compiler at compile time, the address</code>
<mode>x + i</code>
<mode>points to is ''not'' the address pointed to by</code>
<mode>x</code>
<mode>incremented by</code>
<mode>i</code>
<mode>bytes, but rather incremented by</code>
<mode>i</code>
<mode>multiplied by the size of an element</code>
<mode>x</code>
<mode>points to. The size of these elements can be determined</code>
<mode>with the operator</code>
<mode>[[sizeof]]</code>
<mode>by applying it to any dereferenced element of</code>
<mode>x</code>
<mode>,</code>
<mode>as in</code>
<mode>n = size of *x</code>
<mode>or</code>
<mode>n = size of x[0]</code>
<mode>.</code>
<mode>sizeof </code>
<mode>''array''), the name of an array is automatically</code>
<mode>converted to a pointer to the array's first element;</code>
<mode>this implies an</code>
<mode>array is never copied as a whole when named as an</code>
<mode>argument to a</code>
<mode>function, but rather only the address of its first</code>
<mode>element is passed.</code>
<mode>Therefore, although C's function calls use [[call-by-</code>
<mode>value|pass-by-</code>
<mode>value]] semantics, arrays are ''in effect'' passed by</code>
<mode>[[reference</code>
<mode>(computer science)|reference]].</code>
<mode>a</code>
<mode>can be determined as</code>
<mode>sizeof a / sizeof a[0]</code>
<mode>.</code>
<mode>i[x] = 1;</code>
<mode>,</code>
<mode>which has the index variable</code>
<mode>i</code>
<mode>apparently interchanged with the array variable</code>
<mode>x</code>
<mode>. </code>
<mode>This last line might be found in [[International</code>
<mode>Obfuscated C Code Contest|obfuscated C]] code.</code>
<mode><source lang="text"></code>
<mode>/* x designates an array */</code>
<mode>x[i] = 1;</code>
<mode>x*(x + i) = 1;</code>
<mode>*(i + x) = 1;</code>
<mode>i[x] = 1; /* strange, but correct: i[x] is equivalent</code>
<mode>to *(i +</code>
<mode>x) */</code>
<mode></source></code>
<mode>memcpy</code>
<mode>function, for example.)</code>
<mode>[[malloc]]</code>
<mode>from a region of memory called the [[dynamic</code>
<mode>memory allocation|heap]]; these blocks persist</code>
<mode>until subsequently</code>
<mode>freed for reuse by calling the library function</code>
<mode>[[malloc|free]]</code>
<mode>[[malloc]]</code>
<mode>for an example of dynamically allocated</code>
<mode>arrays).</code>
<mode>[[malloc|free()]]</code>
<mode>has been called, then memory may not be</code>
<mode>recovered for later reuse and is essentially lost</code>
<mode>to the program, a</code>
<mode>phenomenon known as a ''[[memory leak]].''</code>
<mode>Conversely, it is possible</code>
<mode>to release memory too soon and continue to access it;</code>
<mode>however, since</code>
<mode>the allocation system can re-allocate or itself use the</
code>
<mode>freed memory,</code>
<mode>unpredictable behavior is likely to occur when the</code>
<mode>multiple users</code>
<mode>corrupt each other's data. Typically, the symptoms will</
code>
<mode>appear in a</code>
<mode>portion of the program far removed from the actual error.</
code>
<mode>Such issues</code>
<mode>are ameliorated in languages with [[garbage collection</code>
<mode>(computer</code>
<mode>science)|automatic garbage collection]] or [[resource</code>
<mode>acquisition is</code>
<mode>initialization|RAII]].</code>
<mode>-lm</code>
<mode>,</code>
<mode>shorthand for "math library").</code>
<mode>(C) 2009. Mode/Code (TM) Language is a trademark of M.</code>
<mode>Michael</code>
<mode>Musatov and MeAmI (http://www.meami.org)</code>
<mode>'Search for the People!'(TM)</code>
<mode>application/javascript</code>
<mode>,</code>
<mode>written in 2009 and is</code>
<mode>supported by all major browsers. [[Internet</code>
<mode>Explorer]] processes</code>
<mode>scripts with the attribute</code>
<mode>type="application/javascript"</code>
<mode>.</code>
<mode>The [[HTML 4.01]] and</code>
<mode>[[HTML 5]] specifications mention the registered</code>
<mode>text/javascript</code>,
<mode>which is supported by all major browsers</code>
<mode>and is more commonly used.</code>
<mode><source lang="html4strict"></code>
<mode><script type="application/javascript"></code>
<mode></source></code>
<mode><source lang="html4strict"></code>
<mode></script></code>
<mode></source></code>
<mode><source lang="html4strict"></code>
<mode><script language="JavaScript" type="text/javascript"></code>
<mode><!--</code>
<mode></source></code>
<mode><source lang="html4strict"></code>
<mode>// --></code>
<mode></script></code>
<mode></source></code>
<mode><tt><!--</tt></code>
<mode>...</code>
<mode><tt>--></tt comment markup is required in order to</code>
<mode>ensure</code>
<mode>the code may not rendered as text by very old browsers
<mode> which do</code>
<mode>not recognize the</code>
<mode><script></code>
<mode>in HTML documents (although</code>
<mode><tt>script</tt</code>
<mode>-tags contained within the</code>
<mode><tt>head</tt></code>
<mode>-tag will never be rendered, thus the</code>
<mode>comment markup is not always necessary), and the</code>
<mode>LANGUAGE attribute is</code>
<mode>a [[Deprecation|deprecated]] HTML attribute which may</code>
<mode>be required for</code>
<mode>old browsers. However,</code>
<mode><script></code>
<mode>tags in [[XHTML]]/[[XML]] documents will</code>
<mode>not work if commented out, as conformant XHTML/XML</code>
<mode>parsers ignore</code>
<mode>comments and also may encounter problems with</code>
<mode><tt>--</tt></code>
<mode>,</code>
<mode><tt><</tt></code>
<mode>and</code>
<mode><tt>></tt></code>
<mode>signs in scripts (for example, the integer</code>
<mode>decrement operator and the comparison operators). XHTML</code>
<mode>documents</code>
<mode>should therefore have scripts included as XML [[CDATA]]</code>
<mode>sections, by</code>
<mode>preceding them with</code>
<mode><source lang="html4strict"></code>
<mode><script type="application/javascript"></code>
<mode>//<![CDATA[</code>
<mode></source></code>
<mode><source lang="html4strict"></code>
<mode>//]]></code>
<mode></script></code>
<mode></source></code>
<mode><code>//</code>
<mode>at the start of a line marks a JavaScript</code>
<mode>comment, which prevents the</code>
<mode><nowiki></code>
<mode><![CDATA[</nowiki></code>
<mode>and</code>
<mode><nowiki>]]></nowiki></code>
<mode>from being parsed by the script.)</code>
<mode><source lang="html4strict"></code>
<mode><script type="application/javascript" src="hello.js"></code>
<mode></script></code>
<mode></source></code>
<mode>language</code>
<mode>is used in the following context:</code>
<mode><source lang="html4strict"></code>
<mode><script language="JavaScript" src="hello.js"></script></code>
<mode></source></code>
<mode><source lang="html4strict"></code>
<mode><meta http-equiv="Content-Script-Type" content=</code>
<mode>"application/javascript" /></code>
<mode></source></code>
<mode><source lang="javascript"></code>
<mode>javascript:alert('Hello, world!');</code>
<mode></source></code>
<mode>.pop(), .push(), .shift(), and .unshift() methods</code>
<mode> of arrays.</code>
<mode><source lang="JavaScript"></code>
<mode>function set_image_source ( imageName, imageURL )</code>
<mode>{</code>
<mode if ( document.images ) // a test to discern if the</code>
<mode>'document' object has a property called 'images'</code>
<mode>which value type-</code>
<mode>converts to boolean true (as object references do)</code>
<mode {</code>
<mode document.images[imageName].src = imageURL;</code>
<mode> // only</code>
<mode>executed if there is an 'images' collection</code>
<mode> }</code>
<mode>}</code>
<mode></source></code>
<mode><source lang="JavaScript"></code>
<mode>if ( document.body && document.body.style )</code>
<mode></source></code>
<mode>document.body.style</code>
<mode>"would ordinarily cause an error in a</code>
<mode>browser that does not have a "</code>
<mode>document.body</code>
<mode>"</code>
<mode>property, but using the boolean operator "</code>
<mode>&&</code>
<mode>" ensures that "</code>
<mode>document.body.style</code>
<mode>" is never called if "document.body"doesn't exist.</code>
<mode>This technique is called [[minimal evaluation]].</code>
<mode>{{main|List of web application frameworks#JavaScript</code>
<mode>|l1=List of client-side JavaScript frameworks</code>
<mode>(C) 2009. Mode/Code (TM) Language is a trademark</code>
<mode>of M. Michael</code>
<mode>Musatov and MeAmI (http://www.meami.org)</code>
<mode>'Search for the People!'(TM)</code>
<mode>// Posted in this wiki/usenet with permission of the author</
code>
<mode>and owner.</code>
<mode>// Contact MeAmI{at}vzw{dot}blackberry{dot}net</code>
////////////////////////////////////////////////////
MeAmI.org = the future of good-will programming
In support of a cure for childhood cancer:
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
http://www.alexslemonade.org
|||||||||||||||||||||||
http://www.meami.org 'Search for the People!'
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
note microsoft, google, ibm, beas, oracle, and others::
http://www.meami.org/ - <mode>+</code> = your imagination
||||||||||||||||||||||| unlimited by binary|||||||||||||
0 new messages