Macaulay2 » Documentation
Packages » ForeignFunctions » ForeignObject » foreignObject
next | previous | forward | backward | up | index | toc

# foreignObject -- construct a foreign object

- Usage:
    `foreignObject x`
- Inputs:
  - x, a thing,
- Outputs:
  - a foreign object,

## Description

This function constructs a ForeignObject. The type is determined automatically based on type of the input. Integers are converted to int32 objects.

    i1 : foreignObject 5

    o1 = 5

    o1 : ForeignObject of type int32

Non-integers are converted to double objects.

    i2 : foreignObject pi

    o2 = 3.141592653589793

    o2 : ForeignObject of type double

Strings are converted to charstar objects.

    i3 : foreignObject "Hello, world!"

    o3 = Hello, world!

    o3 : ForeignObject of type char*

Pointers are converted to voidstar objects.

    i4 : foreignObject nullPointer

    o4 = (nil)

    o4 : ForeignObject of type void*

Lists are converted to foreign objects with the appropriate ForeignArrayType.

    i5 : foreignObject {1, 3, 5, 7, 9}

    o5 = {1, 3, 5, 7, 9}

    o5 : ForeignObject of type int32[5]

No conversion is done when the input is already a foreign object.

    i6 : foreignObject oo

    o6 = {1, 3, 5, 7, 9}

    o6 : ForeignObject of type int32[5]

## Ways to use foreignObject:

- `foreignObject(ForeignObject)`
- `foreignObject(Number)`
- `foreignObject(Pointer)`
- `foreignObject(String)`
- `foreignObject(VisibleList)`
- `foreignObject(ZZ)`

## For the programmer

The object foreignObject is a method function.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/ForeignFunctions.m2:1755:0.