Yeah, it's not the first time this question appears and it's not
immediately obvious that Go compiler can do this optimization.
IIRC someone asked for this optimization on Github and it's there, but
Go doesn't allow bool to int conversion therefore it can't do this
optimization implicitly, which i
To me your example appears somewhat confusing, int(bool(int())) is the
fishiest part IMO. I assume bool(int()) is just (v^v1 != 0) in
disguise and this is essentially
(v^v1 != 0) & (v^v2 != 0) & (v^v3 != 0)
Am i right?
Go can't & bools, so
func bool2int(b bool) int { // This is what Go compiler
If you're looking for efficiency, try to sync on a single mutex. The
best kind of syncing is the one that didn't happen, depending on your
circumstances, pthreads mutex can beat channels even taking into
account context switching because syncing on channel isn't free
either.
Implementing thread-sa
Yeah, that's a good point. A C unit that is using f() won't
necessarily include f's implementation if it is defined somewhere
else. It may create a (weak?) reference to f() and leave the rest to
the linker. However to compile correctly it would *normally* include a
header where f() is declared to a
There is no direct relationship between headers and object files in C
or C++. Compilation process is two stage:
1. Source files are compiled into object files
2. Object files are linked together into executable of sorts
(Actually it's a three stage process, but i'm going to describe it
using two
Try to use two channels: one to signal that the receiver needs a new
value and another one to send new value to the receiver. Supposedly
the sender won't block if you're using `select` to check what
receivers need values, and the receiver can block until a new value is
arrived at the input channel.
https://godbolt.org/z/6n7G8q
I'm actually not sure how good this assembly is, it would be
interesting to hear from you, but it looks promising.
вт, 1 сент. 2020 г. в 22:54, Oliver Smith :
>
> In the process of developing a piece of middleware, I need to translate from
> a bit-array into a bitmas
You are probably thinking about code like this:
var f2 = *f1
Which will make a copy, although not because `f1` is dereferenced, but
because `=` was called on a value.
Dereferencing a pointer gives a reference to the same value, taking
address of the same value will produce a pointer to the same
u very much.
чт, 23 июл. 2020 г. в 09:16, Ian Lance Taylor :
>
> On Wed, Jul 22, 2020 at 9:41 PM Aleksey Tulinov
> wrote:
> >
> > This is Java-style inheritance. It isn't bad, but i think that
> > C++-style composition is somehow more in the spirit of Go. Strictl
I'm not sure if i understood everything correctly.
type structField(type T) struct {
a int
x T
}
But this is a generic type, not a constraint for a type, isn't it?
Constraint is this:
type Custom interface{
type int, float64, uint64
}
type structField(type T Custom) interface {
ty
idea of releasing this in parts, i'll be keeping track
of this, this is a much needed feature. Thank you for looking into
this.
чт, 23 июл. 2020 г. в 00:21, Ian Lance Taylor :
>
> On Wed, Jul 22, 2020 at 1:46 PM Aleksey Tulinov
> wrote:
> >
> > I'm not really a langua
Hi,
I'm not really a language designer and i don't use Go extensively, so
please take my words with a grain of salt. But I like Go and would
like to use it, and I'd like to put my 2 cents into the jar. I'm sorry
if this was already discussed, I checked the mailing list but didn't
find this.
I've
12 matches
Mail list logo