diff --git a/.release-notes/3752.md b/.release-notes/3752.md deleted file mode 100644 index 15a1c32e26..0000000000 --- a/.release-notes/3752.md +++ /dev/null @@ -1,55 +0,0 @@ -## 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 -``` diff --git a/.release-notes/next-release.md b/.release-notes/next-release.md index e89979e1dd..da7da9a1b7 100644 --- a/.release-notes/next-release.md +++ b/.release-notes/next-release.md @@ -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 +``` +