Macaulay2 » Documentation
Packages » ForeignFunctions » ForeignObject » value(ForeignObject)
next | previous | forward | backward | up | index | toc

# value(ForeignObject) -- get the value of a foreign object as a Macaulay2 thing

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

## Description

Convert the given foreign object to the corresponding Macaulay2 thing. The type of the output is determined by the type of the foreign object. Foreign integer objects are converted to ZZ objects.

    i1 : x = int 5

    o1 = 5

    o1 : ForeignObject of type int32

    i2 : value x

    o2 = 5

Foreign real objects are converted to RR objects.

    i3 : x = double 5

    o3 = 5

    o3 : ForeignObject of type double

    i4 : value x

    o4 = 5

    o4 : RR (of precision 53)

Foreign pointer objects are converted to Pointer objects.

    i5 : x = voidstar address int 5

    o5 = 0x7728fbd04030

    o5 : ForeignObject of type void*

    i6 : value x

    o6 = 0x7728fbd04030

    o6 : Pointer

Foreign string objects are converted to strings.

    i7 : x = charstar "Hello, world!"

    o7 = Hello, world!

    o7 : ForeignObject of type char*

    i8 : value x

    o8 = Hello, world!

Foreign array objects are converted to lists.

    i9 : x = (4 * int) {2, 4, 6, 8}

    o9 = {2, 4, 6, 8}

    o9 : ForeignObject of type int32[4]

    i10 : value x

    o10 = {2, 4, 6, 8}

    o10 : List

Foreign struct and union objects are converted to hash tables.

    i11 : mystruct = foreignStructType("mystruct", {"a" => int, "b" => float})

    o11 = mystruct

    o11 : ForeignStructType

    i12 : x = mystruct {"a" => 2, "b" => sqrt 2}

    o12 = HashTable{"a" => 2      }
                    "b" => 1.41421

    o12 : ForeignObject of type mystruct

    i13 : value x

    o13 = HashTable{"a" => 2      }
                    "b" => 1.41421

    o13 : HashTable

Note that this function is also used by describe, expression, net, texMath, toExternalString, and toString for representing foreign objects.

## Ways to use this method:

- `value(charstar)`
- `value(charstarstar)`
- `value(double)`
- `value(float)`
- value(ForeignObject) -- get the value of a foreign object as a Macaulay2 thing
- `value(int8)`
- `value(int16)`
- `value(int32)`
- `value(int64)`
- `value(uint8)`
- `value(uint16)`
- `value(uint32)`
- `value(uint64)`
- `value(voidstar)`
- `value(voidstarstar)`

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