Re: [go-nuts] Re: Why this compilation error ?

2025-03-18 Thread tapi...@gmail.com
s/code/cost On Tuesday, March 18, 2025 at 10:22:48 PM UTC+8 tapi...@gmail.com wrote: > Inline cost is estimated at compile time, not the real code. > > But I sorry to say "*new(T) has a smaller inline cost than T{}". it is a > little larger in fact. > The inline cost of

Re: [go-nuts] Re: Why this compilation error ?

2025-03-18 Thread tapi...@gmail.com
chak wrote: > On Mon, 2025-03-17 at 21:03 -0700, tapi...@gmail.com wrote: > > I prefer *new(T) over T{}, because not only the reason here, but also > > the former has a smaller inline cost. > > What do you mean by "inline cost"? > > https://godbolt.org/z/h8Krq7W8G

Re: [go-nuts] Re: Why this compilation error ?

2025-03-17 Thread tapi...@gmail.com
I prefer *new(T) over T{}, because not only the reason here, but also the former has a smaller inline cost. On Monday, March 17, 2025 at 4:49:51 PM UTC+8 Jan Mercl wrote: > On Mon, Mar 17, 2025 at 9:45 AM tapi...@gmail.com > wrote: > > > You can use *new(Version) instead of Ver

[go-nuts] Re: Why this compilation error ?

2025-03-17 Thread tapi...@gmail.com
You can use *new(Version) instead of Version{} to avoid parsing ambiguity. On Sunday, March 16, 2025 at 9:30:25 PM UTC+8 Christophe Meessen wrote: > Hello, > > You'll find the minimal example code generating the compilation error > here: https://go.dev/play/p/Vb-dNr2DpzM > > It is easy to get ar

[go-nuts] Re: Why can't single-method interfaces not be implemented by embedding?

2025-02-28 Thread tapi...@gmail.com
Just read https://go101.org/article/type-embedding.html The full form of the EqualName field is meter.EqualName, the full form of the EqualName method is mete.EqualName.EqualName. The longer one is shadowed by the shorter one. func main() { impl := new(impl) var m = &meter{ EqualName: impl, }

Re: [go-nuts] Is there a way to browse the stdlib packages in pkg.go.dev?

2025-02-02 Thread tapi...@gmail.com
An alternative std package list: https://docs.go101.org/std/index.html On Sunday, February 2, 2025 at 2:28:15 PM UTC+8 Axel Wagner wrote: > Yupp: > https://pkg.go.dev/std > > On Sun, 2 Feb 2025 at 07:21, will@gmail.com > wrote: > >> To be clear, I mean see a listing of all the packages in t

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-31 Thread tapi...@gmail.com
an't think of any other behavior which is possible. > > On Thursday, 30 January 2025 at 19:27:51 UTC tapi...@gmail.com wrote: > >> On Tuesday, January 28, 2025 at 7:07:15 PM UTC+8 Brian Candler wrote: >> >> > The documentation tells that Fscanln() is similar to Fsc

Re: [go-nuts] Fscan() eats 1st char in scanning values

2025-01-30 Thread tapi...@gmail.com
On Tuesday, January 28, 2025 at 7:07:15 PM UTC+8 Brian Candler wrote: > The documentation tells that Fscanln() is similar to Fscan(), my test shows that it isn't true for some cases. "similar" does not mean "the same as". Fscanln chomps the fields given, then chomps the next character. If th

[go-nuts] Re: how to get dirt memory in go

2025-01-14 Thread tapi...@gmail.com
see https://go101.org/q-and-a/make-dirty-byte-slices.html On Tuesday, January 14, 2025 at 9:44:40 PM UTC+8 Vasiliy Tolstov wrote: > Hi! I'm try to search answers but have no luck. In go i can create > memory arena/ buffer pool etc.. > But does it possible to get memory with like make([]byte, XXX)

Re: [go-nuts] Is it necessary to change the behavior of maps.Keys and maps.Values?

2024-12-30 Thread tapi...@gmail.com
On Tuesday, December 31, 2024 at 9:42:50 AM UTC+8 tapi...@gmail.com wrote: On Monday, December 30, 2024 at 6:12:10 AM UTC+8 Axel Wagner wrote: Why don't I use the sequence versions more frequently? Because I try not to create huge in-memory maps and instead prefer to move logic

Re: [go-nuts] Unexpected behavior where panic raised in-between two phases of an assignment statement

2024-12-30 Thread tapi...@gmail.com
There is not a phase between in-between, Any evaluation must happen in either of the two phases. On Sunday, December 29, 2024 at 3:13:38 PM UTC+8 Kaiming Yang wrote: > An update from the bug: Seems the behavior is WAI because the execution > order of dereference and function calls are not defi

Re: [go-nuts] Is it necessary to change the behavior of maps.Keys and maps.Values?

2024-12-30 Thread tapi...@gmail.com
On Monday, December 30, 2024 at 6:12:10 AM UTC+8 Axel Wagner wrote: Why don't I use the sequence versions more frequently? Because I try not to create huge in-memory maps and instead prefer to move logic that manipulates large amounts of data into a proper database. Iterators are more effi

Re: [go-nuts] Is it necessary to change the behavior of maps.Keys and maps.Values?

2024-12-30 Thread tapi...@gmail.com
Please note that "maps.Collect" is slow. https://github.com/golang/go/issues/68261 It is best to write your own custom Collect function. On Monday, December 30, 2024 at 5:50:47 AM UTC+8 Mike Schinkel wrote: > > On Dec 29, 2024, at 1:28 AM, Axel Wagner > wrote: > > > > At the end of the day,

Re: [go-nuts] Re: Working with release candidates

2024-12-20 Thread tapi...@gmail.com
If you want to know clearly which toolchain version you are using, you can try GoTV (https://go101.org/apps-and-libs/gotv.html). I have used it for two years almost without touching the `go` command directly. On Saturday, December 21, 2024 at 6:07:35 AM UTC+8 Jeffery Carr wrote: > Wow. This syn

[go-nuts] Re: The possibilty run go source code as real scripts

2024-11-22 Thread tapi...@gmail.com
On Friday, November 22, 2024 at 5:27:10 PM UTC+8 Lin Lin wrote: Hi, gophers, here is our dilemma. We build system managing infrastructure such as Kubernetes. With that comes the need to write a lot of maintenance scripts. For now they are all written in Bash, which is hard to edit and test.

Re: [go-nuts] Generic type alias with type conversion

2024-11-04 Thread tapi...@gmail.com
On Monday, November 4, 2024 at 1:47:30 PM UTC+8 Ian Lance Taylor wrote: On Sun, Nov 3, 2024 at 12:41 AM hey...@gmail.com wrote: > > Not sure generic type alias is the solution, but what I'm trying to do is I have a type like this > > type Map[K comparable, V any] struct { m map[K]V } > >

Re: [go-nuts] Generic type alias with type conversion

2024-11-04 Thread tapi...@gmail.com
Why do you have to use alias here? What is the problem if omap is not an alias? On Monday, November 4, 2024 at 6:39:51 PM UTC+8 hey...@gmail.com wrote: Thanks for the reply. Does that mean it's currently not possible to conditionally implement a method based on type parameters? And the solut

Re: [go-nuts] Re: Check Channel is active or not while Writing as writer Go routine

2024-11-02 Thread tapi...@gmail.com
On Thursday, October 31, 2024 at 10:24:23 PM UTC+8 Nico Braun wrote: I think not closing the channel has the side effect, of making it easier to leak goroutines. If your memory is growing, its likely that there is still a receiver who didn't realize there is nothing more to receive. That is one

[go-nuts] Re: Check Channel is active or not while Writing as writer Go routine

2024-10-29 Thread tapi...@gmail.com
https://github.com/golang/go/issues/21985 https://github.com/golang/go/issues/28017 Personally, I think this is an interesting idea. On Thursday, October 24, 2024 at 9:08:33 PM UTC+8 Aniket Pandey wrote: > Has anyone have implemented the logic in order to check if the channel is > active if th

[go-nuts] Re: good practice or premature optimization

2024-10-10 Thread tapi...@gmail.com
On Thursday, October 10, 2024 at 11:51:02 AM UTC+8 Nico Braun wrote: Hi, recently I became very self aware of potential performance implications my code might have. In go there are a few key concepts, like escape analysis and bound checks. If you check the standard library, you can see it was

[go-nuts] Re: I want to know the reason behind slices.Clone using append s[:0:0]

2024-10-01 Thread tapi...@gmail.com
s/hard/harm On Wednesday, October 2, 2024 at 12:50:59 PM UTC+8 tapi...@gmail.com wrote: > On Monday, September 30, 2024 at 1:51:17 PM UTC+8 Hikmatulloh Hari Mukti > (Hari) wrote: > > > Maybe I should apologize for the origin of this idea: > https://github.com/go101/go101/wik

[go-nuts] Re: I want to know the reason behind slices.Clone using append s[:0:0]

2024-10-01 Thread tapi...@gmail.com
orld case for this though. If someone want to intentionally keep alive slice's underlying array, she/he can use s[:0] instead. On Friday 27 September 2024 at 14:16:36 UTC+7 tapi...@gmail.com wrote: Maybe I should apologize for the origin of this idea: https://github.com/go101/go101/wiki/How

[go-nuts] Re: I want to know the reason behind slices.Clone using append s[:0:0]

2024-09-27 Thread tapi...@gmail.com
Maybe I should apologize for the origin of this idea: https://github.com/go101/go101/wiki/How-to-perfectly-clone-a-slice%3F When I posted that wiki article, I was not aware of this (maybe tiny) drawback. My current opinion is that it is best to let the Go runtime specialize zero-capacity slic

[go-nuts] Re: Comparison of pointers to distinct zero-sized variables

2024-06-20 Thread tapi...@gmail.com
see: https://github.com/golang/go/issues/65878 package main var a, b [0]int var p, q = &a, &b func main() { if (p == q) { p, q = &a, &b println(p == q) // false } } On Thursday, June 20, 2024 at 12:59:43 AM UTC+8 Oliver Eikemeier wrote: > I'm observing some strange behavior and could use some

Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-29 Thread tapi...@gmail.com
e you did not get your will at the time, you are now bringing it up to troll unrelated conversations. With no actually coherent position. And so your "one-sentence emoticon" message is neither charming, clever, witty nor funny. It's simply disrespectful. 👍 On Thu, Feb 29, 202

Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-29 Thread tapi...@gmail.com
On Thursday, February 29, 2024 at 3:14:40 PM UTC+8 Axel Wagner wrote: The loop var change *does* break compatibility. And it did so knowingly and - as clearly explained - was an exception. Stop arguing in bad faith. An exception. :D On Thu, Feb 29, 2024 at 7:03 AM tapi...@gmail.com

Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-28 Thread tapi...@gmail.com
On Wednesday, February 28, 2024 at 3:19:37 PM UTC+8 Axel Wagner wrote: That would break backwards compatibility, though. And it would be a re-definition (i.e. existing code would compile, but behave differently at runtime) and is hence not allowed even under the Go 2 transition rules. With G

Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-26 Thread tapi...@gmail.com
On Tuesday, February 27, 2024 at 3:42:25 PM UTC+8 Jan Mercl wrote: On Tue, Feb 27, 2024 at 6:20 AM tapi...@gmail.com wrote: > From common sense, this is an obvious bug. But the spec is indeed not clear enough. > It doesn't state whether or not comparisons of pointers to two dis

[go-nuts] Re: Failed to compile a generic code using embedded struct

2024-02-26 Thread tapi...@gmail.com
use type Test[T, V interface{A; I}] struct{} instead now. There are still several restrictions in custom generics: https://go101.org/generics/888-the-status-quo-of-go-custom-generics.html On Monday, February 26, 2024 at 10:44:46 PM UTC+8 Albert Widiatmoko wrote: > Hi Go community, > > I

Re: [go-nuts] Equality of interface of an empty struct - why?

2024-02-26 Thread tapi...@gmail.com
>> it would be valid for `==` on pointers to zero-sized types to always evaluate to `true`, This would be more straightforward behavior. On Feb 26, 2024, at 9:24 AM, tapi...@gmail.com wrote: package main var a, b [0]int var p, q = &a, &b func main() { if (p == q) { p, q = &am

[go-nuts] Re: Equality of interface of an empty struct - why?

2024-02-26 Thread tapi...@gmail.com
package main var a, b [0]int var p, q = &a, &b func main() { if (p == q) { p, q = &a, &b println(p == q) // false } } On Thursday, February 22, 2024 at 6:55:49 PM UTC+8 Brien Colwell wrote: > I'm confused by this output. It appears that the interface of two > different pointers to an empty str

[go-nuts] Re: Equality of interface of an empty struct - why?

2024-02-25 Thread tapi...@gmail.com
The behavior of Go 1.9 or 1.10 is even more weird. They make the following code print false. ;D package main type T struct {} func main() { var a, b = &T{}, &T{} println(a == b || a != b) } On Sunday, February 25, 2024 at 4:30:22 PM UTC+8 tapi...@gmail.com wrote: > Absol

[go-nuts] Re: Equality of interface of an empty struct - why?

2024-02-25 Thread tapi...@gmail.com
Absolutely a bug. On Thursday, February 22, 2024 at 6:55:49 PM UTC+8 Brien Colwell wrote: > I'm confused by this output. It appears that the interface of two > different pointers to an empty struct are equal. In all other cases, > interface equality seems to be the pointer equality. What's goin

[go-nuts] Re: It seems that go 1.22 has optimized the implementation of string to byte slicing and no longer requires memory allocation.

2023-11-27 Thread tapi...@gmail.com
See https://github.com/golang/go/issues/2205 The tip compiler is able to detect some simple string->[]byte cases in which duplication is not needed. On Monday, November 27, 2023 at 8:12:54 PM UTC+8 fliter wrote: > It seems that go 1.22 has optimized the implementation of string to byte > slicin

Re: [go-nuts] Generic type for struct method: constraint problem && cannot use (untyped string constant) as string value

2023-11-09 Thread tapi...@gmail.com
The uint8 in cachedFn[uint8, V] is the type parameter name, it can be arbitrary valid identifier. It shadows the predeclared uint8 identifier. On Friday, November 10, 2023 at 12:25:05 PM UTC+8 ahuigo wrote: > Btw, please ignore the type logic in my code, I wrote this piece of code > just to ill

Re: [go-nuts] Can Generics match implementers of an interface?

2023-10-24 Thread tapi...@gmail.com
My another surprise is that the below partial instantiation doesn't work. s = slices.Insert[[]Suiter](s, len(s), Clubs{}) // not work s = slices.Insert[[]Suiter, Suiter](s, len(s), Clubs{}) // works On Monday, October 23, 2023 at 11:01:47 AM UTC+8 tapi...@gmail.com wrote: > On Monday,

Re: [go-nuts] Can Generics match implementers of an interface?

2023-10-24 Thread tapi...@gmail.com
gt; figure it out. > > -Mike > On Sunday, October 22, 2023 at 11:01:47 PM UTC-4 tapi...@gmail.com wrote: > >> On Monday, October 23, 2023 at 10:38:59 AM UTC+8 tapi...@gmail.com wrote: >> >> Sorry, I didn't look your full code. >> I think the full code sho

Re: [go-nuts] Can Generics match implementers of an interface?

2023-10-22 Thread tapi...@gmail.com
On Monday, October 23, 2023 at 10:38:59 AM UTC+8 tapi...@gmail.com wrote: Sorry, I didn't look your full code. I think the full code should work with Go toolchain 1.21.n. Aha, it actually doesn't. I'm surprised. On Sunday, October 22, 2023 at 4:40:55 PM UTC+8 Mike Schinkel

Re: [go-nuts] Can Generics match implementers of an interface?

2023-10-22 Thread tapi...@gmail.com
me other negative? > > -Mike > > On Saturday, October 21, 2023 at 11:57:52 PM UTC-4 tapi...@gmail.com > wrote: > > > It is hard to call such type inference better. That is too aggressive. > > -- You received this message because you are subscribed to the Google Groups &quo

Re: [go-nuts] Can Generics match implementers of an interface?

2023-10-21 Thread tapi...@gmail.com
On Sunday, October 22, 2023 at 4:09:51 AM UTC+8 Mike Schinkel wrote: @Axel Wagner — Thank you for adding clarity to this. Yes, it would be nice if we could get this to be handled with better type inference. It is hard to call such type inference better. That is too aggressive. But unl

Re: [go-nuts] Possible Go Compiler or Runtime bug?

2023-07-27 Thread tapi...@gmail.com
On Friday, July 28, 2023 at 6:44:21 AM UTC+8 wagner riffel wrote: On 27/07/2023 03:48, Kyle Harrity wrote: > Maybe this is a known issue and or expected behavior so I thought I'd > ask here before raising an issue on github. > I think I know what's going on, the compiler inlined getStrBytes

[go-nuts] Re: Short Variable Declarations Are Oversold

2023-04-23 Thread tapi...@gmail.com
Type inference is not the main purpose (or even the purpose) of short declarations. I do agree that the negative impact of short declarations is larger than its positive impact, for reasons different from the one you described. Some reasons: * short declarations causes confusions (esp, for new g

[go-nuts] Re: Redfining loop variable semantics - what's the plan?

2023-04-11 Thread tapi...@gmail.com
Not to mention that the change for "for;;" is so counter-intuitive and violates the try-to-be-explicit principle in Go. On Wednesday, April 12, 2023 at 9:08:24 AM UTC+8 tapi...@gmail.com wrote: > The plan for “for;;” is much more risky than “for-each”, because “for;;” > has mor

[go-nuts] Re: Redfining loop variable semantics - what's the plan?

2023-04-11 Thread tapi...@gmail.com
The plan for “for;;” is much more risky than “for-each”, because “for;;” has more variation uses in reality. I have no doubt that many non-bug compatibility-broken or performance-degradation cases will be found in the GOEXPERIMENT phase. On Saturday, March 25, 2023 at 2:44:59 PM UTC+8 Amnon wrot

Re: [go-nuts] Create a 1GB ballast but it takes up RSS and pages are Dirty?

2022-11-06 Thread tapi...@gmail.com
I ever also found this problem: global ballast doesn't work. So I always use local ballast instead now. On Sunday, November 6, 2022 at 8:37:55 PM UTC+8 hit.zh...@gmail.com wrote: > Before, I think the memory is allocated by mmap anon, which Linux OS > guarantees reading will return zero value an

Re: [go-nuts] godoc and generic code

2022-11-03 Thread tapi...@gmail.com
You may also try Golds: https://github.com/go101/golds. Still not perfect in handling custom generic things, but it is generally usable. On Friday, November 4, 2022 at 1:26:26 AM UTC+8 Hotei wrote: > Thanks for the very helpful replies. < go doc -all pkg > should meets my > needs for printed doc

Re: [go-nuts] Re: What's the maximum array length?

2022-10-29 Thread tapi...@gmail.com
gt; say that your reply is invalid. I'm just curious how you view your reply as >> being more clear than mine. :-) >> >> >>> On Fri, Oct 28, 2022 at 8:57 PM tapi...@gmail.com >>> wrote: >>> >>>> The max array length is math.MaxInt. &qu

[go-nuts] Re: What's the maximum array length?

2022-10-28 Thread tapi...@gmail.com
The max array length is math.MaxInt. "[math.MaxInt]struct{}" is valid, though the practical size of non-zero-size array is hard limited in some way. On Friday, October 28, 2022 at 9:43:16 AM UTC+8 eric...@arm.com wrote: > The spec says that " The length is part of the array's type; it must > ev

[go-nuts] Re: What is the relationship between go community and goproxy.io

2022-10-10 Thread tapi...@gmail.com
On Monday, October 10, 2022 at 3:11:06 PM UTC+8 Brian Candler wrote: > > By the go module cache system design, if you trust the server set in > your GOSUMDB env var, > > which is defaulted to sum.golang.org, then it is not a matter whatever > proxy server your are using. > > From the point of

[go-nuts] Re: What is the relationship between go community and goproxy.io

2022-10-09 Thread tapi...@gmail.com
On Sunday, October 9, 2022 at 11:50:49 PM UTC+8 ljh wrote: > Hi, community, > > I Just saw this site: yunzhanghu.com , is listed as Special Sponsor on > goproxy.io homepage. > > I'm just curious, is goproxy.io endorsed by The Go Team and is goproxy.io > trustworthy? > By the go module cache

[go-nuts] Re: private go documentation server similar to https://pkg.go.dev

2022-09-11 Thread tapi...@gmail.com
I don't know if it satisfies your need, but you can try Golds: https://go101.org/apps-and-libs/golds.html On Sunday, September 11, 2022 at 5:28:35 AM UTC+8 brainman wrote: > Hello Everyone, > > I would like to run go documentation server that have access to my private > code. > > Is it possible

[go-nuts] Re: Go 1.19 average goroutine stack

2022-08-22 Thread tapi...@gmail.com
On Saturday, August 20, 2022 at 10:58:10 PM UTC+8 tapi...@gmail.com wrote: > On Friday, August 19, 2022 at 12:14:55 AM UTC+8 k...@google.com wrote: > >> On Wednesday, August 17, 2022 at 8:18:35 PM UTC-7 tapi...@gmail.com >> wrote: >> >>> I'm a bit wonderin

[go-nuts] Re: Go 1.19 average goroutine stack

2022-08-20 Thread tapi...@gmail.com
s 0%: 0.098+2.6+0.011 ms clock, 0.39+0/2.5/7.5+0.044 ms cpu, 0->0->0 MB, 118 MB goal, 128 MB stacks, 8 MB globals, 4 P (forced) 2022/08/20 22:52:02 16777216 3 On Saturday, August 20, 2022 at 10:58:10 PM UTC+8 tapi...@gmail.com wrote: > On Friday, August 19, 2022 at 12:14:55 AM UTC+8 k

[go-nuts] Re: Go 1.19 average goroutine stack

2022-08-20 Thread tapi...@gmail.com
On Friday, August 19, 2022 at 12:14:55 AM UTC+8 k...@google.com wrote: > On Wednesday, August 17, 2022 at 8:18:35 PM UTC-7 tapi...@gmail.com wrote: > >> I'm a bit wondering about how the following case will be affected by the >> change: >> 1. Initially, there is on

[go-nuts] Re: Go 1.19 average goroutine stack

2022-08-17 Thread tapi...@gmail.com
I'm a bit wondering about how the following case will be affected by the change: 1. Initially, there is one goroutine, which stack size is large at the time of a GC process. 2. After the GC process, a large quantity of goroutines start. They all need small stacks. But now the runtime will all

Re: [go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-15 Thread tapi...@gmail.com
I tend to think it should print 1, as well this one: https://go.dev/play/p/bax7CoaSV1d On Monday, August 15, 2022 at 3:34:35 PM UTC+8 tapi...@gmail.com wrote: > It would be good if the Memory Model article shows some atomic examples. > > On Monday, August 15, 2022 at 3:06:58 PM

[go-nuts] About Go 1.19 memory model clarificaitons on atomic operations.

2022-08-14 Thread tapi...@gmail.com
By the latest version of Go Memory Model article: https://go.dev/ref/mem, will the following program always print 1? https://go.dev/play/p/RICYGip5y8M -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop recei

Re: [go-nuts] Is there a compiler directive to use the Go version set in go.mod instead of the current toolchain version?

2022-05-10 Thread tapi...@gmail.com
commend but not force them to use a recent version. And this is not a 1.15/1.16 specific problem. > > On Tuesday, 10 May 2022 at 01:24:12 UTC+1 tapi...@gmail.com wrote: > >> On Tuesday, May 10, 2022 at 1:46:35 AM UTC+8 Ian Lance Taylor wrote: >> >>> On Mon, May 9, 2

Re: [go-nuts] Is there a compiler directive to use the Go version set in go.mod instead of the current toolchain version?

2022-05-09 Thread tapi...@gmail.com
On Tuesday, May 10, 2022 at 1:46:35 AM UTC+8 Ian Lance Taylor wrote: > On Mon, May 9, 2022 at 10:18 AM tapi...@gmail.com > wrote: > > > > I have a project using go1.16 embedding feature. > > The project supports Go toolchain 1.15, by using "//go:build !go1.16&q

[go-nuts] Is there a compiler directive to use the Go version set in go.mod instead of the current toolchain version?

2022-05-09 Thread tapi...@gmail.com
I have a project using go1.16 embedding feature. The project supports Go toolchain 1.15, by using "//go:build !go1.16" directive. Now I have upgraded the toolchain to v1.18.1, And I want to debug the non-embedding flow of the project. Changing the go version in go.mod doesn't help. Do I have to

Re: [go-nuts] Refactor to use generics to have a single Make

2022-05-03 Thread tapi...@gmail.com
On Wednesday, May 4, 2022 at 7:01:48 AM UTC+8 se...@liao.dev wrote: > right now it only works if the structs are actually identical: > https://go.dev/play/p/tMG3SYG5fLN > > - sean > > Though accessing fields is still not allowed. > > On Tue, May 3, 2022 at 8:06 PM sbezverk wrote: > >> Hello,

Re: [go-nuts] Are the two constraints equivalent to each other?

2022-04-02 Thread tapi...@gmail.com
Ah, I forgot that point. Thanks for the explanation! On Saturday, April 2, 2022 at 10:00:27 PM UTC+8 axel.wa...@googlemail.com wrote: > Ptr[int] is a defined type, `*int` is not. So the two types are not the > same and this is working as intended. > > On Sat, Apr 2, 2022 at

[go-nuts] Are the two constraints equivalent to each other?

2022-04-02 Thread tapi...@gmail.com
package main type Ptr[E any] *E type MyConstraint interface { Ptr[int] } type YourConstraint interface { *int } func foo[T MyConstraint](x T) { } func bar[T YourConstraint](x T) { } func main() { var x = new(int) foo(x) // *int does not implement MyConstraint bar(x) } --

Re: [go-nuts] Unexpected order of global variable declaration during package initialization

2022-03-24 Thread tapi...@gmail.com
Aha, sorry, the file order really matters here. But for this specified case, it should not. That's not right. I remembered in an issue thread, it is mentioned that the order should be 1. D is not ready (because it depends on A) 2. A is ready, so it is initialized: it gets value 3. 4. B is init

Re: [go-nuts] Is it safe to say two unname interface types are identical if their type sets are identicial?

2022-03-24 Thread tapi...@gmail.com
Then I think interface{int; m()} and interface{bool;; m()} should be identical. Because their type sets are both empty.. On Thursday, March 24, 2022 at 7:38:10 PM UTC+8 Jan Mercl wrote: > On Thu, Mar 24, 2022 at 11:58 AM tapi...@gmail.com > wrote: > > https://go.dev/ref/spec#T

Re: [go-nuts] Unexpected order of global variable declaration during package initialization

2022-03-24 Thread tapi...@gmail.com
BTW, the rewritten version outputs Init A Init B Init C 1 4 3 On my machine (go1.18 linux/amd64). On Thursday, March 24, 2022 at 7:30:37 PM UTC+8 tapi...@gmail.com wrote: > > 2. A < D < B < C - happens when f2.go is passed first to the compiler. > In this case, the *expe

Re: [go-nuts] Unexpected order of global variable declaration during package initialization

2022-03-24 Thread tapi...@gmail.com
> 2. A < D < B < C - happens when f2.go is passed first to the compiler. In this case, the *expected output *would be "1 2 1". However, the *actual output* is "1 2 3". This is not true by my understanding of the spec. https://go.dev/ref/spec#Package_initialization If f2.go is passed first, then

[go-nuts] Is it safe to say two unname interface types are identical if their type sets are identicial?

2022-03-24 Thread tapi...@gmail.com
. -- 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

Re: [go-nuts] Re: Is there a way to eliminate the code repetition in the code?

2022-03-22 Thread tapi...@gmail.com
Is it hard to add two predeclared constraints, convertibleFrom and convertibleTo, just like comparable? On Tuesday, March 22, 2022 at 11:07:41 PM UTC+8 Ian Lance Taylor wrote: > On Tue, Mar 22, 2022 at 6:01 AM tapi...@gmail.com > wrote: > > > > > > > > On Monday

[go-nuts] Re: Is there a way to eliminate the code repetition in the code?

2022-03-22 Thread tapi...@gmail.com
] = vs[i] } return r } > > > On Sunday, March 20, 2022 at 11:36:27 PM UTC+7 tapi...@gmail.com wrote: > >> >> >> package main >> >> type A interface { >> Ma() >> } >> >> type B interface { >> Mb()

[go-nuts] Re: type parameters and named type

2022-03-20 Thread tapi...@gmail.com
> *type parameters *itself is not a type, but a list of type parameters. true. The spec means a single type parameter is a named type. On Monday, March 21, 2022 at 12:12:26 AM UTC+8 xiej...@gmail.com wrote: > Hi there. > > I am reading go spec. When hit the "Types" section, > > https://go

[go-nuts] Is there a way to eliminate the code repetition in the code?

2022-03-20 Thread tapi...@gmail.com
package main type A interface { Ma() } type B interface { Mb() } type Ta struct { A } type Tb struct { B } func ConvertSliceToA[From A](vs []From) []A { var r = make([]A, len(vs)) for i := range vs { r[i] = vs[i] } return r } f

[go-nuts] The core type definition might be not right

2022-03-03 Thread tapi...@gmail.com
The tip spec states that the core type of a constraint is born from the type set of the constraint. https://tip.golang.org/ref/spec#Core_types So the C constraint in the following program should have no core type, because its type set is blank. But the foo function compiles okay, which indicates

Re: [go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread tapi...@gmail.com
Thanks for the reply, gri. The latest generics design and implementation are much more beautiful than I expected, though I still think there are many restrictions. BTW, it looks the following line in spec becomes depreciated now, as now any type could be embedded in interfaces. In a slightly m

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread tapi...@gmail.com
On Thursday, January 6, 2022 at 11:19:40 PM UTC+8 tapi...@gmail.com wrote: > On Thursday, January 6, 2022 at 9:40:52 PM UTC+8 tapi...@gmail.com wrote: > >> On Thursday, January 6, 2022 at 8:35:06 PM UTC+8 Brian Candler wrote: >> >>> No, the mistake is in your re

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread tapi...@gmail.com
On Thursday, January 6, 2022 at 9:40:52 PM UTC+8 tapi...@gmail.com wrote: > On Thursday, January 6, 2022 at 8:35:06 PM UTC+8 Brian Candler wrote: > >> No, the mistake is in your reading of the spec. You are complaining >> about this line: >> >> interface{ i

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread tapi...@gmail.com
sorry again. It should be "the type set and specific types of interface{ int; any } are both {int}." On Thursday, January 6, 2022 at 9:45:35 PM UTC+8 tapi...@gmail.com wrote: > On Thursday, January 6, 2022 at 9:44:05 PM UTC+8 tapi...@gmail.com wrote: > >> On Thursday, Janu

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread tapi...@gmail.com
On Thursday, January 6, 2022 at 9:44:05 PM UTC+8 tapi...@gmail.com wrote: > On Thursday, January 6, 2022 at 9:40:49 PM UTC+8 Brian Candler wrote: > >> So to be more specific, I think you're asking why this code works: >> https://gotipplay.golang.org/p/kuYzzx4EJY1 >&g

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread tapi...@gmail.com
On Thursday, January 6, 2022 at 9:40:49 PM UTC+8 Brian Candler wrote: > So to be more specific, I think you're asking why this code works: > https://gotipplay.golang.org/p/kuYzzx4EJY1 > > Sorry, I made a mistake in interpreting the spec. It also says: > > "The type set of the empty interface is

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread tapi...@gmail.com
the set of one type (int) with the > empty set, and therefore the result is the empty set. Exactly as the > comment says. > > On Thursday, 6 January 2022 at 11:47:52 UTC tapi...@gmail.com wrote: > >> On Thursday, January 6, 2022 at 6:15:06 PM UTC+8 Brian Candler wrote: >>

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread tapi...@gmail.com
3. "interface { int; any }" is an *intersection* of *specific types* > > You are taking the intersection of the set of one type (int) with the > empty set, and therefore the result is the empty set. Exactly as the > comment says. > > On Thursday, 6 January 2022 at 11

[go-nuts] Re: An mistake in tip spec?

2022-01-06 Thread tapi...@gmail.com
On Thursday, January 6, 2022 at 6:15:06 PM UTC+8 Brian Candler wrote: > 1. interface { a;b } is intersection. The "Intersection" between two sets > means things which exist in both sets simultaneously. > 2. interface { a|b } is union. "Union" means a set of things which which > exist in set A

[go-nuts] Re: An mistake in tip spec?

2022-01-05 Thread tapi...@gmail.com
Should it be interface{ int | any } // no specific types (intersection is empty) instead On Wednesday, January 5, 2022 at 11:20:16 PM UTC+8 tapi...@gmail.com wrote: > https://tip.golang.org/ref/spec#Structure_of_interfaces > >interface{ int; any } // no specific types (inters

[go-nuts] An mistake in tip spec?

2022-01-05 Thread tapi...@gmail.com
https://tip.golang.org/ref/spec#Structure_of_interfaces interface{ int; any } // no specific types (intersection is empty) Why the constraint has no specific types. Doesn't it specify int? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] some incorrect code in blog.

2021-11-26 Thread tapi...@gmail.com
Isn't the code should be: *func CopyFile() {* * ...* * if err != nil {* * return* * }* * defer func() { err = src.Close() }()* * ...* *}* On Thursday, November 25, 2021 at 12:18:20 PM UTC+8 Ian Lance Taylor wrote: > On Wed, Nov 24, 2021 at 6:14 PM Fannie Zhang wrote: > > > > The

[go-nuts] Re: compile time error vs runtime crash for same array

2021-11-26 Thread tapi...@gmail.com
There is an issue for this: https://github.com/golang/go/issues/17378 On Sunday, November 14, 2021 at 1:46:29 AM UTC+8 arthurwil...@gmail.com wrote: > On a 64bit Mac, this code: > > package main > > var X [^uint(0)>>14]byte > func main() { > } > > produces a compile time error: > main.X: symbol

[go-nuts] Re: compile time error vs runtime crash for same array

2021-11-26 Thread tapi...@gmail.com
It is 1 << 50 is the limit on heap. The following code doesn't compile: package main func main() { var X [1 << 50]byte // type [1125899906842624]byte larger than address space _ = X } But with 1 << 50 - 1, it compiles: package main func main() { var X [1 << 50 - 1]byte // runtime:

[go-nuts] Re: The runtime/slice_test.go shows most benchmarks become slower on tip (vs v1.17.3)

2021-11-22 Thread tapi...@gmail.com
fill an issue here: https://github.com/golang/go/issues/49744 On Tuesday, November 23, 2021 at 12:15:52 AM UTC+8 tapi...@gmail.com wrote: > Slower about 20%. As least, on my machine, it looks so. > As my machine is slow, I haven't use -count=10 and benchstat to make a > report

[go-nuts] The runtime/slice_test.go shows most benchmarks become slower on tip (vs v1.17.3)

2021-11-22 Thread tapi...@gmail.com
Slower about 20%. As least, on my machine, it looks so. As my machine is slow, I haven't use -count=10 and benchstat to make a report. -- 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

Re: [go-nuts] Re: About struct fields in type parameters

2021-11-12 Thread tapi...@gmail.com
what will land in go 1.18. > > On Fri, Nov 12, 2021 at 6:18 PM tapi...@gmail.com > wrote: > >> The SliceConstraint example also doesn't work. >> >> Is the doc I mentioned outdated? >> >> On Saturday, November 13, 2021 at 1:13:13 AM UTC+8 tapi...@gmai

Re: [go-nuts] How the scopes of type parameters are defined?

2021-11-12 Thread tapi...@gmail.com
> > On Fri, Nov 12, 2021 at 11:03 AM Axel Wagner > wrote: > >> >> >> On Fri, Nov 12, 2021 at 10:54 AM tapi...@gmail.com >> wrote: >> >>> >>> >>> On Friday, November 12, 2021 at 5:33:19 PM UTC+8 >>> axel.wa...@

Re: [go-nuts] How the scopes of type parameters are defined?

2021-11-12 Thread tapi...@gmail.com
Fri, Nov 12, 2021 at 11:03 AM Axel Wagner > wrote: > >> >> >> On Fri, Nov 12, 2021 at 10:54 AM tapi...@gmail.com >> wrote: >> >>> >>> >>> On Friday, November 12, 2021 at 5:33:19 PM UTC+8 >>> axel.wa...@googlemail.com wrote:

Re: [go-nuts] How the scopes of type parameters are defined?

2021-11-12 Thread tapi...@gmail.com
On Friday, November 12, 2021 at 6:04:01 PM UTC+8 axel.wa...@googlemail.com wrote: > On Fri, Nov 12, 2021 at 10:54 AM tapi...@gmail.com > wrote: > >> >> >> On Friday, November 12, 2021 at 5:33:19 PM UTC+8 >> axel.wa...@googlemail.com wrote: >> >>

Re: [go-nuts] Re: What is the problem of the generic use?

2021-11-12 Thread tapi...@gmail.com
i, Nov 12, 2021 at 6:18 AM tapi...@gmail.com > wrote: > >> sorry, a mistake, "int" -> "[]byte". >> >> On Friday, November 12, 2021 at 1:08:50 PM UTC+8 tapi...@gmail.com wrote: >> >>> >>> package main >>> >>>

[go-nuts] Re: About struct fields in type parameters

2021-11-12 Thread tapi...@gmail.com
The SliceConstraint example also doesn't work. Is the doc I mentioned outdated? On Saturday, November 13, 2021 at 1:13:13 AM UTC+8 tapi...@gmail.com wrote: > And this fails to compile, although the docs says it is valid: > > // sliceOrMap is a type constraint for a

[go-nuts] Re: About struct fields in type parameters

2021-11-12 Thread tapi...@gmail.com
pe T constrained by sliceOrMap } On Saturday, November 13, 2021 at 1:10:30 AM UTC+8 tapi...@gmail.com wrote: > The proposal design docs ( > https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md) > > mentions: > > // structField is

[go-nuts] About struct fields in type parameters

2021-11-12 Thread tapi...@gmail.com
The proposal design docs (https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md) mentions: // structField is a type constraint whose type set consists of some // struct types that all have a field named x. type structField interface { struc

Re: [go-nuts] Is this a known problem?

2021-11-12 Thread tapi...@gmail.com
On Friday, November 12, 2021 at 11:40:53 PM UTC+8 axel.wa...@googlemail.com wrote: > On Fri, Nov 12, 2021 at 4:29 PM tapi...@gmail.com > wrote: > >> On Friday, November 12, 2021 at 11:10:17 PM UTC+8 >> axel.wa...@googlemail.com wrote: >> >>> `range s` w

Re: [go-nuts] Is this a known problem?

2021-11-12 Thread tapi...@gmail.com
matters here? > > On Fri, Nov 12, 2021 at 3:18 PM tapi...@gmail.com > wrote: > >> >> func Bar[T []byte|string](s T) bool { >> for _, v := range s { // cannot range over s (variable of type T >> constrained by []byte|string) (T has no structural type) &g

[go-nuts] Is this a known problem?

2021-11-12 Thread tapi...@gmail.com
func Bar[T []byte|string](s T) bool { for _, v := range s { // cannot range over s (variable of type T constrained by []byte|string) (T has no structural type) if v > 100 { return true } } return false } The message is quite confusing. -- You received th

  1   2   3   >