Macaulay2 » Documentation
Packages » ForeignFunctions :: ForeignPointerArrayType
next | previous | forward | backward | up | index | toc

ForeignPointerArrayType -- foreign type for NULL-terminated arrays of pointers


This is the class for a particular kind of array type, where the entries of each array are some sort of pointer type and the lengths are arbitrary. There are two built-in types, charstarstar (for arrays of strings) and voidstarstar (for arrays of pointers), but more types may be constructed using foreignPointerArrayType.

i1 : charstarstar {"foo", "bar", "baz"}

o1 = {foo, bar, baz}

o1 : ForeignObject of type char**
i2 : charstarstar {"the", "quick", "brown", "fox", "jumps", "over", "the",
         "lazy", "dog"}

o2 = {the, quick, brown, fox, jumps, over, the, lazy, dog}

o2 : ForeignObject of type char**
i3 : voidstarstar {address int 0, address int 1, address int 2}

o3 = {0x77289dc8e3d0, 0x77289dc8e3c0, 0x77289dc8e3b0}

o3 : ForeignObject of type void**

Foreign pointer arrays may be subscripted using _.

i4 : x = charstarstar {"foo", "bar", "baz"}

o4 = {foo, bar, baz}

o4 : ForeignObject of type char**
i5 : x_1

o5 = bar

o5 : ForeignObject of type char*
i6 : x_(-1)

o6 = baz

o6 : ForeignObject of type char*

Their lengths may be found using length.

i7 : length x

o7 = 3

They are also iterable.

i8 : i = iterator x;
i9 : next i

o9 = foo

o9 : ForeignObject of type char*
i10 : next i

o10 = bar

o10 : ForeignObject of type char*
i11 : scan(x, print)

They may also be modified using subscripted assignment.

i12 : x_0 = "qux"

o12 = qux

o12 : ForeignObject of type char*
i13 : x

o13 = {qux, bar, baz}

o13 : ForeignObject of type char**

Functions and methods returning a foreign array type :

Methods that use a foreign array type :

Fixed objects of class ForeignPointerArrayType :

For the programmer

The object ForeignPointerArrayType is a type, with ancestor classes ForeignType < Type < MutableHashTable < HashTable < Thing.