next | previous | forward | backward | up | top | index | toc | Macaulay2 website
ForeignFunctions :: foreignUnionType

foreignUnionType -- construct a foreign union type

Synopsis

Description

To construct a foreign union type, specify a name and a list of the members. Each member should be an Option of the form memberName => memberType, where memberName is a String and memberType is a ForeignType.

i1 : myunion = foreignUnionType("myunion",
         {"foo" => 4 * char', "bar" => charstar})

o1 = myunion

o1 : ForeignUnionType

Use _ to return a single member of a foreign union.

i2 : x = myunion (4 * char') append(ascii "hi!", 0)

o2 = HashTable{bar => hi!              }
               foo => {104, 105, 33, 0}

o2 : ForeignObject of type myunion
i3 : x_"foo"

o3 = {104, 105, 33, 0}

o3 : ForeignObject of type int8[4]
i4 : x_"bar"

o4 = hi!

o4 : ForeignObject of type char*

Ways to use foreignUnionType :

For the programmer

The object foreignUnionType is a method function.