Implicit conversions ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Implicit conversions ?

Sven Van Caekenberghe
Why is that the following 2 expressions work

#(1 2 3 4 5 6) asByteArray replaceFrom: 1 to: 3 with: 'abc'.
'abcdef' replaceFrom: 1 to: 3 with: #(70 71 72) asByteArray.

while the next 2 don't

(#(70 71 72) asByteArray) at: 1 put: $a; yourself.
'abcdef' at: 1 put: 75; yourself.

and there exists

'abcdef' byteAt: 1 put: 75; yourself.

but there is no

(#(70 71 72) asByteArray) charAt: 1 put: $a; yourself.

Is the implicit conversion in #replaceFrom:to:with: by design ?

And why is there no equivalent single operation ?

Sven

PS: I ran into this trying to deal with the concept of a 'bivalent' stream, one that can be read/written both byte and char based, some streams like SocketStream support this a little bit, but not really.


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project