From dc29eecc7859d0514c7b18a60c52048aa240d82b Mon Sep 17 00:00:00 2001 From: Jason Self Date: Sat, 1 Jul 2017 19:58:03 -0700 Subject: [PATCH 1/1] Add initial work on Inform in four minutes --- README | 18 ++++ informqr/informqr.md | 237 +++++++++++++++++++++++++++++++++++++++++++ permission.txt | 44 ++++++++ 3 files changed, 299 insertions(+) create mode 100644 README create mode 100644 informqr/informqr.md create mode 100644 permission.txt diff --git a/README b/README new file mode 100644 index 0000000..4b5940f --- /dev/null +++ b/README @@ -0,0 +1,18 @@ +This repository contains various Inform-related material originally +from Roger Firth at + + +Relicensing was done with permission of Roger Firth. + +The documents in this repository, including this one, are made +following Pandoc's extended version of Markdown: +. + +Converting them to other formats requires that Pandoc or some other +program that can understand this version of Markdown be installed on +your system. + +--- +This document by Jason Self is licensed under the Creative Commons +Attribution-ShareAlike 4.0 International Public License and all +future versions: . \ No newline at end of file diff --git a/informqr/informqr.md b/informqr/informqr.md new file mode 100644 index 0000000..e595a36 --- /dev/null +++ b/informqr/informqr.md @@ -0,0 +1,237 @@ +% Inform in four minutes +% Roger Firth + +A quick reference to the Inform programming language. + +Copyright © 2002 Roger Firth . Copying and +distribution, with or without modification, are permitted in any +medium without royalty provided the copyright notice and this notice +are preserved. + + + +Version 1.3 (March 2002) + +The road to brevity is via imprecision and through solecism. + +Literals +-------- + +A Z-code **word** literal uses sixteen bits (whereas a Glulx word has +thirty-two bits). A **byte** literal is always eight bits. + +- Decimal: `-32768` to `32767`\ + Hexadecimal: `$0` to `$FFFF`\ + Binary: `$$0` to `$$1111111111111111` +- Action: `##Look` +- Character: `'a'` +- Dictionary word: `'aardvark'` (up to nine characters significant); + use circumflex "`^`" to denote apostrophe.\ + Plural word: `'aardvarks//p'`\ + Single-character word: `"a"` (`name` property only) or `'a//'` +- String: `"aardvark's adventure"` (maximum around 4000 characters); + can include special values including: + + ------------- ------------------------------------ + \^ newline + \~ quote (") + @@64 at sign "@" + @@92 backslash "" + @@94 circumflex "\^" + @@126 tilde "\~" + @\`a a with a grave accent "`à`", et al + @LL pound sign "£", et al + @00 ... @31 low string 0..31 + ------------- ------------------------------------ + +Names +----- + +The identifier of an Inform *constant*, *variable*, *array*, *class*, +*object*, *property*, *attribute*, *routine* or *label*. Up to 32 +characters: alphabetic (case not significant), numeric and underscore, +with the first character not a digit. + +Expressions and Operators +------------------------- + +Use parentheses (...) to control the order of evaluation. +Arithmetic/logical expressions support these operators: + + ---------- --------------------------------------------- + *p + q* addition + *p - q* subtraction + *p * q\* multiplication + *p / q* integer division + *p % q* remainder + *p++* increments *p*, evaluates to original value + *++p* increments *p*, evaluates to new value + *p--* decrements *p*, evaluates to original value + *--p* decrements *p*, evaluates to new value + *p & q* bitwise AND + *p | q* bitwise OR + *\~p* bitwise NOT (inversion) + ---------- --------------------------------------------- + +Conditional expressions return `true` (1) or `false` (0); *q* may be a +list of alternatives *q1* `or` *q2* `or` ... *qN*: + + ---------------- ---------------------------------------- + *p == q* *p* is equal to *q* + *p \~= q* *p* isn't equal to *q* + *p* > *q* *p* is greater than *q* + *p < q* *p* is less than *q* + *p >= q* *p* is greater than or equal to *q* + *p <= q* *p* is less than or equal to *q* + *p ofclass q* object *p* is of class *q* + *p in q* object *p* is a child of object *q* + *p notin q* object *p* isn't a child of object *q* + *p provides q* object *p* provides property *q* + *p has q* object *p* has attribute *q* + *p hasnt q* object *p* hasn't attribute *q* + ---------------- ---------------------------------------- + +Boolean expressions return `true` (1) or `false` (0): + + -------- ---------------------------------- + p && q both p and q are true (non-zero) + p || q either p or q is true (non-zero) + \~\~p p is false (zero) + -------- ---------------------------------- + +To return -1, 0 or 1 based on unsigned comparison: + + UnsignedCompare(p,q) + +To return `true` if object *q* is a child or grand-child or... of *p*: + + IndirectlyContains(p,q) + +To return a random number 1..*N*, or one from a list of constant +values: + + random(N ) + random(value,value, ... value ) + +Constants +--------- + +Named word values, unchanging at run-time, which are by default +initialised to zero: + + Constant constant; + Constant constant = expr; + +Standard constants are `true` (1), `false` (0) and `nothing` (0), also +`NULL` (-1). + +To define a constant (unless it already exists): + + Default constant expr ; + +Variables and Arrays +-------------------- + +Named word/byte values which can change at run-time and are by default +initialised to zero. + +A **global** variable is a single word: + + Global variable; + Global variable = expr; + +A **word array** is a set of global words accessed using `array-->0`, +`array-->1`, ... `array-->(N-1)`: + + Array array --> N; + Array array --> expr1 expr2 ... exprN; + Array array --> "string"; + +A **table array** is a set of global words accessed using +*array-->1*, *array-->2*, ... *array-->N*, with +*array-->0* initialized to *N*: + + Array array table N ; + Array array table expr1 expr2 ... exprN + Array array table "string"; + +A **byte array** is a set of global bytes accessed using +*array->0*, *array->1*, ... *array->(N-1)*: + + Array array -> N; + Array array -> expr1 expr2 ... exprN; + Array array -> "string"; + +A **string array** is a set of global bytes accessed using +*array->1*, *array->2*, ... *array->N*, with *array->0* +initialized to *N*: + + Array array string N; + Array array string expr1 expr2 ... exprN; + Array array string "string"; + +In all these cases, the characters of the initializing *string* are +unpacked to the individual word/byte elements of the array. See also +Objects (for **property** variables) and Routines (for **local** +variables). + +## Classes and Objects + +To declare a *class* - a template for a family of objects - +where the optional (*N*) limits instances created at run-time: + + Class class(N) + class class class ... class + has attr_def attr_def ... attr_def + with prop_def, + ... + prop_def; + +To declare an *object*; "`Object`" can instead be a *class*, the +remaining four header items are all optional, and *arrows* +(`->`, `->` `->`, ...) and *parent_object* are incompatible: + + Object arrows object "ext_name " parent_object + class class class ... class + has attr_def attr_def ... attr_def + with prop_def, + ... + prop_def; + +The `class`, `has` and `with` (and also the rarely-used `private`) +segments are all optional, and can appear in any order. + +To determine an object's class as one of `Class`, `Object`, +`Routine`, `String` (or `nothing`): + + metaclass(object) + +**has segment**: Each *attr_def* is either of: + + attribute + ~attribute + +To change attributes at run-time: + + give object attr_def attr_def ... attr_def; + +**with/private segments**: Each *prop_def* declares a variable +(or word array) and can take any of these forms (where a +*value* is an expression, a string or an embedded routine): + + property + property value + property value value ... value + +A property variable is addressed by *object.property* (or +within the object's declaration as *self.property*). + +Multiple values create a property array; in this case +*object.#property* is the number of **bytes** occupied by the +array, the entries can be accessed using +*object.&property-->0*, *object.&property-->1*, ... , and +*object.property* refers to the value of the first entry. + +A property variable inherited from an object's class is +addressed by *object.class::property*; this gives the +original value prior to any changes within the object. \ No newline at end of file diff --git a/permission.txt b/permission.txt new file mode 100644 index 0000000..f70f59d --- /dev/null +++ b/permission.txt @@ -0,0 +1,44 @@ +Return-Path: +X-Original-To: jason@bluehome.net +Delivered-To: jason@bluehome.net +Received: from claranet-outbound-smtp00.uk.clara.net (claranet-outbound-smtp00.uk.clara.net [195.8.89.33]) + by bluehome.net (Postfix) with ESMTP id 987A77803A1 + for ; Sat, 1 Jul 2017 10:39:31 -0700 (PDT) +Received: from [79.123.82.65] (port=35732 helo=[192.168.1.105]) + by relay00.mail.eu.clara.net (relay.clara.net [81.171.239.30]:1025) + with esmtpa (authdaemon_plain:roger@firthworks.com) id 1dRMMi-0007nW-03 for jason@bluehome.net + (return-path ); Sat, 01 Jul 2017 17:39:29 +0000 +Subject: Re: The Inform Beginner's Guide +To: Jason Self +References: <1498928270.2632@bluehome.net> +From: Roger Firth +Message-ID: +Date: Sat, 1 Jul 2017 18:39:27 +0100 +User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 + Thunderbird/52.2.1 +MIME-Version: 1.0 +In-Reply-To: <1498928270.2632@bluehome.net> +Content-Type: text/plain; charset=windows-1252; format=flowed +Content-Transfer-Encoding: 7bit + +On 01/07/2017 17:57, Jason Self wrote: +> Thank you. I'll get started on it. I propose adding this, if you're OK +> with it, to acknowledge your copyright in it and so that it can +> continue to be re-shared. (Because otherwise, since it's copyrighted +> by you technically people would need to contact you and ask for +> permission to re-share it each and every time. And if you're OK with +> people sharing copies then it seems easier to go ahead and grant that +> permission upfront.) It also allows for modification so as to keep +> things current as Inform changes (and for translations, etc.) [0] +> +> Copyright Roger Firth . Copying and +> distribution, with or without modification, are permitted in any +> medium without royalty provided the copyright notice and this notice +> are preserved. +> +> [0] https://www.gnu.org/philosophy/free-doc.html + +That's fine by me, Jason. I totaly agree with that philosophy. + +-- +Cheers, Roger \ No newline at end of file -- 2.31.1