Peter Bortas @ Pike developers forum wrote:
It's so quirky that we might want to consider a warning for that.
What about this:
(string)({65,66,"abc",67,"def",68})
Can we turn it into: "ABabcCdefD" ? Currently this doesn't work (obviously). The reason I would like to have this is that in order to parse strings and accumulate results, in Pike I tend to either pick the characters apart as integers, or use strings of characters whenever the parsing allows me to go faster.
The result is that I would like to accumulate the results piecemeal in an array. This array gets filled like in the example above. Then I'd like to return a single string to the function caller, in which case I could cast it to string (as done above).
From a language purity standpoint I realise that implementing the cast like
this is not quite proper. Then again, I can't think of any other reasonable result the cast should have (except throw an error). Thus in essence it's a DWIM (Do What I Mean) behaviour and conforms to the principle of least surprise.
Comments?