anyone rely on this?

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

anyone rely on this?

Eliot Miranda-2
Hi All,


(32 to: 127) asByteArray asString do: [:c| c class] =>  ' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'

so far so good.


(32 to: 127) asWordArray asString do: [:c| c class] => 'a WordArray(32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127)'

?!?!?!

Surely this should be a String of some sort also?  Any objections if I implement this as such?
--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: anyone rely on this?

Bert Freudenberg

On 02.07.2014, at 21:47, Eliot Miranda <[hidden email]> wrote:

Hi All,


(32 to: 127) asByteArray asString do: [:c| c class] =>  ' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'

so far so good.


(32 to: 127) asWordArray asString do: [:c| c class] => 'a WordArray(32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127)'

?!?!?!

Surely this should be a String of some sort also?  Any objections if I implement this as such?

Nope.

- Bert -






smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: anyone rely on this?

Chris Muller-3
In reply to this post by Eliot Miranda-2
On Wed, Jul 2, 2014 at 2:47 PM, Eliot Miranda <[hidden email]> wrote:
Hi All,


(32 to: 127) asByteArray asString do: [:c| c class] =>  ' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ '

so far so good.


(32 to: 127) asWordArray asString do: [:c| c class] => 'a WordArray(32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127)'

?!?!?!

Surely this should be a String of some sort also?  Any objections if I implement this as such?


Are you saying you want to override asString in WordArray so you get a string-representation of the WordArray instead of its printString?  I wasn't sure whether the do: part of those code snippets fits into your question and if I missed something..



Reply | Threaded
Open this post in threaded view
|

Re: anyone rely on this?

Nicolas Cellier



2014-07-03 1:59 GMT+02:00 Chris Muller <[hidden email]>:
On Wed, Jul 2, 2014 at 2:47 PM, Eliot Miranda <[hidden email]> wrote:
Hi All,


(32 to: 127) asByteArray asString do: [:c| c class] =>  ' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ '

so far so good.


(32 to: 127) asWordArray asString do: [:c| c class] => 'a WordArray(32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127)'

?!?!?!

Surely this should be a String of some sort also?  Any objections if I implement this as such?


Are you saying you want to override asString in WordArray so you get a string-representation of the WordArray instead of its printString?  I wasn't sure whether the do: part of those code snippets fits into your question and if I missed something..



Yes, but which string?
Maybe you wan't to turn the WordArray into a WideString ?
Or re-interpret the individual bytes (endianness?) as a ByteString?



Reply | Threaded
Open this post in threaded view
|

Re: anyone rely on this?

Eliot Miranda-2



On Wed, Jul 2, 2014 at 5:26 PM, Nicolas Cellier <[hidden email]> wrote:



2014-07-03 1:59 GMT+02:00 Chris Muller <[hidden email]>:

On Wed, Jul 2, 2014 at 2:47 PM, Eliot Miranda <[hidden email]> wrote:
Hi All,


(32 to: 127) asByteArray asString do: [:c| c class] =>  ' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ '

so far so good.


(32 to: 127) asWordArray asString do: [:c| c class] => 'a WordArray(32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127)'

?!?!?!

Surely this should be a String of some sort also?  Any objections if I implement this as such?


Are you saying you want to override asString in WordArray so you get a string-representation of the WordArray instead of its printString?  I wasn't sure whether the do: part of those code snippets fits into your question and if I missed something..



Yes, but which string?
Maybe you wan't to turn the WordArray into a WideString ?

This is useful, and symmetrical with ByteArray>>asString..

 
Or re-interpret the individual bytes (endianness?) as a ByteString?

I don't see this as particularly useful, and is not symmetric.

--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: anyone rely on this?

Bert Freudenberg
On 03.07.2014, at 03:54, Eliot Miranda <[hidden email]> wrote:

On Wed, Jul 2, 2014 at 5:26 PM, Nicolas Cellier <[hidden email]> wrote:

2014-07-03 1:59 GMT+02:00 Chris Muller <[hidden email]>:

On Wed, Jul 2, 2014 at 2:47 PM, Eliot Miranda <[hidden email]> wrote:
Hi All,


(32 to: 127) asByteArray asString do: [:c| c class] =>  ' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ '

so far so good.


(32 to: 127) asWordArray asString do: [:c| c class] => 'a WordArray(32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127)'

?!?!?!

Surely this should be a String of some sort also?  Any objections if I implement this as such?


Are you saying you want to override asString in WordArray so you get a string-representation of the WordArray instead of its printString?  I wasn't sure whether the do: part of those code snippets fits into your question and if I missed something..

I'm sure Eliot meant to ignore the "do:" part. It's only about #asString.

Eliot: a more descriptive subject would have been nice ;)

Yes, but which string?
Maybe you wan't to turn the WordArray into a WideString ?

This is useful, and symmetrical with ByteArray>>asString..

Yep. We should also have String>>asWordArray.

We want

aString asWordArray asString = aString

just like

aByteString asByteArray asString = aByteString

And while we're on that topic, this is just wrong:

'foo' asWideString asByteArray
=> #[0 0 0 102 0 0 0 111 0 0 0 111]

in particular since

#(1 2 3) asWordArray asByteArray
=>  #[1 2 3]

- Bert -





smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: anyone rely on this?

Frank Shearar-3
On 3 July 2014 11:58, Bert Freudenberg <[hidden email]> wrote:

> On 03.07.2014, at 03:54, Eliot Miranda <[hidden email]> wrote:
>
> On Wed, Jul 2, 2014 at 5:26 PM, Nicolas Cellier
> <[hidden email]> wrote:
>>
>>
>> 2014-07-03 1:59 GMT+02:00 Chris Muller <[hidden email]>:
>>
>>> On Wed, Jul 2, 2014 at 2:47 PM, Eliot Miranda <[hidden email]>
>>> wrote:
>>>>
>>>> Hi All,
>>>>
>>>>
>>>> (32 to: 127) asByteArray asString do: [:c| c class] =>  '
>>>> !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
>>>> '
>>>>
>>>> so far so good.
>>>>
>>>>
>>>> (32 to: 127) asWordArray asString do: [:c| c class] => 'a WordArray(32
>>>> 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
>>>> 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
>>>> 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
>>>> 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
>>>> 125 126 127)'
>>>>
>>>> ?!?!?!
>>>>
>>>> Surely this should be a String of some sort also?  Any objections if I
>>>> implement this as such?
>>>>
>>>
>>> Are you saying you want to override asString in WordArray so you get a
>>> string-representation of the WordArray instead of its printString?  I wasn't
>>> sure whether the do: part of those code snippets fits into your question and
>>> if I missed something..
>
>
> I'm sure Eliot meant to ignore the "do:" part. It's only about #asString.
>
> Eliot: a more descriptive subject would have been nice ;)
>
>> Yes, but which string?
>> Maybe you wan't to turn the WordArray into a WideString ?
>
>
> This is useful, and symmetrical with ByteArray>>asString..
>
>
> Yep. We should also have String>>asWordArray.
>
> We want
>
> aString asWordArray asString = aString
>
> just like
>
> aByteString asByteArray asString = aByteString
>
> And while we're on that topic, this is just wrong:
>
> 'foo' asWideString asByteArray
> => #[0 0 0 102 0 0 0 111 0 0 0 111]

Why is that wrong? Because #asByteArray doesn't make sense without
specifying an encoding?

frank

> in particular since
>
> #(1 2 3) asWordArray asByteArray
> =>  #[1 2 3]
>
> - Bert -
>
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: anyone rely on this?

Bert Freudenberg
On 03.07.2014, at 13:07, Frank Shearar <[hidden email]> wrote:

> On 3 July 2014 11:58, Bert Freudenberg <[hidden email]> wrote:
>>
>> And while we're on that topic, this is just wrong:
>>
>> 'foo' asWideString asByteArray
>> => #[0 0 0 102 0 0 0 111 0 0 0 111]
>
> Why is that wrong? Because #asByteArray doesn't make sense without
> specifying an encoding?

That, and it exposes endianness which is not a good idea either. Besides, this is what asByteArray is supposed to do:

asByteArray
        "Answer a ByteArray whose elements are the elements of the receiver."

... but "0" is not an element of that string in any sensible interpretation. I would expect

        'foo' asWideString asByteArray = 'foo' asByteArray

(and asByteArray should raise an exception for larger values)

Encoding the string would make sense, but is something else entirely, yes.

>> in particular since
>>
>> #(1 2 3) asWordArray asByteArray
>> =>  #[1 2 3]

This is sensible, and does raise the exception.

- Bert -






smime.p7s (5K) Download Attachment