| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
36.1 Shared And Read Only Strings 36.2 `Sloppy' List Membership Procedures `Sloppy' list membership procedures. 36.3 Strange Variations on evalStrange 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] | [ ? ] |
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] | [ ? ] |
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.
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] | [ ? ] |
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/ |
#t if obj is either a string or a symbol,
otherwise return #f.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
memq, but does no type or error checking.
Its use is recommended only in writing Guile internals,
not for high-level Scheme programs.
memv, but does no type or error checking.
Its use is recommended only in writing Guile internals,
not for high-level Scheme programs.
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] | [ ? ] |
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.
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.
end-of-file error is
signalled.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
** 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] | [ ? ] |
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.
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.
#t if obarray contains a symbol with name
string, and #f otherwise.
#t if the symbol was present and #f
otherwise.
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.
#f,
use the global symbol table. If string is not interned in
obarray, an error is signalled.
#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.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
tag fseek list*
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |