[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

36. Deprecated

36.1 Shared And Read Only Strings  
36.2 `Sloppy' List Membership Procedures  `Sloppy' list membership procedures.
36.3 Strange Variations on eval  Strange variations on eval.
36.4 Closing All Ports Except Some ...  Closing all ports except some ...
36.5 Old Method for Registering C Modules.  Old method for registering C modules.
36.6 Obarray Symbol Manipulation  Obarray symbol manipulation.
36.7 Previously Deprecated Items Now Removed  Previously deprecated, now removed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

36.1 Shared And Read Only Strings

The procedures described in this section are deprecated because explicit shared substrings are planned to disappear from Guile.

Instead, all strings will be implemented using sharing internally, combined with a copy-on-write strategy. Once internal string sharing and copy-on-write have been implemented, it will be unnecessary to preserve the concept of read only strings.

36.1.1 Shared Substrings  Strings which share memory with each other.
36.1.2 Read Only Strings  Treating certain non-strings as strings.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

36.1.1 Shared Substrings

Whenever you extract a substring using substring, the Scheme interpreter allocates a new string and copies data from the old string. This is expensive, but substring is so convenient for manipulating text that programmers use it often.

Guile Scheme provides the concept of the shared substring to improve performance of many substring-related operations. A shared substring is an object that mostly behaves just like an ordinary substring, except that it actually shares storage space with its parent string.

Deprecated Scheme Procedure: make-shared-substring str [start [end]]
Deprecated C Function: scm_make_shared_substring (str, start, end)
Return a shared substring of str. The arguments are the same as for the substring function: the shared substring returned includes all of the text from str between indexes start (inclusive) and end (exclusive). If end is omitted, it defaults to the end of str. The shared substring returned by make-shared-substring occupies the same storage space as str.

Example:

 
(define foo "the quick brown fox")
(define bar (make-shared-substring some-string 4 9))

foo => "t h e   q u i c k   b r o w n   f o x"
bar =========> |---------|

The shared substring bar is not given its own storage space. Instead, the Guile interpreter notes internally that bar points to a portion of the memory allocated to foo. However, bar behaves like an ordinary string in most respects: it may be used with string primitives like string-length, string-ref, string=?. Guile makes the necessary translation between indices of bar and indices of foo automatically.

 
(string-length? bar) => 5	; bar only extends from indices 4 to 9
(string-ref bar 3)  => #\c	; same as (string-ref foo 7)
(make-shared-substring bar 2)
  => "ick"			; can even make a shared substring!

Because creating a shared substring does not require allocating new storage from the heap, it is a very fast operation. However, because it shares memory with its parent string, a change to the contents of the parent string will implicitly change the contents of its shared substrings.

 
(string-set! foo 7 #\r)
bar => "quirk"

Guile considers shared substrings to be immutable. This is because programmers might not always be aware that a given string is really a shared substring, and might innocently try to mutate it without realizing that the change would affect its parent string. (We are currently considering a "copy-on-write" strategy that would permit modifying shared substrings without affecting the parent string.)

In general, shared substrings are useful in circumstances where it is important to divide a string into smaller portions, but you do not expect to change the contents of any of the strings involved.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

36.1.2 Read Only Strings

In previous versions of Guile, there was the idea that some string-based primitives such as string-append could equally accept symbols as arguments. For example, one could write

 
(string-append '/home/ 'vigilia)

and get "/home/vigilia" as the result. The term read only string was adopted to describe the argument type expected by such primitives.

This idea has now been removed. The predicate read-only-string? still exists, but deprecated, and is equivalent to

 
(lambda (x) (or (string? x) (symbol? x)))

But no Guile primitives now use read-only-string? to validate their arguments.

String-based primitives such as string-append now require strings:

 
(string-append '/home/ 'vigilia)
=>
ERROR: Wrong type argument (expecting STRINGP): /home/

Deprecated Scheme Procedure: read-only-string? obj
Deprecated C Function: scm_read_only_string_p (obj)
Return #t if obj is either a string or a symbol, otherwise return #f.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

36.2 `Sloppy' List Membership Procedures

The following are equivalent to memq, memv and member respectively, except that they do not fully type-check the arguments that they are given. They are deprecated because the lack of proper type-checking makes them dangerous.

Deprecated Scheme Procedure: sloppy-memq x lst
Deprecated C Function: scm_sloppy_memq (x, lst)
This procedure behaves like memq, but does no type or error checking. Its use is recommended only in writing Guile internals, not for high-level Scheme programs.

Deprecated Scheme Procedure: sloppy-memv x lst
Deprecated C Function: scm_sloppy_memv (x, lst)
This procedure behaves like memv, but does no type or error checking. Its use is recommended only in writing Guile internals, not for high-level Scheme programs.

Deprecated Scheme Procedure: sloppy-member x lst
Deprecated C Function: scm_sloppy_member (x, lst)
This procedure behaves like member, but does no type or error checking. Its use is recommended only in writing Guile internals, not for high-level Scheme programs.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

36.3 Strange Variations on eval

eval2 was useful in previous Guile releases because the eval in those releases was a single argument eval that did not conform to R5RS. Guile's standard eval now requires a second environment-specifier argument (which Guile interprets as the module in which to evaluate the specified code expression). Hence eval is now R5RS-compliant, and eval2 is obsolete and therefore deprecated.

Deprecated Scheme Procedure: eval2 obj env_thunk
Deprecated C Function: scm_eval2 (obj, env_thunk)
Evaluate exp, a Scheme expression, in the environment designated by lookup, a symbol-lookup function. Do not use this version of eval, it does not play well with the module system. Use eval or primitive-eval instead.

In previous Guile releases, the implementation of expressions like (eval (read port)) was deficient in that source properties associated with the expression returned by the read would be lost during the eval. To provide a way of performing a read and evaluation without losing source properties, read-and-eval! was invented.

In this Guile release, evaluation always preserves source property information. So read-and-eval! is now unnecessary.

Deprecated Scheme Procedure: read-and-eval! [port]
Deprecated C Function: scm_read_and_eval_x (port)
Read a form from port (standard input by default), and evaluate it (memoizing it in the process) in the top-level environment. If no data is left to be read from port, an end-of-file error is signalled.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

36.4 Closing All Ports Except Some ...

Deprecated Scheme Procedure: close-all-ports-except . ports
Deprecated C Function: scm_close_all_ports_except (ports)
[DEPRECATED] Close all open file ports used by the interpreter except for those supplied as arguments. This procedure was intended to be used before an exec call to close file descriptors which are not needed in the new process. However it has the undesirable side effect of flushing buffers, so it's deprecated. Use port-for-each instead.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

36.5 Old Method for Registering C Modules.

** Auto-loading of compiled-code modules is deprecated.

Guile used to be able to automatically find and link a shared library to satisfy requests for a module. For example, the module `(foo bar)' could be implemented by placing a shared library named "foo/libbar.so" (or with a different extension) in a directory on the load path of Guile.

This has been found to be too tricky, and is no longer supported. The shared libraries are now called "extensions". You should now write a small Scheme file that calls `load-extension' to load the shared library and initialize it explicitely.

The shared libraries themselves should be installed in the usual places for shared libraries, with names like "libguile-foo-bar".

For example, place this into a file "foo/bar.scm"

(define-module (foo bar))

(load-extension "libguile-foo-bar" "foobar_init")


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

36.6 Obarray Symbol Manipulation

Guile's module mechanism uses obarrays, which are hash tables that map symbols to variables. Guile 1.4 included a group of primitives that could be used for the manipulation of the symbol-variable mappings in such obarrays.

However, considering the availability both of low-level procedures for operating on hash tables in general (see section 22.7.3 Hash Tables), and of a dedicated API for module-related operations (see section 31. Modules), the intermediate set of obarray primitives is no longer useful, and --- which is worse -- makes it more difficult to evolve the implementation of Guile's module system. Hence this set of primitives has now been deprecated.

If you have code using these functions, please change it to use either hash table or module-related operations.

Deprecated Scheme Procedure: gentemp [prefix [obarray]]
Deprecated C Function: scm_gentemp (prefix, obarray)
Create a new symbol with a name unique in an obarray. The name is constructed from an optional string prefix and a counter value. The default prefix is t. The obarray is specified as a second optional argument. Default is the system obarray where all normal symbols are interned. The counter is increased by 1 at each call. There is no provision for resetting the counter.

Deprecated Scheme Procedure: intern-symbol obarray string
Deprecated C Function: scm_intern_symbol (obarray, string)
Add a new symbol to obarray with name string, bound to an unspecified initial value. The symbol table is not modified if a symbol with this name is already present.

Deprecated Scheme Procedure: symbol-interned? obarray string
Deprecated C Function: scm_symbol_interned_p (obarray, string)
Return #t if obarray contains a symbol with name string, and #f otherwise.

Deprecated Scheme Procedure: unintern-symbol obarray string
Deprecated C Function: scm_unintern_symbol (obarray, string)
Remove the symbol with name string from obarray. This function returns #t if the symbol was present and #f otherwise.

Deprecated Scheme Procedure: string->obarray-symbol obarray string [soft?]
Deprecated C Function: scm_string_to_obarray_symbol (obarray, string, soft_p)
Intern a new symbol in obarray, a symbol table, with name string.

If obarray is #f, use the default system symbol table. If obarray is #t, the symbol should not be interned in any symbol table; merely return the pair (symbol . #<undefined>).

The soft? argument determines whether new symbol table entries should be created when the specified symbol is not already present in obarray. If soft? is specified and is a true value, then new entries should not be added for symbols not already present in the table; instead, simply return #f.

Deprecated Scheme Procedure: symbol-binding obarray string
Deprecated C Function: scm_symbol_binding (obarray, string)
Look up in obarray the symbol whose name is string, and return the value to which it is bound. If obarray is #f, use the global symbol table. If string is not interned in obarray, an error is signalled.

Deprecated Scheme Procedure: symbol-bound? obarray string
Deprecated C Function: scm_symbol_bound_p (obarray, string)
Return #t if obarray contains a symbol with name string bound to a defined value. This differs from symbol-interned? in that the mere mention of a symbol usually causes it to be interned; symbol-bound? determines whether a symbol has been given any meaningful value.

Deprecated Scheme Procedure: symbol-set! obarray string value
Deprecated C Function: scm_symbol_set_x (obarray, string, value)
Find the symbol in obarray whose name is string, and rebind it to value. An error is signalled if string is not present in obarray.

Deprecated Scheme Procedure: builtin-bindings
Deprecated C Function: scm_builtin_bindings
Create and return a copy of the global symbol table, removing all unbound symbols.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

36.7 Previously Deprecated Items Now Removed

tag fseek list*


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Ingo Ruhnke on September, 12 2002 using texi2html