Type handling

Arc has functions to convert types and to determine the type of an object.

Type handling

annotate type obj
Tags the object with the given type.
>(type (annotate 'mac car))
mac
rep obj
Returns the underlying object for an annotated object
>(rep whilet)
#<procedure: whilet>
sym x
Coerces x to a 'sym.
>(sym "a")
a
coerce obj type [args]
Coerces object to a new type. A char can be coerced to int, string, or sym. A number can be coerced to int, char, or string (of specified base). A string can be coerced to sym, cons (char list), or int (of specified base). A list of characters can be coerced to a string. A symbol can be coerced to a string.
>(coerce "a" 'sym)
a
>(coerce 65 'char)
#\A
>(coerce 65 'int 2)
65
>(coerce "abc" 'cons)
(#\a #\b #\c)
int x [base]
Coerces x to an integer. New in arc3.
>(int "3.14")
3
>(int "1111" 2)
15
>(int #\a)
97
type object
Returns the type of an object (as a symbol). Possibilities are cons, sym, fn, char, string, int, num, table, output, input, socket, exception, or mac.
>(type 1)
int
>(type car)
fn

Copyright 2008 Ken Shirriff.