The go language spec is one of my favorite things about go. Is a learnxiny on steroids. In less than an hour, you fully understand the language.
I am curious to see how this functionality will change the spec. Will it double it in size?
The go language spec is one of my favorite things about go. Is a learnxiny on steroids. In less than an hour, you fully understand the language.
I am curious to see how this functionality will change the spec. Will it double it in size?
To me it always struck me as overly casual and loose compared to other languages, and reads more like a guide.
For example, what does the following C# code print?
UInt32 x = 1;
UInt32 s = x >> 32;
Console.WriteLine("" + s);
How about the following Go code? var x uint32 = 1
var s uint32 = x >> 32
fmt.Println(s)
I can easily answer the question for Go looking at the Go spec, but I cannot seem to find anywhere documented in the C# spec its (more surprising) behavior.“For the predefined operators, the number of bits to shift is computed as follows:
- When the type of x is int or uint, the shift count is given by the low-order five bits of count. In other words, the shift count is computed from count & 0x1F.
- When the type of x is long or ulong, the shift count is given by the low-order six bits of count. In other words, the shift count is computed from count & 0x3F.”