Changes between Version 1 and Version 2 of SymbolsCowan


Ignore:
Timestamp:
11/28/12 02:42:20 (5 years ago)
Author:
cowan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SymbolsCowan

    v1 v2  
    1 This WG2 proposal extends Scheme symbols in a variety of traditional Lisp ways: it provides uninterned symbols, symbol values, and property lists.  It can be implemented portably on top of ordinary symbols, provided that the four standard procedures given here are redefined to deal with uninterned symbols as well as ordinary symbols.  For a high-quality implementation, a record facility is needed for uninterned symbols, and a hash table or similar lookup table to associated ordinary symbols with their values and property lists. 
     1This WG2 proposal extends Scheme symbols in a variety of traditional Lisp ways: it provides uninterned symbols, symbol values, and property lists.  It can be implemented portably on top of standard Scheme symbols, provided that the `symbol?`, `symbol=?`, and `symbol->string` procedures are redefined to deal with uninterned symbols as well as standard symbols.  For a high-quality implementation, a record facility is needed for uninterned symbols, and a hash table or similar lookup table to associate standard symbols with their values and property lists. 
    22 
    33== Uninterned symbols == 
    44 
    5 Uninterned symbols are like symbols, except that they have two names, a unique name and a human-readable name (which need not be unique).  Implementations need not guarantee that the unique name is truly unique, but should make a best effort to do so, such as by using a large pseudo-random string of characters as the name. 
     5Uninterned symbols are like standard symbols, except that they have two names, a unique name and a human-readable name (which need not be unique).  Implementations need not guarantee that the unique name is truly unique, but should make a best effort to do so, such as by using a large pseudo-random string of characters as the name. 
    66 
    77`(symbol? `''obj''`)` 
    88 
    9 Returns `#t` if ''obj'' is either an ordinary symbol or an uninterned symbol, and `#f` otherwise.    
     9Returns `#t` if ''obj'' is either a standard symbol or an uninterned symbol, and `#f` otherwise.    
    1010 
    11 `(ordinary-symbol? `''obj''`)` 
     11`(standard-symbol? `''obj''`)` 
    1212 
    13 Returns `#t` if ''obj'' is an ordinary symbol, and `#f` otherwise. 
     13Returns `#t` if ''obj'' is a standard symbol, and `#f` otherwise. 
    1414 
    1515`(uninterned-symbol? `''obj''`)` 
     
    1919`(symbol=? `''symbol1 symbol2'' ... `)` 
    2020 
    21 Returns `#t` if all the ''symbol''s have the same unique name in the sense of `string=?`. 
     21Returns `#t` if all the ''symbol''s have the same unique name in the sense of `string=?`, and `#f` otherwise. 
    2222 
    2323`(symbol->string `''symbol''`)` 
    2424 
    25 Returns the name of ''symbol'' as a string if it is an ordinary symbol, or its human-readable name if it is an uninterned symbol.  It is an error to mutate this string. 
     25Returns the name of ''symbol'' as a string if it is a standard symbol, or its human-readable name if it is an uninterned symbol.  It is an error to mutate this string. 
    2626 
    2727`(string->symbol `''string''`)` 
    2828 
    29 Returns an ordinary symbol whose name is ''string''. 
     29Returns the standard symbol whose name is ''string''.  (Same as the standard version of this procedure.) 
    3030 
    3131`(string->uninterned-symbol `''string''`)` 
    3232 
    33 Returns an uninterned symbol whose human-readable name is ''string'', and whose unique name is chosen by the implementation. 
     33Returns a newly allocated uninterned symbol whose human-readable name is ''string'', and whose unique name is chosen by the implementation. 
    3434 
    3535`(symbol-unique-name `''symbol''`)` 
    3636 
    37 Return the name of ''symbol'' if it is an ordinary symbol, or its unique name if it is an uninterned symbol. 
     37Return the name of ''symbol'' if it is a standard symbol, or its unique name if it is an uninterned symbol. 
    3838 
    3939`(gensym ` [ ''string'' ] `)` 
    4040 
    41 Returns an uninterned symbol whose human-readable name is distinct from that of any symbol returned by a previous call to `gensym`.  If ''string'' is present, it is used as a prefix of the human-readable name. 
     41Returns a newly allocated uninterned symbol whose human-readable name is distinct from that of any symbol returned by a previous call to `gensym`.  If ''string'' is present, it is used as a prefix of the human-readable name. 
    4242 
    4343== Symbol values == 
     
    5353== Property lists == 
    5454 
    55 A property list is a list that can be bound to a symbol.  The original value of a symbol's property list is implementation-dependent.  The structure of a property list is a sequence of symbols known as ''indicators'', some of which may be followed by an arbitrary object known as the indicator's ''value''.  Note that property lists are a list of objects, unlike alists which are a list of pairs. 
     55A property list (plist) is a list that can be bound to a symbol.  The original value of a symbol's plist is implementation-dependent.  The structure of a plist is a sequence of symbols known as ''indicators'', some of which may be followed by an arbitrary object known as the indicator's ''value''.  Note that plists are a list of objects, unlike alists which are a list of pairs. 
    5656 
    5757`(get-property `''symbol indicator'' [ ''obj'' ] `)` 
    5858 
    59 Searches the property list of ''symbol'' for ''indicator''.  If a symbol that is `symbol=?` to ''indicator'' is found on the list, the next object on the list is returned; it is an error if there is no next object.  If there is not, ''obj'' is returned if it is present, and if absent, `#f` is returned. 
     59If a symbol that is `symbol=?` to ''indicator'' is found on the list, the next object on the plist of ''symbol'' is returned; it is an error if there is no next object.  If there is not, ''obj'' is returned if it is present, and if absent, `#f` is returned. 
    6060 
    6161`(get-property-list `''symbol indicator''`)` 
    6262 
    63 If a symbol that is `symbol=?` to ''indicator'' is found on the list, the rest of the list is returned.  If there is not, `#f` is returned. 
     63If a symbol that is `symbol=?` to ''indicator'' is found on the plist of ''symbol'', the rest of the plist is returned.  If there is not, `#f` is returned. 
    6464 
    6565`(set-property! `''symbol indicator obj''`)` 
    6666 
    67 Searches the property list of ''symbol'' for ''indicator''.  If a symbol that is `symbol=?` to ''indicator'' is found on the list, the next object on the list is destructively replaced with ''obj''; it is an error if there is no next object.  If there is not, ''indicator'' and ''obj'' are consed on to the beginning of the property list.   An unspecified value is returned. 
     67If a symbol that is `symbol=?` to ''indicator'' is found on the plist of ''symbol'', the next object on the plist is destructively replaced with ''obj''; it is an error if there is no next object.  If there is not, ''indicator'' and ''obj'' are consed on to the beginning of the plist.   An unspecified value is returned. 
    6868 
    6969`(remove-property! `''symbol indicator''`)` 
    7070 
    71 Searches the property list of ''symbol'' for ''indicator''.  If a symbol that is `symbol=?` to ''indicator'' is found on the list, the indicator and the next object on the list are destructively removed from the list and `#t` is returned; it is an error if there is no next object.  If there is not, nothing is done, and `#f` is returned. 
     71If a symbol that is `symbol=?` to ''indicator'' is found on the plist of ''symbol'', the indicator and the next object on the list are destructively removed from the plist and `#t` is returned; it is an error if there is no next object.  If there is not, nothing is done, and `#f` is returned. 
    7272 
    7373`(symbol-property-list `''symbol''`)` 
    7474 
    75 Returns the property list associated with ''symbol'' without copying it.  The caller is free to mutate the list. 
     75Returns the plist associated with ''symbol'' without copying it.  The caller is free to mutate the returned list. 
    7676 
    7777`(symbol-property-list-set! `''symbol list''`)` 
    7878 
    79 Replaces the property list associated with ''symbol'' with ''list'', which is not copied.  An unspecified value is returned. 
     79The plist associated with ''symbol'' is replaced with ''list'', which is not copied.  An unspecified value is returned. 
    8080 
    8181`(symbol-add-indicators! `''symbol-list indicator''`)` 
    8282 
    83 ''Symbol-list'' is a list of symbols.  The property list of each symbol is searched for ''indicator''.  If a symbol that is `symbol=?` to ''indicator'' is found on the list, nothing is done.  If not, ''indicator'' is consed on to the beginning of the property list.  An unspecified value is returned. 
     83''Symbol-list'' is a list of symbols.  If a symbol that is `symbol=?` to ''indicator'' is found on the plist of ''symbol'', nothing is done.  If not, ''indicator'' is consed on to the beginning of the plist.  An unspecified value is returned. 
    8484 
    8585`(symbol-remove-indicators! `''symbol-list indicator''`)` 
    8686 
    87 ''Symbol-list'' is a list of symbols.  The property list of each symbol is searched for ''indicator''.  If a symbol that is `symbol=?` to ''indicator'' is found on the list, the indicator is destructively removed from the list.  If not, ''indicator'' is consed on to the beginning of the property list.  An unspecified value is returned. 
     87''Symbol-list'' is a list of symbols.  If a symbol that is `symbol=?` to ''indicator'' is found on the plist of ''symbol'', the indicator is destructively removed from the plist.  If not, ''indicator'' is consed on to the beginning of the plist.  An unspecified value is returned. 
     88 
     89== Symbol utilities == 
     90 
     91`(symbol-append ` ''symbol'' ... `)` 
     92 
     93Returns a standard symbol whose name is the concatenation (as if by `string-append`) of the names of the ''symbol''s.  This may be used to construct pseudo-structured symbol names; for example, `(symbol-append prefix ":" name)`.