Skip to content

Commit

Permalink
Updates release notes for PR #3752
Browse files Browse the repository at this point in the history
  • Loading branch information
ponylang-main committed May 5, 2021
1 parent 5de51c8 commit 61791e9
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 55 deletions.
55 changes: 0 additions & 55 deletions .release-notes/3752.md

This file was deleted.

56 changes: 56 additions & 0 deletions .release-notes/next-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,59 @@ use @printf[I32](fmt: Pointer[U8] tag, ...)

FFI declarations are visible to an entire package, so you don't need to add type signatures to all Pony files.

## Change the return type of String.add to String iso^ (RFC 69)

This release introduces a breaking change by changing the return type of `String.add` from `String val` to `String iso^`.

Where you previously had code like:

```pony
let c = Circle
let str = "Radius: " + c.get_radius().string() + "\n"
env.out.print(str)
```

you now need:

```pony
let c = Circle
let str = recover val "Radius: " + c.get_radius().string() + "\n" end
env.out.print(str)
```

or you can also let the compiler do the work for you by using explicit type declarations:

```pony
let c = Circle
let str: String = "Radius: " + c.get_radius().string() + "\n"
env.out.print(str)
```

The above code works since `val` is the default reference capability of the `String` type.

The new type makes it simpler to implement the `Stringable` interface by using `String.add`. Where before you had code like:

```pony
class MyClass is Stringable
let var1: String = "hello"
let var2: String = " world"
fun string(): String iso^ =>
recover
String.create(var1.size() + var1.size())
.>append(var1)
.>append(var2)
end
```

you can now implement the `string` method as such:

```pony
class MyClass is Stringable
let var1: String = "hello"
let var2: String = " world"
fun string(): String iso^ =>
var1 + var2
```

0 comments on commit 61791e9

Please sign in to comment.