Previous: , Up: iklib   [Index]


6.53 Miscellaneous functions

Function: neq? obj1 obj2

Compare the arguments as eq? would do, but return a negated result. Equivalent (but more efficient) to:

(not (eq? obj1 obj2))
Function: immediate? obj

Return true if obj is an immediate object: an object contained in a single machine word. Compound objects (like lists and vectors) are not immediate.

Function: void

Return the void value. We should never use the void object as argument for a function application, because the only legitimate use of the void object is as single return value of functions returning “unspecified values” (under Vicare returning a single value is faster than returning zero values). If we need a unique value: we should use the sentinel value (see The sentinel object).

Function: void-object? obj

Return #t if obj is the void value; otherwise return #f.

Function: always-true arg
Function: always-false arg

Always return #t or #f, ignoring the arguments.

Function: expect-single-argument-and-return-it arg
Function: expect-single-argument-and-return-true arg
Function: expect-single-argument-and-return-false arg

These function are used by some syntaxes to check at run–time that an expression returns a single value. If zero, two or more values are returned: the built–in validation mechanism raises an exception at run–time; otherwise the argument is returned or discarded and the return value is #t or #f.

Function: apropos key

Given a string or symbol key, search among the internally installed libraries all the exported bindings having key as substring of their name and print a report to the standard output port. Useful when using the REPL. Example:

vicare> (apropos "-length")
*** in library (vicare):
(bitwise-length bytevector-length string-length
  struct-length vector-length)

*** in library (rnrs):
(bitwise-length bytevector-length string-length
  vector-length)

*** in library (rnrs arithmetic bitwise):
(bitwise-length)

*** in library (rnrs base):
(string-length vector-length)

*** in library (rnrs bytevectors):
(bytevector-length)

*** in library (vicare):
(bitwise-length bytevector-length string-length
  struct-length vector-length)

vicare>
Function: getenv varname

Interface to the C function getenv(), (libc)getenv. Retrieve the value of environment variables. variable must reference a string object representing the name of the environment variable. If the environment variable is set: return a string representing its value; else return false.

(getenv "PATH")
⇒ "/usr/local/bin:/usr/bin:/bin"

The Scheme level representation of environment variables names and values is a string, but internally it is a bytevector; strings are internally converted to bytevectors using string->utf8.

Function: environ

Interface to the global C variable environ, (libc)unsetenv. Retrieve the full environment. Return a list of strings representing the contents of the environ array; if the environment is empty (no environment variables set) return nil.

Function: strerror errno

Return a string describing the errno code errno. Makes use of the system function strerror(). If errno is not a valid errno value: return a string telling it. As special cases errno can be also #t, meaning “unknown error”, and #f, meaning “no error”.

(libc)Error Messages

Function: warning who message irritant ...

Similar to error, but raise a continuable exception with condition components: &warning, &who, &message, &irritants.

Function: random fx

Return a random fixnum object between zero (included) and fx (excluded). fx must be a strictly positive fixnum.

Parameter: exit-hooks

Contains null or a list of thunks to be evaluated by exit whenever the process is normally terminated. Any exception raised by the thunks is catched and discarded. To add an exit hook:

(define (do-something-at-exit)
  ---)

(exit-hooks (cons do-something-at-exit
                  (exit-hooks)))

Previous: , Up: iklib   [Index]