F64 val) & Real[B] val)](
a: B)
: Real[A] val^

Parameters¶

a: B

Returns¶

Real[A] val^

min_value¶
[Source]
new val min_value()
: Real[A] val^

Returns¶


fun ref set_up(h: TestHelper) ? =>
"""
Set up the testing environment before a test method is called.
Default is to do nothing.
"""
None

fun ref tear_down(h: TestHelper) =>
"""
Tidy up after the test has completed.
Called for each run test, whether that test passed, succeeded or timed out.
The default is to do nothing.
"""
None

fun label(): String =>
"""
Report the test label, returning an empty string for none.
It can be later use to filter tests which we want to run, by labels.


fun val reverse()
: Vec[A] val

Returns¶

Vec[A] val

keys¶
[Source]
Return an iterator over the indices in the vector.
fun val keys()
: VecKeys[A] ref^

Returns¶

VecKeys[A] ref^

values¶


use @"llvm.bswap.i16"[U16](src: U16)
use @"llvm.bswap.i32"[U32](src: U32)
use @"llvm.bswap.i64"[U64](src: U64)
use @"llvm.bswap.i128"[U128](src: U128)
use @"llvm.ctpop.i8"[U8](src: U8)
use @"llvm.ctpop.i16"[U16](src: U16)
use @"llvm.ctpop.i32"[U32](src: U32)
use @"llvm.ctpop.i64"[U64](src: U64)
use @"llvm.ctpop.i128"[U128](src: U128)
use @"llvm.ctlz.i8"[U8](src: U8, is_zero_undef: Bool)
use @"llvm.ctlz.i16"[U16](src: U16, is_zero_undef: Bool)
use @"llvm.ctlz.i32"[U32](src: U32, is_zero_undef: Bool)
use @"llvm.ctlz.i64"[U64](src: U64, is_zero_undef: Bool)
use @"llvm.ctlz.i128"[U128](src: U128, is_zero_undef: Bool)
use @"llvm.cttz.i8"[U8](src: U8, zero_undef: Bool)
use @"llvm.cttz.i16"[U16](src: U16, zero_undef: Bool)
use @"llvm.cttz.i32"[U32](src: U32, zero_undef: Bool)
use @"llvm.cttz.i64"[U64](src: U64, zero_undef: Bool)
use @"llvm.cttz.i128"[U128](src: U128, zero_undef: Bool)
use @"llvm.uadd.with.overflow.i8"[(U8, Bool)](a: U8, b: U8)


fun box u128_unsafe()
: U128 val

Returns¶

U128 val

ulong_unsafe¶
[Source]
fun box ulong_unsafe()
: ULong val

Returns¶

ULong val

usize_unsafe¶
[Source]


fun box sctp_smallest_pmtu()
: I32 val

Returns¶

I32 val

sctp_ss_default¶
[Source]
fun box sctp_ss_default()
: I32 val

Returns¶

I32 val

sctp_ss_fair_bandwith¶
[Source]


1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511


# Default arguments

When defining a method you can provide default values for any of the arguments. The caller then has the choice to use the values you have provided or to provide their own. Default argument values are specified with a `=` after the parameter name.

```pony
class Coord
var _x: U32
var _y: U32

new create(x: U32 = 0, y: U32 = 0) =>
_x = x
_y = y

class Bar
fun f() =>
var a: Coord = Coord.create()     // Contains (0, 0)
var b: Coord = Coord.create(3)    // Contains (3, 0)
var c: Coord = Coord.create(3, 4) // Contains (3, 4)
```


done¶
[Source]
Return an array of buffered ByteSeqs and reset the Writer's buffer.
fun ref done()
: Array[(String val | Array[U8 val] val)] iso^

Returns¶

Array[(String val | Array[U8 val] val)] iso^


Returns¶

Bool val

expect¶
[Source]
Called when the connection has been told to expect a certain quantity of
bytes. This allows nested notifiers to change the expected quantity, which
allows a lower level protocol to handle any framing (e.g. SSL).
fun ref expect(
conn: TCPConnection ref,
qty: USize val)
: USize val

Parameters¶

conn: TCPConnection ref
qty: USize val


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51


USize val

f32¶
[Source]
fun box f32()
: F32 val

Returns¶

F32 val

f64¶
[Source]
fun box f64()
: F64 val

Returns¶


fun posix(): Bool => bsd() or linux() or osx()
fun windows(): Bool => compile_intrinsic

fun x86(): Bool => compile_intrinsic
fun arm(): Bool => compile_intrinsic
fun riscv(): Bool => compile_intrinsic

fun lp64(): Bool => compile_intrinsic
fun llp64(): Bool => compile_intrinsic
fun ilp32(): Bool => compile_intrinsic

fun bigendian(): Bool => compile_intrinsic
fun littleendian(): Bool => compile_intrinsic

fun native128(): Bool => compile_intrinsic
fun debug(): Bool => compile_intrinsic
fun runtimestats(): Bool => compile_intrinsic
fun runtimestatsmessages(): Bool => compile_intrinsic


A

hash¶
[Source]
fun box hash()
: USize val

Returns¶

USize val

hash64¶
[Source]
fun box hash64()
: U64 val

Returns¶


fun box ipv6_flowlabel_mgr()
: I32 val

Returns¶

I32 val

ipv6_fl_a_get¶
[Source]
fun box ipv6_fl_a_get()
: I32 val

Returns¶

I32 val

ipv6_fl_a_put¶
[Source]


: N

Parameters¶

n: N

Returns¶

N

int_unbiased[optional N: ((U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val) & Real[N] val)]¶
[Source]
fun ref int_unbiased[optional N: ((U8 val | U16 val | U32 val |
U64 val | U128 val | ULong val |
USize val) & Real[N] val)](
n: N)
: N

Parameters¶


fun box tipc_reserved_types()
: I32 val

Returns¶

I32 val

tipc_retdata¶
[Source]
fun box tipc_retdata()
: I32 val

Returns¶

I32 val

tipc_sock_recvq_depth¶
[Source]


912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931


532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551


Returns¶

A

powi¶
[Source]
fun box powi(
y: I32 val)
: A

Parameters¶

y: I32 val

Returns¶

A


new val create(
value: U8 val)
: U8 val^

Parameters¶

value: U8 val

Returns¶

U8 val^

from[B: ((I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val | U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val | F32 val | F64 val) & Real[B] val)]¶
[Source]
new val from[B: ((I8 val | I16 val | I32 val |
I64 val | I128 val | ILong val |
ISize val | U8 val | U16 val |
U32 val | U64 val | U128 val |
ULong val | USize val | F32 val |


ctrl: Bool val
alt: Bool val
shift: Bool val

Returns¶

None val

down¶
[Source]
fun ref down(
ctrl: Bool val,
alt: Bool val,
shift: Bool val)
: None val

Parameters¶

ctrl: Bool val


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


Parameters¶

process: ProcessMonitor ref

Returns¶

None val

stdout¶
[Source]
ProcessMonitor calls this when new data is received on STDOUT of the
forked process
fun ref stdout(
process: ProcessMonitor ref,
data: Array[U8 val] iso)
: None val

Parameters¶


Bool val

le¶
[Source]
Return true if every element in this is also in that.
fun box le(
that: HashSet[A, H] box)
: Bool val

Parameters¶

that: HashSet[A, H] box

Returns¶

Bool val

gt¶


# Calling

As in many other languages, methods in Pony are called by providing the arguments within parentheses after the method name. The parentheses are required even if there are no arguments being passed to the method.

```pony
class Foo
fun hello(name: String): String =>
"hello " + name

fun f() =>
let a = hello("Fred")
```

Constructors are usually called "on" a type, by specifying the type that is to be created. To do this just specify the type, followed by a dot, followed by the name of the constructor you want to call.

```pony
class Foo
var _x: U32

new create() =>


(0, 1) (1, 2) (2, 3)
fun ref enum[optional B: (Real[B] val & (I8 val | I16 val | I32 val |
I64 val | I128 val | ILong val |
ISize val | U8 val | U16 val |
U32 val | U64 val | U128 val |
ULong val | USize val | F32 val |
F64 val))]()
: Iter[(B , A)] ref^

Returns¶

Iter[(B , A)] ref^

filter¶
[Source]
Return an iterator that only returns items that match the predicate f.
Example¶
Iter[I64]([1; 2; 3; 4; 5; 6].values())
.filter({(x) => (x % 2) == 0 })


use @open[I32](path: Pointer[U8] tag, flags: I32, ...) if not windows
use @_read[I32](fd: I32, buffer: Pointer[None], bytes_to_read: I32) if windows
use @read[ISize](fd: I32, buffer: Pointer[None], bytes_to_read: USize)
if not windows
use @_write[I32](fd: I32, buffer: Pointer[None], bytes_to_send: I32) if windows
use @writev[ISize](fd: I32, buffer: Pointer[None], num_to_send: I32)
if not windows
use @_lseeki64[I64](fd: I32, offset: I64, base: I32) if windows
use @lseek64[I64](fd: I32, offset: I64, base: I32) if linux
use @lseek[I64](fd: I32, offset: I64, base: I32) if not windows and not linux
use @FlushFileBuffers[Bool](file_handle: Pointer[None]) if windows
use @_get_osfhandle[Pointer[None]](fd: I32) if windows
use @fsync[I32](fd: I32) if not windows
use @fdatasync[I32](fd: I32) if not windows
use @_chsize_s[I32](fd: I32, len: I64) if windows
use @ftruncate64[I32](fd: I32, len: I64) if linux
use @ftruncate[I32](fd: I32, len: I64) if not windows and not linux
use @_close[I32](fd: I32) if windows
use @close[I32](fd: I32) if not windows
use @pony_os_writev_max[I32]()


92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111


FileEOF¶
[Source]
primitive val FileEOF

Constructors¶
create¶
[Source]
new val create()
: FileEOF val^

Returns¶

FileEOF val^


y: U32 val

Returns¶

U32 val

op_not¶
[Source]
fun box op_not()
: U32 val

Returns¶

U32 val

add¶
[Source]


1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371


172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189use "collections"

use @pony_asio_event_create[AsioEventID](


y: A

Returns¶

(A , Bool val)

op_and¶
[Source]
fun box op_and(
y: A)
: A

Parameters¶

y: A

Returns¶


fun box ipproto_inlsp()
: I32 val

Returns¶

I32 val

ipproto_inp¶
[Source]
fun box ipproto_inp()
: I32 val

Returns¶

I32 val

ipproto_ip¶
[Source]


that: Iterator[A^] ref

Returns¶

None val

intersect[optional K: HashFunction[box->A!] val]¶
[Source]
Remove everything that isn't in that.
fun ref intersect[optional K: HashFunction[box->A!] val](
that: HashSet[box->A!, K] ref)
: None val

Parameters¶

that: HashSet[box->A!, K] ref

Returns¶


[Source]
fun box gt(
y: ILong val)
: Bool val

Parameters¶

y: ILong val

Returns¶

Bool val

hash64¶
[Source]
fun box hash64()
: U64 val

Returns¶


fun box lt(
that: box->A)
: Bool val

Parameters¶

that: box->A

Returns¶

Bool val

le¶
[Source]
fun box le(
that: box->A)
: Bool val

Parameters¶


(((c >= 'A') and (c <= 'Z')) or ((c >= 'a') and (c <= 'z')))
and (path.at_offset(offset + 1)? == ':')
else
false
end

fun _network_share(path: String, offset: ISize = 0): String =>
"""
Look for a host, a \, and a resource. Return the path up to that point if
we found one, otherwise an empty String.
"""
try
let next = path.find("\\", offset)? + 1

try
path.trim(0, path.find("\\", next)?.usize())
else
path
end


fun ref append_list(that: List[A]) =>
"""
Empties the provided List by appending all elements onto the receiving List.

```pony
let my_list = List[String].from(["a"; "b"; "c"])
let other_list = List[String].from(["d"; "e"; "f"])
my_list.append_list(other_list)  // my_list is ["a"; "b"; "c"; "d"; "e"; "f"], other_list is empty
```
"""
if this isnt that then
while that._size > 0 do
try append_node(that.head()?) end
end
end

fun ref prepend_list(that: List[A]) =>
"""
Empties the provided List by prepending all elements onto the receiving List.


252
253
254
255
256
257
258
259
260
261
262
263use @pony_os_accept[U32](event: AsioEventID)
use @pony_os_listen_tcp[AsioEventID](owner: AsioEventNotify, host: Pointer[U8] tag,
service: Pointer[U8] tag)
use @pony_os_listen_tcp4[AsioEventID](owner: AsioEventNotify, host: Pointer[U8] tag,
service: Pointer[U8] tag)
use @pony_os_listen_tcp6[AsioEventID](owner: AsioEventNotify, host: Pointer[U8] tag,
service: Pointer[U8] tag)

actor TCPListener is AsioEventNotify


let _addr1: U32 = 0
"""
Bits 0-32 of the IPv6 address in network byte order.

`0` if this is an IPv4 address. Check with `ipv4()` and `ipv6()`.
"""

let _addr2: U32 = 0
"""
Bits 33-64 of the IPv6 address in network byte order.

`0` if this is an IPv4 address. Check with `ipv4()` and `ipv6()`.
"""
let _addr3: U32 = 0
"""
Bits 65-96 of the IPv6 address in network byte order.

`0` if this is an IPv4 address. Check with `ipv4()` and `ipv6()`.
"""


# Example program

```pony
// Here we have a TCPConnectionNotify that upon construction
// is given a ApplyReleaseBackpressureAuth token. This allows the notifier
// to inform the Pony runtime when to apply and release backpressure
// as the connection experiences it.
// Note the calls to
//
// Backpressure.apply(_auth)
// Backpressure.release(_auth)
//
// that apply and release backpressure as needed

use "backpressure"
use "collections"
use "net"

class SlowDown is TCPConnectionNotify
let _auth: ApplyReleaseBackpressureAuth


fun info(): FileInfo ? =>
"""
Return a FileInfo for this directory. Raise an error if the fd is invalid
or if we don't have FileStat permission.
"""
FileInfo._descriptor(_fd, path)?

fun chmod(mode: FileMode box): Bool =>
"""
Set the FileMode for this directory.
"""
_FileDes.chmod(_fd, path, mode)

fun chown(uid: U32, gid: U32): Bool =>
"""
Set the owner and group for this directory. Does nothing on Windows.
"""
_FileDes.chown(_fd, path, uid, gid)

fun touch(): Bool =>


max: F64 val = 1.0)
: F64 val

Parameters¶

min: F64 val = 0.0
max: F64 val = 1.0

Returns¶

F64 val

bool¶
[Source]
Generate a random Bool value.
fun ref bool()
: Bool val

Returns¶


F64 val) & Real[A] val)](
a: A)
: I128 val^

Parameters¶

a: A

Returns¶

I128 val^

min_value¶
[Source]
new val min_value()
: I128 val^

Returns¶


fun ref shuffle[A: A](
array: Array[A] ref)
: None val

Parameters¶

array: Array[A] ref

Returns¶

None val


Minimum positive value representable at full precision (ie a normalised
number).
"""
from_bits(0x0010_0000_0000_0000)

new epsilon() =>
"""
Minimum positive value such that (1 + epsilon) != 1.
"""
from_bits(0x3CB0_0000_0000_0000)

fun tag radix(): U8 =>
"""
Exponent radix.
"""
2

fun tag precision2(): U8 =>
"""
Mantissa precision in bits.


end
end

Supports min being smaller than max with negative inc
but only for signed integer types and floats:
var previous = 11
for left in Range[I64](10, -5, -1) do
if not (left < previous) then
error
end
previous = left
end

If inc is nonzero, but cannot produce progress towards max because of its sign, the Range is considered empty and will not produce any iterations. The Range is also empty if either min equals max, independent of the value of inc, or if inc is zero.
let empty_range1 = Range(0, 10, -1)
let empty_range2 = Range(0, 10, 0)
let empty_range3 = Range(10, 10)
empty_range1.is_empty() == true
empty_range2.is_empty() == true
empty_range3.is_empty() == true


collections.List class is the
correct way to create these. Do not attempt to create a Linked List using only
ListNodes.
Example program¶
The functions which are illustrated below are only those which operate on an
individual ListNode.
It outputs:
My node has the item value: My Node item
My node has the updated item value: My updated Node item
Popped the item from the ListNode
The ListNode has no (None) item.
use "collections"
actor Main
new create(env:Env) =>

// Create a new ListNode of type String
let my_list_node = ListNode[String]("My Node item")
try
env.out.print("My node has the item value: "
+ my_list_node.apply()?) // My Node item


U8 val

min_exp2¶
[Source]
fun tag min_exp2()
: I16 val

Returns¶

I16 val

min_exp10¶
[Source]
fun tag min_exp10()
: I16 val

Returns¶


fun box f64()
: F64 val

Returns¶

F64 val

i8_unsafe¶
[Source]
fun box i8_unsafe()
: I8 val

Returns¶

I8 val

i16_unsafe¶
[Source]


fun ttin(): U32 =>
ifdef linux or bsd or osx then 21
else compile_error "no SIGTTIN"
end

fun ttou(): U32 =>
ifdef linux or bsd or osx then 22
else compile_error "no SIGTTOU"
end

fun io(): U32 =>
ifdef bsd or osx then 23
elseif linux then 29
else compile_error "no SIGIO"
end

fun xcpu(): U32 =>
ifdef linux or bsd or osx then 24
else compile_error "no SIGXCPU"


")
: None val

Parameters¶

s: String box = "
"

Returns¶

None val

rstrip¶
[Source]
Remove all trailing characters within the string that are in s. By default,
trailing whitespace is removed.
fun ref rstrip(
s: String box = "
")


[Source]
fun box ne(
y: box->A)
: Bool val

Parameters¶

y: box->A

Returns¶

Bool val

lt¶
[Source]
fun box lt(
y: box->A)
: Bool val


212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231


fun box rem_partial(
y: U128 val)
: U128 val ?

Parameters¶

y: U128 val

Returns¶

U128 val ?

divrem_partial¶
[Source]
fun box divrem_partial(
y: U128 val)
: (U128 val , U128 val) ?

Parameters¶


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91


Public Behaviours¶
raise¶
[Source]
Raise the signal.
be raise()

dispose¶
[Source]
Dispose of the signal handler.
be dispose()


fun box rds_info_message_flag_ack()
: I32 val

Returns¶

I32 val

rds_info_message_flag_fast_ack¶
[Source]
fun box rds_info_message_flag_fast_ack()
: I32 val

Returns¶

I32 val

rds_info_recv_messages¶
[Source]


MapValues[K: K, V: V, H: HashFunction[K] val, M: HashMap[K, V, H] #read]¶
[Source]
An iterator over the values in a map.
class ref MapValues[K: K, V: V, H: HashFunction[K] val, M: HashMap[K, V, H] #read] is
Iterator[M->V] ref

Implements¶

Iterator[M->V] ref

Constructors¶
create¶


fun ip_min_memberships():I32 => @pony_os_sockopt_option(I32(282))
fun ip_msfilter():I32 => @pony_os_sockopt_option(I32(283))
fun ip_mtu():I32 => @pony_os_sockopt_option(I32(284))
fun ip_mtu_discover():I32 => @pony_os_sockopt_option(I32(285))
fun ip_multicast_all():I32 => @pony_os_sockopt_option(I32(286))
fun ip_multicast_if():I32 => @pony_os_sockopt_option(I32(287))
fun ip_multicast_ifindex():I32 => @pony_os_sockopt_option(I32(288))
fun ip_multicast_loop():I32 => @pony_os_sockopt_option(I32(289))
fun ip_multicast_ttl():I32 => @pony_os_sockopt_option(I32(290))
fun ip_multicast_vif():I32 => @pony_os_sockopt_option(I32(291))
fun ip_nat_xxx():I32 => @pony_os_sockopt_option(I32(292))
fun ip_nodefrag():I32 => @pony_os_sockopt_option(I32(293))
fun ip_old_fw_add():I32 => @pony_os_sockopt_option(I32(294))
fun ip_old_fw_del():I32 => @pony_os_sockopt_option(I32(295))
fun ip_old_fw_flush():I32 => @pony_os_sockopt_option(I32(296))
fun ip_old_fw_get():I32 => @pony_os_sockopt_option(I32(297))
fun ip_old_fw_resetlog():I32 => @pony_os_sockopt_option(I32(298))
fun ip_old_fw_zero():I32 => @pony_os_sockopt_option(I32(299))
fun ip_onesbcast():I32 => @pony_os_sockopt_option(I32(300))
fun ip_options():I32 => @pony_os_sockopt_option(I32(301))


c = c - 1
end
end
end
error

fun ref filter_map[B](f: {(A!): (B^ | None) ?} box): Iter[B]^ =>
"""
Return an iterator which applies `f` to each element. If `None` is
returned, then the iterator will try again by applying `f` to the next
element. Otherwise, the value of type `B` is returned.


232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251


Parameters¶

y: F64 val

Returns¶

(F64 val , F64 val)

rem_unsafe¶
fun box rem_unsafe(
y: F64 val)
: F64 val

Parameters¶

y: F64 val

Returns¶


[Source]
Returns the name of the help command, which defaults to "help".
fun box help_name()
: String val

Returns¶

String val

help_string¶
[Source]
Returns a formated help string for this command and all of its arguments.
fun box help_string()
: String val

Returns¶

String val


end

fun read_u128[B: (A & Real[B] val & U8) = A](offset: USize): U128 ? =>
"""
Reads a U128 from offset. This is only allowed for an array of U8s.
"""
let u128_bytes = U128(0).bytewidth()
if (offset + u128_bytes) <= _size then
_ptr._offset(offset)._convert[U128]()._apply(0)
else
error
end

fun apply(i: USize): this->A ? =>
"""
Get the i-th element, raising an error if the index is out of bounds.
"""
if i < _size then
_ptr._apply(i)
else


"""
let array = recover Array[String] end
var offset: ISize = 0

try
while true do
let next = path.find(list_sep(), offset)?
array.push(clean(path.trim(offset.usize(), next.usize())))
offset = next + 1
end
else
array.push(clean(path.trim(offset.usize())))
end

array

fun random(len: USize = 6): String =>
"""
Returns a pseudo-random base, suitable as a temporary file name or
directory name, but not guaranteed to not already exist.


filter_map[B: B]¶
[Source]
Return an iterator which applies f to each element. If None is
returned, then the iterator will try again by applying f to the next
element. Otherwise, the value of type B is returned.
Example¶
Iter[I64]([as I64: 1; -2; 4; 7; -5])
.filter_map[USize](
{(i: I64): (USize | None) => if i >= 0 then i.usize() end })

1 4 7
```pony
fun ref filter_map[B: B](
f: {(A!): (B^ | None) ?}[A, B] box)
: Iter[B] ref^

Parameters¶


recover String end
end

fun lower(): String iso^ =>
"""
Returns a lower case version of the string.
"""
let s = clone()
s.lower_in_place()
s

fun ref lower_in_place() =>
"""
Transforms the string to lower case. Currently only knows ASCII case.
"""
var i: USize = 0

while i < _size do
let c = _ptr._apply(i)


messages consist of the following:

* `list_size` - the number of items in the following list of items
as a big-endian 32-bit integer
* zero or more items of the following data:
* a big-endian 64-bit floating point number
* a string that starts with a big-endian 32-bit integer that
specifies the length of the string, followed by a number of
bytes that represent the string

A message would be something like this:

```
[message_length][list_size][float1][string1][float2][string2]...
```

The following program uses a `Reader` to decode a message of
this type and print them:

```pony


fun box ne(
that: HashSet[A, H] box)
: Bool val

Parameters¶

that: HashSet[A, H] box

Returns¶

Bool val


max_shrink_rounds = max_shrink_rounds'
max_generator_retries = max_generator_retries'
timeout = timeout'
async = async'

fun string(): String iso^ =>
recover
String()
.>append("Params(seed=")
.>append(seed.string())
.>append(")")
end

trait Property1[T]
"""
A property that consumes 1 argument of type `T`.

A property is defined by a [Generator](pony_check-Generator.md), returned by
the [`gen()`](pony_check-Property1.md#gen) method, and a
[`property`](pony_check-Property1#property) method that consumes the


1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431


: String val

Returns¶

String val

params¶
[Source]
fun box params()
: PropertyParams val

Returns¶

PropertyParams val


msg: String val = ""
loc: SourceLoc val = __loc

Returns¶

Bool val

assert_array_eq_unordered[A: (Equatable[A] #read & Stringable #read)]¶
[Source]
Assert that the contents of the 2 given ReadSeqs are equal ignoring order.
The type parameter of this function is the type parameter of the
elements in both ReadSeqs. For instance, when comparing two Array[U8],
you should call this method as follows:
fun apply(h: TestHelper) =>
let a: Array[U8] = [1; 2; 3]
let b: Array[U8] = [1; 3; 2]
h.assert_array_eq_unordered[U8](a, b)

fun box assert_array_eq_unordered[A: (Equatable[A] #read & Stringable #read)](


fun box hash64()
: U64 val

Returns¶

U64 val

i8¶
[Source]
fun box i8()
: I8 val

Returns¶

I8 val

i16¶
[Source]


fun box ctz_unsafe()
: ULong val

Returns¶

ULong val

bitwidth¶
[Source]
fun box bitwidth()
: ULong val

Returns¶

ULong val

bytewidth¶
[Source]


Parameters¶

error_type': (ExecveError val | PipeError val | ForkError val |
WaitpidError val | WriteError val | KillError val |
CapError val | ChdirError val | UnknownError val)
message': (String val | None val) = reference

Returns¶

ProcessError val^

Public fields¶
let error_type: (ExecveError val | PipeError val | ForkError val |¶
[WaitpidError](process-WaitpidError.md) val | [WriteError](process-WriteError.md) val | [KillError](process-KillError.md) val |
[CapError](process-CapError.md) val | [ChdirError](process-ChdirError.md) val | [UnknownError](process-UnknownError.md) val)

[Source]


The ListNode must be contained within a List for this to succeed.
"""
match _list
| let list': List[A] =>
match (_prev, _next)
| (let prev': ListNode[A], let next': ListNode[A]) =>
// We're in the middle of the list.
prev'._next = _next
next'._prev = _prev
_prev = None
_next = None
| (let prev': ListNode[A], None) =>
// We're the tail.
prev'._next = None
list'._set_tail(prev')
_prev = None
| (None, let next': ListNode[A]) =>
// We're the head.
next'._prev = None
list'._set_head(next')


its struct sockaddr definition, returns the length.
Else (Linux/Windows) returns the size of sockaddr_in or sockaddr_in6.
fun box length()
: U8 val

Returns¶

U8 val

family¶
[Source]
Returns the family.
fun box family()
: U8 val

Returns¶

U8 val


true
else
_fail("Assert EQ_UNORDERED failed from an internal error.")
false
end

fun _print_array[A: Stringable #read](array: ReadSeq[A]): String =>
"""
Generate a printable string of the contents of the given readseq to use in
error messages.
"""
"[len=" + array.size().string() + ": " + ", ".join(array.values()) + "]"

/****** END DUPLICATION FROM TESTHELPER *********/

fun expect_action(name: String) =>
"""
Expect some action of the given name to complete
for the property to hold.


(value *? base') +? digit
end

had_digit = true
index = index + 1
end

// Check result
if not had_digit then
// No integer found
return (0, 0)
end

// Success
(value, index - start_index)

fun _read_int_base[A: ((Signed | Unsigned) & Integer[A] val)](
base: U8,
index: USize)
: (A, USize /* chars used */)


fun property(arg1: Array[USize], ph: PropertyHelper) =>
ph.assert_array_eq[USize](arg1, arg1.reverse())
```


Proxy¶
[Source]
interface ref Proxy

Public Functions¶
apply¶
[Source]
fun box apply(
wrap: TCPConnectionNotify iso)
: TCPConnectionNotify iso^

Parameters¶


y: I32 val

Returns¶

(I32 val , Bool val)

remc¶
[Source]
fun box remc(
y: I32 val)
: (I32 val , Bool val)

Parameters¶

y: I32 val

Returns¶


let max = len.max_value() - 1
let min_alloc = len.min(max) + 1
if min_alloc <= (max / 2) then
_alloc = min_alloc.next_pow2()
else
_alloc = min_alloc.min(max)
end
_ptr = _ptr._realloc(_alloc, _size)
end

fun ref compact() =>
"""
Try to remove unused space, making it available for garbage collection. The
request may be ignored. The string is returned to allow call chaining.
"""
if (_size + 1) <= 512 then
if (_size + 1).next_pow2() != _alloc.next_pow2() then
_alloc = (_size + 1).next_pow2()
let old_ptr = _ptr = Pointer[U8]._alloc(_alloc)
old_ptr._copy_to(_ptr, _size)


Parameters¶

offset: USize val = 0

Returns¶

I64 val ?

peek_u128_be¶
[Source]
Peek at a big-endian U128.
fun box peek_u128_be(
offset: USize val = 0)
: U128 val ?

Parameters¶

offset: USize val = 0


U32 val

set_so_sndbuf¶
[Source]
Wrapper for the FFI call setsockopt(fd, SOL_SOCKET, SO_SNDBUF, ...)
fun ref set_so_sndbuf(
bufsize: U32 val)
: U32 val

Parameters¶

bufsize: U32 val

Returns¶

U32 val


if _use_event then
// Create a new event.
_event = @pony_asio_event_create(this, 0, AsioEvent.read(), 0, true)
else
// Start the read loop.
_loop_read()
end
end

try (_notify as InputNotify).dispose() end
_notify = consume notify

be _loop_read() =>
"""
If we are able to read from stdin, schedule another read.
"""
if _read() then
_loop_read()
end


y: I64 val

Returns¶

(I64 val , Bool val)

mulc¶
[Source]
fun box mulc(
y: I64 val)
: (I64 val , Bool val)

Parameters¶

y: I64 val

Returns¶


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


Clears the last error code set for this File.
Clears the error indicator for the stream.
"""
_errno = FileOK

fun _get_error(): FileErrNo =>
"""
Fetch errno from the OS.
"""
let os_errno = @pony_os_errno()
match os_errno
| _EBADF() => return FileBadFileNumber
| _EEXIST() => return FileExists
| _EACCES() => return FilePermissionDenied
else
return FileError
end

fun valid(): Bool =>


# How to write tests

Create a test.pony file

```pony
use "pony_test"

actor Main is TestList
new create(env: Env) => PonyTest(env, this)
new make() => None

fun tag tests(test: PonyTest) =>
test(_TestAddition)

class iso _TestAddition is UnitTest
"""
Adding 2 numbers
"""
fun name(): String => "u32/add"


None

fun ref not_listening(sock: UDPSocket ref)
"""
Called if it wasn't possible to bind the socket to an address.

It is expected to implement proper error handling. You need to opt in to
ignoring errors, which can be implemented like this:

```pony
fun ref not_listening(sock: UDPSocket ref) =>
None
```
"""

fun ref received(
sock: UDPSocket ref,
data: Array[U8] iso,
from: NetAddress)
=>


_mod = n - 1
_array = Array[A](n)

fun head(): USize ? =>
"""
The first read that will succeed. If nothing has been written to the ring,
this will raise an error.
"""
if _write > 0 then
if _write > space() then
_write - space()
else
0
end
else
error
end

fun size(): USize =>
"""


I64 val

i128_unsafe¶
[Source]
fun box i128_unsafe()
: I128 val

Returns¶

I128 val

ilong_unsafe¶
[Source]
fun box ilong_unsafe()
: ILong val

Returns¶


[Source]
new ref create(
x: U64 val = 5489,
y: U64 val = 0)
: XorOshiro128StarStar ref^

Parameters¶

x: U64 val = 5489
y: U64 val = 0

Returns¶

XorOshiro128StarStar ref^

Public Functions¶
next¶
[Source]
fun ref next()


fun box dso_nodelay()
: I32 val

Returns¶

I32 val

dso_seqpacket¶
[Source]
fun box dso_seqpacket()
: I32 val

Returns¶

I32 val

dso_services¶
[Source]


_short = short'
(_typ, _default, _required) = _init(_BoolType, default')

new val string(
name': String,
descr': String = "",
short': (U8 | None) = None,
default': (String | None) = None)
=>
"""
Creates an Option with a String typed value that can be used like
`--file=dir/filename` or `-F=dir/filename` or `-Fdir/filename`
to yield an option value like
`cmd.option("file").string() == "dir/filename"`.
"""
_name = name'
_descr = descr'
_short = short'
(_typ, _default, _required) = _init(_StringType, default')


312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331


U128 val

ctz¶
[Source]
fun box ctz()
: U128 val

Returns¶

U128 val

clz_unsafe¶
[Source]
Unsafe operation.
If this is 0, the result is undefined.
fun box clz_unsafe()
: U128 val


372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391


: I16 val

Returns¶

I16 val

i32¶
[Source]
fun ref i32()
: I32 val

Returns¶

I32 val

i64¶
[Source]
fun ref i64()


# Type Expressions

The types we've talked about so far can also be combined in __type expressions__. If you're used to object-oriented programming, you may not have seen these before, but they are common in functional programming. A __type expression__ is also called an __algebraic data type__.

There are three kinds of type expression: __tuples__, __unions__, and __intersections__.


132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151


Public Functions¶
string¶
[Source]
fun box string()
: String iso^

Returns¶

String iso^

eq¶
[Source]
fun box eq(
that: WriteError val)
: Bool val

Parameters¶


@pony_os_ipv6(this)

fun name(
reversedns: (DNSAuth | None) = None,
servicename: Bool = false)
: (String, String) ?
=>
"""
Returns the host and service name.

If `reversedns` is `DNSAuth`,
a DNS lookup will be executed and the hostname
for this address is returned as first element of the result tuple.
If no hostname could be found, an error is raised.
If `reversedns` is `None` the plain IP address is given
and no DNS lookup is executed.

If `servicename` is `false` the numeric port is returned
as second element of the result tuple.
If it is `true` the port is translated into its


U64 val

mod¶
[Source]
fun box mod(
y: U64 val)
: U64 val

Parameters¶

y: U64 val

Returns¶

U64 val

modc¶
[Source]


272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291


Returns¶

None val


fun box sctp_cause_cookie_in_shutdown()
: I32 val

Returns¶

I32 val

sctp_cause_deleting_last_addr¶
[Source]
fun box sctp_cause_deleting_last_addr()
: I32 val

Returns¶

I32 val

sctp_cause_deleting_src_addr¶
[Source]


# Why is this safe?

Because of Pony's __capabilities secure type system__. We've mentioned reference capabilities briefly before when talking about function receiver reference capabilities. The short version is that they are annotations on a type that make all this parallelism safe without any runtime overhead.

We will cover reference capabilities in depth later.


fun box dccp_sockopt_ccid()
: I32 val

Returns¶

I32 val

dccp_sockopt_ccid_rx_info¶
[Source]
fun box dccp_sockopt_ccid_rx_info()
: I32 val

Returns¶

I32 val

dccp_sockopt_ccid_tx_info¶
[Source]


1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291


Main.make() is called during aggregation. If so desired extra code can be added
to either of these constructors to perform additional tasks.


## Isolated data may be complex

An isolated piece of data may be a single byte. But it can also be a large data structure with multiple references between the various objects in that structure. What matters for the data to be isolated is that there is only a single reference to that structure as a whole. We talk about the __isolation boundary__ of a data structure. For the structure to be isolated:

1. There must only be a single reference outside the boundary that points to an object inside.
2. There can be any number of references inside the boundary, but none of them must point to an object outside.


end

fun rem_unsafe(y: U128): U128 =>
"""
Unsafe operation.
If y is 0, the result is undefined.
If the operation overflows, the result is undefined.
"""
ifdef native128 then
this %~ y
else
this % y
end

fun f32(): F32 =>
let v = f64()
if v > F32.max_value().f64() then
F32._inf(false)
else
v.f32()


Parameters¶

y: F32 val

Returns¶

(F32 val , F32 val)

rem_unsafe¶
fun box rem_unsafe(
y: F32 val)
: F32 val

Parameters¶

y: F32 val

Returns¶


)
let shrink_iter: Iterator[Map[K, V]^] =
Iter[USize](CountdownIter(size, 0)) // Range(size, 0, -1))
// .skip(1)
.map_stateful[Map[K, V]^]({
(s: USize): Map[K, V]^ =>
Map[K, V].create(s).>concat(
Iter[(K^, V^)](gen.value_iter(rnd)).take(s)
)
})
(consume result, shrink_iter)

end)

fun map_is_of[K, V](
gen: Generator[(K, V)],
max: USize = 100)
: Generator[MapIs[K, V]]
=>
"""


create¶
[Source]
Defaults to a prealloc of 8.
new ref create(
prealloc: USize val = 8)
: HashSet[A, H] ref^

Parameters¶

prealloc: USize val = 8

Returns¶

HashSet[A, H] ref^

Public Functions¶
size¶
[Source]
The number of items in the set.


312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331


fun box sctp_del_vrf_id()
: I32 val

Returns¶

I32 val

sctp_disable_fragments¶
[Source]
fun box sctp_disable_fragments()
: I32 val

Returns¶

I32 val

sctp_ecn_cwr¶
[Source]


new val create(
base: FileAuth val,
path': String val,
caps': Flags[(FileCreate val | FileChmod val | FileChown val | FileLink val | FileLookup val | FileMkdir val | FileRead val | FileRemove val | FileRename val | FileSeek val | FileStat val | FileSync val | FileTime val | FileTruncate val | FileWrite val | FileExec val), U32 val] val = recover)
: FilePath val^

Parameters¶

base: FileAuth val
path': String val
caps': Flags[(FileCreate val | FileChmod val | FileChown val | FileLink val | FileLookup val | FileMkdir val | FileRead val | FileRemove val | FileRename val | FileSeek val | FileStat val | FileSync val | FileTime val | FileTruncate val | FileWrite val | FileExec val), U32 val] val = recover

Returns¶

FilePath val^

from¶
[Source]
Create a new path from an existing FilePath.


A

rotr¶
[Source]
fun box rotr(
y: A)
: A

Parameters¶

y: A

Returns¶

A

popcount¶
[Source]


fun box ip_faith()
: I32 val

Returns¶

I32 val

ip_flowid¶
[Source]
fun box ip_flowid()
: I32 val

Returns¶

I32 val

ip_flowtype¶
[Source]


372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391


fun bswap(): U16 => @"llvm.bswap.i16"(this)
fun popcount(): U16 => @"llvm.ctpop.i16"(this)
fun clz(): U16 => @"llvm.ctlz.i16"(this, false)
fun ctz(): U16 => @"llvm.cttz.i16"(this, false)

fun clz_unsafe(): U16 =>
"""
Unsafe operation.
If this is 0, the result is undefined.
"""
@"llvm.ctlz.i16"(this, true)

fun ctz_unsafe(): U16 =>
"""
Unsafe operation.
If this is 0, the result is undefined.
"""
@"llvm.cttz.i16"(this, true)

fun bitwidth(): U16 => 16


fun box i16_unsafe()
: I16 val

Returns¶

I16 val

i32_unsafe¶
[Source]
fun box i32_unsafe()
: I32 val

Returns¶

I32 val

i64_unsafe¶
[Source]


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


FulfillIdentity[A] iso^

Public Functions¶
apply¶
[Source]
fun ref apply(
value: A)
: A

Parameters¶

value: A

Returns¶

A


# How to access command line arguments

```pony
actor Main
new create(env: Env) =>
// The no of arguments
env.out.print(env.args.size().string())
for value in env.args.values() do
env.out.print(value)
end
// Access the arguments the first one will always be the application name
try env.out.print(env.args(0)?) end
```


epsilon¶
[Source]
Minimum positive value such that (1 + epsilon) != 1.
new val epsilon()
: F64 val^

Returns¶

F64 val^

Public Functions¶
bits¶
[Source]
fun box bits()
: U64 val

Returns¶


```pony
use "time"

class Foo
fun f() =>
(var secs, var nsecs) = Time.now()
```


ILong val

isize_unsafe¶
[Source]
fun box isize_unsafe()
: ISize val

Returns¶

ISize val

u8_unsafe¶
[Source]
fun box u8_unsafe()
: U8 val

Returns¶


492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511


y: ULong val

Returns¶

ULong val

rotr¶
[Source]
fun box rotr(
y: ULong val)
: ULong val

Parameters¶

y: ULong val

Returns¶


__Can I call using positional arguments but miss out the first one?__ No. If you use positional arguments they must be the first ones in the call.


452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471


fun box ilong_unsafe()
: ILong val

Returns¶

ILong val

isize_unsafe¶
[Source]
fun box isize_unsafe()
: ISize val

Returns¶

ISize val

u8_unsafe¶
[Source]


In our trait based example, we can add new colors at any time. With the type union based approach, we can only add them by modifying definition of `Color` in the package that provides it.

Interfaces can't be used for open world enumerations. If we defined `Color` as an interface:

```pony
interface Color
```

Then literally everything in Pony would be a `Color` because everything matches the `Color` interface. You can however, do something similar using "marker methods" with an interface:

```pony
interface Color
fun is_color(): None

primitive Red
fun is_color(): None => None
```

Here we are using structural typing to create a collection of things that are in the category `Color` by providing a method that "marks" being a member of the category: `is_color`.


match name'
| None => p4.name()
| let s: String => s
end
_prop4 = consume p4

fun name(): String => _name

fun ref apply(h: TestHelper) ? =>
let prop = ((_prop4 = None) as Property4[T1, T2, T3, T4] iso^)
let params = prop.params()
h.long_test(params.timeout)
let property_runner =
PropertyRunner[(T1, T2, T3, T4)](
consume prop,
params,
h, // PropertyResultNotify
h, // PropertyLogger
h.env
)


fun mulc(y: I32): (I32, Bool) =>
@"llvm.smul.with.overflow.i32"(this, y)

fun divc(y: I32): (I32, Bool) =>
_SignedCheckedArithmetic.div_checked[I32, U32](this, y)

fun remc(y: I32): (I32, Bool) =>
_SignedCheckedArithmetic.rem_checked[I32, U32](this, y)

fun fldc(y: I32): (I32, Bool) =>
_SignedCheckedArithmetic.fld_checked[I32, U32](this, y)

fun modc(y: I32): (I32, Bool) =>
_SignedCheckedArithmetic.mod_checked[I32, U32](this, y)

fun add_partial(y: I32): I32 ? =>
_SignedPartialArithmetic.add_partial[I32](this, y)?

fun sub_partial(y: I32): I32 ? =>


### Example

```pony
Iter[I64]([1; 2; 3].values())
.last()
```
`3`
"""
while _iter.has_next() do _iter.next()?
else error
end

fun ref map[B](f: {(A!): B ?} box): Iter[B]^ =>
"""
Return an iterator where each item's value is the application of the given
function to the value in the original iterator.


RingBuffer[A: A]¶
[Source]
A ring buffer.
class ref RingBuffer[A: A]

Constructors¶
create¶
[Source]
Create a ring buffer with a fixed size. The size will be rounded up to the
next power of 2.
new ref create(
len: USize val)
: RingBuffer[A] ref^


U64 val

clz_unsafe¶
[Source]
Unsafe operation.
If this is 0, the result is undefined.
fun box clz_unsafe()
: U64 val

Returns¶

U64 val

ctz_unsafe¶
[Source]
Unsafe operation.
If this is 0, the result is undefined.


172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191


scheduled on the last timing wheel.
"""
((1 << (_wheels() * _bits())) - 1).u64()

fun tag _wheels(): USize => 4
fun tag _bits(): USize => 6


fun box rds_info_connection_stats()
: I32 val

Returns¶

I32 val

rds_info_counters¶
[Source]
fun box rds_info_counters()
: I32 val

Returns¶

I32 val

rds_info_first¶
[Source]


# Reference capabilities that can't be sent

You may have noticed we didn't mention `trn`, `ref`, or `box` as things you can send to other actors. That's because you can't do it. They don't make the guarantees we need in order to be safe.

So when should you use those reference capabilities?

* Use `ref` when you need to be able to change an object over time. On the other hand, if your program wouldn't be any slower if you used an immutable type instead, you may want to use a `val` anyway.
* Use `box` when you don't care whether the object is mutable or immutable. In other words, you want to be able to read it, but you don't need to write to it or share it with other actors.
* Use `trn` when you want to be able to change an object for a while, but you also want to be able to make it _globally immutable_ later.


332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351


y: I64 val

Returns¶

Bool val

ge¶
[Source]
fun box ge(
y: I64 val)
: Bool val

Parameters¶

y: I64 val

Returns¶


that: Generators val

Returns¶

Bool val


F64 val

floor¶
[Source]
fun box floor()
: F64 val

Returns¶

F64 val

round¶
[Source]
fun box round()
: F64 val

Returns¶


632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651


use @SSL_library_init[I32]()

primitive _SSLInit
"""
This initialises SSL when the program begins.
"""
fun _init() =>
@SSL_load_error_strings()
@SSL_library_init()
```

On Windows, we use the libraries `libssl-32` and `libcrypto-32` and on other platforms we use `ssl` and `crypto`. These contain the FFI functions `SSL_library_init` and `SSL_load_error_strings` (amongst others).

By default the Pony compiler will look for the libraries to link in the standard places, however, that is defined on the build platform. However, it may be necessary to look in extra places. The `use "path:..."` command allows this. The specified path is added to the library search paths for the remainder of the current file. The example above uses this to add the path `/usr/local/opt/libressl/lib` for MacOS. This is required because the library is provided by brew, which installs things outside the standard library search paths.

If you are integrating with existing libraries, that is all you need to do.


fun box sem_getvalue()
: U64 val

Returns¶

U64 val

sem_post¶
[Source]
fun box sem_post()
: U64 val

Returns¶

U64 val

sem_wait¶
[Source]


752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71


fun box ipv6_use_min_mtu()
: I32 val

Returns¶

I32 val

ipv6_v6only¶
[Source]
fun box ipv6_v6only()
: I32 val

Returns¶

I32 val

ipv6_xfrm_policy¶
[Source]


: Serialised ref^ ?

Parameters¶

auth: SerialiseAuth val
data: Any box

Returns¶

Serialised ref^ ?

input¶
[Source]
A caller with InputSerialisedAuth can create serialised data from any
arbitrary set of bytes. It is the caller's responsibility to ensure that
the data is in fact well-formed serialised data. This is currently the most
dangerous method, as there is currently no way to check validity at
runtime.
new ref input(


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


### Example

```pony
Iter[I64]([1; 2; 3; 4; 5; 6].values())
.filter({(x) => (x % 2) == 0 })
```
`2 4 6`
"""
filter_stateful({(a: A!): Bool ? => f(a)? })

fun ref find(f: {(A!): Bool ?} box, n: USize = 1): A! ? =>
"""
Return the nth value in the iterator that satisfies the predicate `f`.


292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311


_start_next_read()

be write(data: ByteSeq, to: NetAddress) =>
"""
Write a single sequence of bytes.
"""
_write(data, to)

be writev(data: ByteSeqIter, to: NetAddress) =>
"""
Write a sequence of sequences of bytes.
"""
for bytes in data.values() do
_write(bytes, to)
end

be set_notify(notify: UDPNotify iso) =>
"""
Change the notifier.
"""


Returns¶

String val

line¶
[Source]
Line number within file.
Line numbers start at 1.
fun box line()
: USize val

Returns¶

USize val

pos¶
[Source]


env_vars.pony

1
2
3
4
5
6
7
8
9
10
11


fun box ip_traffic_mgt_background()
: I32 val

Returns¶

I32 val

ip_transparent¶
[Source]
fun box ip_transparent()
: I32 val

Returns¶

I32 val

ip_ttl¶
[Source]


[Source]
fun box eq(
that: AsioEvent val)
: Bool val

Parameters¶

that: AsioEvent val

Returns¶

Bool val

ne¶
[Source]
fun box ne(
that: AsioEvent val)
: Bool val


Bool val

next¶
[Source]
fun ref next()
: A ?

Returns¶

A ?

rewind¶
[Source]
fun ref rewind()
: None val

Returns¶


fun box ip_default_multicast_loop()
: I32 val

Returns¶

I32 val

ip_default_multicast_ttl¶
[Source]
fun box ip_default_multicast_ttl()
: I32 val

Returns¶

I32 val

ip_dontfrag¶
[Source]


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91


fun sctp_initiation():I32 => @pony_os_sockopt_option(I32(642))
fun sctp_initiation_ack():I32 => @pony_os_sockopt_option(I32(643))
fun sctp_initmsg():I32 => @pony_os_sockopt_option(I32(644))
fun sctp_interleaving_supported():I32 => @pony_os_sockopt_option(I32(645))
fun sctp_i_want_mapped_v4_addr():I32 => @pony_os_sockopt_option(I32(646))
fun sctp_last_packet_tracing():I32 => @pony_os_sockopt_option(I32(647))
fun sctp_listen():I32 => @pony_os_sockopt_option(I32(648))
fun sctp_local_auth_chunks():I32 => @pony_os_sockopt_option(I32(649))
fun sctp_lock_logging_enable():I32 => @pony_os_sockopt_option(I32(650))
fun sctp_log_at_send_2_outq():I32 => @pony_os_sockopt_option(I32(651))
fun sctp_log_at_send_2_sctp():I32 => @pony_os_sockopt_option(I32(652))
fun sctp_log_maxburst_enable():I32 => @pony_os_sockopt_option(I32(653))
fun sctp_log_rwnd_enable():I32 => @pony_os_sockopt_option(I32(654))
fun sctp_log_sack_arrivals_enable():I32 => @pony_os_sockopt_option(I32(655))
fun sctp_log_try_advance():I32 => @pony_os_sockopt_option(I32(656))
fun sctp_ltrace_chunk_enable():I32 => @pony_os_sockopt_option(I32(657))
fun sctp_ltrace_error_enable():I32 => @pony_os_sockopt_option(I32(658))
fun sctp_map_logging_enable():I32 => @pony_os_sockopt_option(I32(659))
fun sctp_maxburst():I32 => @pony_os_sockopt_option(I32(660))
fun sctp_maxseg():I32 => @pony_os_sockopt_option(I32(661))


1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091


Promises[A: Any #share]¶
[Source]
primitive val Promises[A: Any #share]

Constructors¶
create¶
[Source]
new val create()
: Promises[A] val^

Returns¶

Promises[A] val^


fun box i64()
: I64 val

Returns¶

I64 val

i128¶
[Source]
fun box i128()
: I128 val

Returns¶

I128 val

ilong¶
[Source]


Returns¶

HashMap[this->K!, this->V!, H2] ref^

clear¶
[Source]
Remove all entries.
fun ref clear()
: None val

Returns¶

None val

keys¶
[Source]
Return an iterator over the keys.
fun box keys()


fun box hash64()
: U64 val

Returns¶

U64 val

i8¶
[Source]
fun box i8()
: I8 val

Returns¶

I8 val

i16¶
[Source]


ExecveError¶
[Source]
primitive val ExecveError

Constructors¶
create¶
[Source]
new val create()
: ExecveError val^

Returns¶

ExecveError val^


promise(_registry(key)? as A)
else
promise.reject()
end


uid: U32 val
gid: U32 val

Returns¶

Bool val

touch¶
[Source]
Set the last access and modification times of the directory to now.
fun box touch()
: Bool val

Returns¶

Bool val

set_time¶


F64 val) & Real[A] val)](
a: A)
: U16 val^

Parameters¶

a: A

Returns¶

U16 val^

min_value¶
[Source]
new val min_value()
: U16 val^

Returns¶


values¶
[Source]
Returns an iterator over the elements of the sequence. Note that this
iterates over this->A, not A.
fun box values()
: Iterator[this->A] ref^

Returns¶

Iterator[this->A] ref^


Parameters¶

expect: A
actual: A
msg: String val = ""
loc: SourceLoc val = __loc

Returns¶

Bool val

assert_eq[A: (Equatable[A] #read & Stringable #read)]¶
[Source]
Assert that the 2 given expressions are equal.
fun box assert_eq[A: (Equatable[A] #read & Stringable #read)](
expect: A,
actual: A,
msg: String val = "",
loc: SourceLoc val = __loc)


12
13
14
15
16primitive AmbientAuth
"""
This type represents the root capability. When a Pony program starts, the
Env passed to the Main actor contains an instance of the root capability.

Ambient access to the root capability is denied outside of the builtin
package. Inside the builtin package, only Env creates a Root.

The root capability can be used by any package that wants to establish a
principle of least authority. A typical usage is to have a parameter on a
constructor for some resource that expects a limiting capability specific to
the package, but will also accept the root capability as representing
unlimited access.
"""
new _create() =>
None


# Additional resources

You can learn more about PonyTest specifics by checking out the [API documentation](https://stdlib.ponylang.io/pony_test--index/). There's also a [testing section](http://patterns.ponylang.io/testing.html) in the [Pony Patterns](http://patterns.ponylang.io/) book.


rem_unsafe¶
[Source]
Unsafe operation.
If y is 0, the result is undefined.
If the operation overflows, the result is undefined.
fun box rem_unsafe(
y: U128 val)
: U128 val

Parameters¶

y: U128 val

Returns¶

U128 val

f32¶


err: _Pipe, stdin: _Pipe, stdout: _Pipe, stderr: _Pipe)
=>
"""
We are now in the child process. We redirect STDIN, STDOUT and STDERR
to their pipes and execute the command. The command is executed via
execve which does not return on success, and the text, data, bss, and
stack of the calling process are overwritten by that of the program
loaded. We've set the FD_CLOEXEC flag on all file descriptors to ensure
that they are all closed automatically once @execve gets called.
"""
_dup2(stdin.far_fd, _STDINFILENO())   // redirect stdin
_dup2(stdout.far_fd, _STDOUTFILENO()) // redirect stdout
_dup2(stderr.far_fd, _STDERRFILENO()) // redirect stderr

var step: U8 = _StepChdir()

match wdir
| let d: FilePath =>
let dir: Pointer[U8] tag = d.path.cstring()
if 0 > @chdir(dir) then


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91


None val

u16_be¶
[Source]
Write a U16 to the buffer in big-endian byte order.
fun ref u16_be(
data: U16 val)
: None val

Parameters¶

data: U16 val

Returns¶

None val


chopped from a single string. This function checks that they are indeed two
strings chopped from the same original string and can be unchopped before
doing the unchopping and returning the unchopped string. If the two strings
cannot be unchopped it returns both strings without modifying them.
The operation does not allocate a new string pointer nor copy elements.
fun iso unchop(
b: String iso)
: ((String iso^ , String iso^) | String iso^)

Parameters¶

b: String iso

Returns¶

((String iso^ , String iso^) | String iso^)

is_null_terminated¶
[Source]


252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271


insert_byte¶
[Source]
Inserts a byte at the given offset. Appends if the offset is out of bounds.
fun ref insert_byte(
offset: ISize val,
value: U8 val)
: None val

Parameters¶

offset: ISize val
value: U8 val

Returns¶

None val


92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111


ULong val

abs¶
[Source]
fun box abs()
: ULong val

Returns¶

ULong val

bit_reverse¶
[Source]
fun box bit_reverse()
: ULong val

Returns¶


fun box split_by(
delim: String val,
n: USize val = call)
: Array[String val] iso^

Parameters¶

delim: String val
n: USize val = call

Returns¶

Array[String val] iso^

split¶
[Source]
Split the string into an array of strings with any character in the
delimiter string. By default, the string is split with whitespace
characters. If n > 0, then the split count is limited to n.


fun box sctp_vrf_id()
: I32 val

Returns¶

I32 val

sctp_wake_logging_enable¶
[Source]
fun box sctp_wake_logging_enable()
: I32 val

Returns¶

I32 val

sock_cloexec¶
[Source]


String val

cwd¶
[Source]
Returns the program's working directory. Setting the working directory is
not supported, as it is not concurrency-safe.
fun box cwd()
: String val

Returns¶

String val

abs¶
[Source]
Returns a cleaned, absolute path.
fun box abs(


I8 val

op_and¶
[Source]
fun box op_and(
y: I8 val)
: I8 val

Parameters¶

y: I8 val

Returns¶

I8 val

op_or¶
[Source]


Returns¶

Bool val

ge_unsafe¶
[Source]
Unsafe operation.
If any input of the operation is +/- infinity or NaN, the result is
undefined.
The operation isn't required to fully comply to IEEE 754 semantics.
fun box ge_unsafe(
y: box->A)
: Bool val

Parameters¶

y: box->A


# Standard Library

The Pony standard library is a collection of packages that can each be used as needed to provide a variety of functionality. For example, the __files__ package provides file access and the __collections__ package provides generic lists, maps, sets and so on.

There is also a special package in the standard library called __builtin__. This contains various types that the compiler has to treat specially and are so common that all Pony code needs to know about them. All Pony source files have an implicit `use "builtin"` command. This means all the types defined in the package builtin are automatically available in the type namespace of all Pony source files.

Documentation for the standard library is [available online](https://stdlib.ponylang.io/)


y: A

Returns¶

A

max¶
[Source]
fun box max(
y: A)
: A

Parameters¶

y: A

Returns¶