-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate array->string cast (#23380)
Deprecate casting arrays to string. This is a continuation of the deprecation of the universal string cast from [this PR](#22068). See #19893 for more context. This deprecation recommends replacing: ```chapel var s = myArray: string; ``` with: ```chapel var s = "%?".format(myArray); ``` - [x] paratest [ reviewed by @riftEmber ] - Thanks!
- Loading branch information
Showing
12 changed files
with
46 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var a = [i in 1..10] i; | ||
|
||
operator :(arr: [], type t:string) { | ||
var s = "---"; | ||
var first = true; | ||
for x in arr { | ||
if first | ||
then first = false; | ||
else s += " "; | ||
s += x:string; | ||
}; | ||
s += "---"; | ||
return s; | ||
} | ||
|
||
writeln(a:string); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
---1 2 3 4 5 6 7 8 9 10--- |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
record R { | ||
var x: int; | ||
|
||
operator: (r: R, type t:string) { | ||
return "-" + r.x:string + "-"; | ||
} | ||
} | ||
|
||
proc string.init=(r: R) { | ||
init this; | ||
this = r:string; | ||
} | ||
|
||
const d = {1..10}, | ||
a = [i in d] new R(i), | ||
b: [d] string = a; | ||
|
||
writeln(b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-1- -2- -3- -4- -5- -6- -7- -8- -9- -10- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const x: [1..10] int; | ||
writeln(x:string); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
array-string-cast.chpl:2: warning: casting arrays to string is deprecated; please use 'try! "%?".format()' from IO.FormattedIO instead | ||
0 0 0 0 0 0 0 0 0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters