Re: [go-nuts] Give us const arrays please :)

2021-04-13 Thread tapi...@gmail.com
More immutable value proposals: 
https://github.com/go101/go101/wiki/Go-immutable-value-proposal-list

On Sunday, April 11, 2021 at 8:47:31 PM UTC-4 Kurtis Rader wrote:

> This has been formally requested several times. For example:
>
> https://github.com/golang/go/issues/20443
> https://github.com/golang/go/issues/22876
>
> I'm also willing to bet you are basing your request on experience with a 
> language such as C. Adopting ideas from other languages is fine but 
> blindly, and simplistically, shoehorning a feature from another language 
> almost never has a satisfying result.
>
> On Sun, Apr 11, 2021 at 4:33 PM 'Vladimir Efanov' via golang-nuts <
> golan...@googlegroups.com> wrote:
>
>> Hi Go-Masters
>>
>> It will be very useful to get constant arrays in Golang.
>> Programmers asked about it for years .
>>
>> For now we all should write not exported array definitions 
>> and exported functions to get read access to it.
>>
>> *What we need*
>> const *M*yArray = [n]T = {...} or initMyArrayFunc()
>>
>> *What we have*
>> // ---
>> var ws = [256]bool{' ': true, '\t': true, '\n\: true, '\r\: true}
>> // IsWhitespace checks 
>> func IsWhitespace(c byte) bool {
>> return whitespace[c]
>> }
>> // ---
>> var letter = [256]bool{
>> 'A': true, 'B': true, 'C': true, 'D': true, 'E': true, 'F': true, 
>> ...
>> }
>> //  IsLetterASCII checks a start of an ASCII identifier
>> func  IsLetterASCII(c byte) bool {
>> return letter[c] // 'A'-'Z', 'a'-'z', '_'
>> }
>>  and so on ...
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/01f4a524-9463-4770-8f9d-a17962cd5ba7n%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/cd8265e6-c87b-417d-90ef-5c5a9eecc958n%40googlegroups.com.


Re: [go-nuts] Give us const arrays please :)

2021-04-11 Thread Kurtis Rader
This has been formally requested several times. For example:

https://github.com/golang/go/issues/20443
https://github.com/golang/go/issues/22876

I'm also willing to bet you are basing your request on experience with a
language such as C. Adopting ideas from other languages is fine but
blindly, and simplistically, shoehorning a feature from another language
almost never has a satisfying result.

On Sun, Apr 11, 2021 at 4:33 PM 'Vladimir Efanov' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> Hi Go-Masters
>
> It will be very useful to get constant arrays in Golang.
> Programmers asked about it for years .
>
> For now we all should write not exported array definitions
> and exported functions to get read access to it.
>
> *What we need*
> const *M*yArray = [n]T = {...} or initMyArrayFunc()
>
> *What we have*
> // ---
> var ws = [256]bool{' ': true, '\t': true, '\n\: true, '\r\: true}
> // IsWhitespace checks
> func IsWhitespace(c byte) bool {
> return whitespace[c]
> }
> // ---
> var letter = [256]bool{
> 'A': true, 'B': true, 'C': true, 'D': true, 'E': true, 'F': true,
> ...
> }
> //  IsLetterASCII checks a start of an ASCII identifier
> func  IsLetterASCII(c byte) bool {
> return letter[c] // 'A'-'Z', 'a'-'z', '_'
> }
>  and so on ...
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/01f4a524-9463-4770-8f9d-a17962cd5ba7n%40googlegroups.com
> 
> .
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD_ziekjYVZgBAky3ekznQ_mKbMpCwkh10hbSxo8N6eNuQ%40mail.gmail.com.


[go-nuts] Give us const arrays please :)

2021-04-11 Thread 'Vladimir Efanov' via golang-nuts
Hi Go-Masters

It will be very useful to get constant arrays in Golang.
Programmers asked about it for years .

For now we all should write not exported array definitions 
and exported functions to get read access to it.

*What we need*
const *M*yArray = [n]T = {...} or initMyArrayFunc()

*What we have*
// ---
var ws = [256]bool{' ': true, '\t': true, '\n\: true, '\r\: true}
// IsWhitespace checks 
func IsWhitespace(c byte) bool {
return whitespace[c]
}
// ---
var letter = [256]bool{
'A': true, 'B': true, 'C': true, 'D': true, 'E': true, 'F': true, 
...
}
//  IsLetterASCII checks a start of an ASCII identifier
func  IsLetterASCII(c byte) bool {
return letter[c] // 'A'-'Z', 'a'-'z', '_'
}
 and so on ...



-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/01f4a524-9463-4770-8f9d-a17962cd5ba7n%40googlegroups.com.