Back to library index.

Package std-query (in std.i) - finding out variable type and properties

Index of documented functions or symbols:

am_subroutine

DOCUMENT am_subroutine()
  returns 1 if the current Yorick function was invoked as a subroutine,
  else 0.  If am_subroutine() returns true, the result of the current
  function will not be used, and need not be computed (the function
  has been called for its side effects only).

dimsof

DOCUMENT dimsof(object)
      or dimsof(object1, object2, ...)
  returns a vector of integers describing the dimensions of OBJECT.
  The format of the vector is [number of dims, length1, length2, ...].
  The orgsof function returns the origin of each dimension (normally 1).
  If more than one argument is given, dimsof returns the dimension
  list of the result of binary operations between all the objects,
  or nil if the objects are not conformable.

SEE ALSO: typeof, structof, numberof, sizeof, orgsof

identof

DOCUMENT identof(object)
  Returns type identifier of OBJECT as a long integer:
    0 (Y_CHAR)      for an array of char('s)
    1 (Y_SHORT)     for an array of short('s)
    2 (Y_INT)       for an array of int('s)
    3 (Y_LONG)      for an array of long('s)
    4 (Y_FLOAT)     for an array of float('s)
    5 (Y_DOUBLE)    for an array of double('s)
    6 (Y_COMPLEX)   for an array of complex('s)
    7 (Y_STRING)    for an array of string('s)
    8 (Y_POINTER)   for an array of pointer('s)
    9 (Y_STRUCT)    for a structure object
   10 (Y_RANGE)     for a range object
   11 (Y_LVALUE)    for a lvalue
   12 (Y_VOID)      for a void (undefined) object
   13 (Y_FUNCTION)  for a function array
   14 (Y_BUILTIN)   for a builtin array
   15 (Y_STRUCTDEF) for a data type or structure definition
   16 (Y_STREAM)    for a file stream
   17 (Y_OPAQUE)    for an opaque object

SEE ALSO: typeof, structof.

is_array

DOCUMENT is_array(object)
  returns 1 if OBJECT is an array data type (as opposed to a function,
  structure definition, index range, I/O stream, etc.), else 0.
  An array OBJECT can be written to or read from a binary file;
  non-array Yorick data types cannot.

SEE ALSO: is_func, is_void, is_range, is_struct, is_stream, is_scalar

is_complex

SEE: is_integer

is_func

DOCUMENT is_func(object)
  returns 1 if OBJECT is a Yorick interpreted function, 2 if OBJECT
  is a built-in (that is, compiled) function, 3 if OBJECT is an
  autoload, 4 if object is a wrap_args function, 5 if object
  is a closure function, else 0.

SEE ALSO: is_array, is_void, is_range, is_struct, is_stream, autoload, closure

is_integer

DOCUMENT is_integer(x)
      or is_real(x)
      or is_complex(x)
      or is_numerical(x)
      or is_string(x)
      or is_pointer(x)
  These functions  return true if  X is an  array of type:  integer, real
  (i.e.  double or  float), complex,  numerical (i.e.  integer,  real or
  complex), string, or pointer.

SEE ALSO: structof, dimsof, is_array, is_func, is_hash, is_list, is_range, is_scalar, is_stream, is_struct, is_void.

is_list

DOCUMENT is_list(object)
  returns 1 if OBJECT is a list or nil, else 0 (see _lst).

SEE ALSO: is_array, is_func, is_void, is_range, is_struct, _lst

is_matrix

SEE: is_scalar

is_numerical

SEE: is_integer

is_pointer

SEE: is_integer

is_range

DOCUMENT is_range(object)
  returns 1 if OBJECT is an index range (e.g.-  3:5 or 11:31:2),
  else 0.

SEE ALSO: is_array, is_func, is_void, is_struct, is_stream

is_real

SEE: is_integer

is_scalar

DOCUMENT is_scalar(x)
      or is_vector(x)
      or is_matrix(x)
  These functions return true if X is (respectively) a scalar, a vector
  (i.e., a 1-D array), or a matrix (i.e., a 2-D array).

SEE ALSO: dimsof, is_array, is_func, is_hash, is_integer, is_list, is_range, is_stream, is_struct, is_void.

is_stream

DOCUMENT is_stream(object)
  returns 1 if OBJECT is a binary I/O stream (usually a file), else 0.
  The _read and _write functions work on object if and only if
  is_stream returns non-zero.  Note that is_stream returns 0 for a
  text stream -- you need the typeof function to test for those.

SEE ALSO: is_array, is_func, is_void, is_range, is_struct

is_string

SEE: is_integer

is_struct

DOCUMENT is_struct(object)
  returns 1 if OBJECT is the definition of a Yorick struct, else 0.
  Thus, is_struct(double) returns 1, but is_struct(1.0) returns 0.

SEE ALSO: is_array, is_func, is_void, is_range, is_stream

is_vector

SEE: is_scalar

is_void

DOCUMENT is_void(object)
  returns 1 if OBJECT is nil (the one instance of the void data type),
  else 0.

SEE ALSO: is_array, is_func, is_range, is_struct, is_stream

nameof

DOCUMENT nameof(object)
  If OBJECT is a function or a structure definition, returns the
  name of the func or struct as it was defined (not necessarily
  the name of the variable passed to the nameof function).

SEE ALSO: typeof

numberof

DOCUMENT numberof(object)
  returns the number of elements if object is an array, or 0 if not.

SEE ALSO: sizeof, dimsof, typeof, structof

orgsof

DOCUMENT orgsof(object)
  returns a vector of integers describing the dimensions of OBJECT.
  The format of the vector is [number of dims, origin1, origin2, ...].
  By default, dimension origins are ignored, but use_origins changes
  this.  The dimsof function returns the length of each dimension.
  *** NOTE NOTE NOTE ***
  Unless use_origins(1) is in effect, orgsof will always return
  1 for all of the originI in the list.  Thus, whether use_origins(1)
  is in effect or not, you are guaranteed that x(orgsof(x)(2)) is the
  first element of x.

  *** DEPRECATED ***
  Do not use index origins.  Your brain will explode sooner or later.

SEE ALSO: dimsof, typeof, structof, numberof, sizeof, use_origins

sizeof

DOCUMENT sizeof(object)
  returns the size of the object in bytes, or 0 for non-array objects.
  sizeof(structure_definition) returns the number of bytes per instance.
  sizeof(binary_file) returns the file size in bytes.

SEE ALSO: dimsof, typeof, structof, numberof

structof

DOCUMENT structof(object)
  returns the data type of OBJECT, or nil for non-array OBJECTs.
  Use typeof(object) to get the ASCII name of a the data type.

SEE ALSO: typeof, dimsof, numberof, sizeof, nameof

typeof

DOCUMENT typeof(object)
  returns a string describing the type of object.  For the basic
  data types, these are "char", "short", "int", "long", "float",
  "double", "complex", "string", "pointer", "struct_instance",
  "void", "range", "struct_definition", "function", "builtin",
  "stream" (for a binary stream), and "text_stream".

SEE ALSO: structof, dimsof, sizeof, numberof, nameof

use_origins

DOCUMENT dummy= use_origins(dont_force)
  Yorick array dimensions have an origin as well as a length.
  By default, this origin is 1 (like FORTRAN arrays, unlike C
  arrays).  However, the array function and the pseudo-index (-)
  can be used to produce arrays with other origins.

  Initially, the origin of an array index is ignored by Yorick; the
  first element of any array has index 1.  You can change this
  default behavior by calling use_origins with non-zero DONT_FORCE,
  and restore the default behavior by calling use_origins(0).

  When the returned object DUMMY is destroyed, either by return from
  the function in which it is a local variable, or by explicit
  redefintion of the last reference to it, the treatment of array
  index origins reverts to the behavior prior to the call to
  use_origins.  Thus, you can call use_origins at the top of a
  function and not worry about restoring the external behavior
  before every possible return (including errors).

  *** DEPRECATED ***
  Do not use index origins.  Your brain will explode sooner or later.

SEE ALSO: array, dimsof, orgsof

Y_BUILTIN

SEE: identof

Y_CHAR

SEE: identof

Y_COMPLEX

SEE: identof

Y_DOUBLE

SEE: identof

Y_FLOAT

SEE: identof

Y_FUNCTION

SEE: identof

Y_INT

SEE: identof

Y_LONG

SEE: identof

Y_LVALUE

SEE: identof

Y_OPAQUE

SEE: identof

Y_POINTER

SEE: identof

Y_RANGE

SEE: identof

Y_SHORT

SEE: identof

Y_STREAM

SEE: identof

Y_STRING

SEE: identof

Y_STRUCT

SEE: identof

Y_STRUCTDEF

SEE: identof

Y_VOID

SEE: identof