Re: [go-nuts] inconsistent min max signatures with variadics

2025-01-20 Thread 'Dan Kortschak' via golang-nuts
Agreed. My understanding was that this was because the min and max functions get written as an unrolled set of cmp instructions, rather than as a loop, and while this was not included in the spec for obvious reasons, it is why the spec was written that way. Dan On Mon, 2025-01-20 at 14:35 -0800,

Re: [go-nuts] inconsistent min max signatures with variadics

2025-01-20 Thread Ian Lance Taylor
On Mon, Jan 20, 2025 at 11:35 AM 'Dan Kortschak' via golang-nuts wrote: > > On Mon, 2025-01-20 at 10:42 -0800, Ian Lance Taylor wrote: > > Calling append with an empty slice is well defined. Calling min or > > max with an empty slice is not. > > If the only input to min/max were the slice, this wo

[go-nuts] Go 1.24 BLooper

2025-01-20 Thread peterGo
Go 1.24 introduces B.Loop() to replace B.N. https://pkg.go.dev/testing@go1.24rc2#B.Loop https://pkg.go.dev/testing@go1.24rc2#B testing: add testing.B.Loop for iteration #61515 https://github.com/golang/go/issues/61515 As suggested by @rsc, b.Loop could be a clear signal to the com

Re: [go-nuts] inconsistent min max signatures with variadics

2025-01-20 Thread Benoît Marguerie
Thanks Ian and Dan for your returns. I'm pretty agree with Dan considering that if append can understand that an empty slice provides nothing to add, I think min/max should be able to understand that an empty slice provides nothing to compare to the first param. Moreover, today, it is possible

Re: [go-nuts] inconsistent min max signatures with variadics

2025-01-20 Thread 'Dan Kortschak' via golang-nuts
On Mon, 2025-01-20 at 10:42 -0800, Ian Lance Taylor wrote: > Calling append with an empty slice is well defined. Calling min or > max with an empty slice is not. If the only input to min/max were the slice, this would be true, but I do not think it is in the case that is implemented in the standar

Re: [go-nuts] Example tests: access to module testdata files

2025-01-20 Thread 'Sean Liao' via golang-nuts
The playground, which also serves pkg.go.dev examples. runs in an isolated environment with just the built test/example binary, without the source code. Consider embedding any files you need with "embed" and accessing them through io/fs.FS rather than through os calls. - sean On Fri, Jan 10, 2025

[go-nuts] Re: Example tests: access to module testdata files

2025-01-20 Thread Charles Pustejovsky
It looks like you're code is failing because you're trying to open from Your operator is opening new Mboxs and the paths you pass in are assuming the main.go is called from that directory. https://github.com/rorycl/mailboxoperator/blob/main/mbox/mbox.go#L28 I'm not sure how you would resolve t

Re: [go-nuts] inconsistent min max signatures with variadics

2025-01-20 Thread Ian Lance Taylor
On Mon, Jan 20, 2025 at 7:00 AM Benoît Marguerie wrote: > > Even if the spec precises : > > slice arguments are not permitted > > I wonder if there's any real technical reason to prohibit the use of the > slice variadics during min/max buildin functions, when it's allowed with > append (which cr

[go-nuts] Re: inconsistent min max signatures with variadics

2025-01-20 Thread Benoît Marguerie
If I remember well, max(slice...) existed but not anymore: it disappeared with Go 1.21 I think. The idea was to force one element at least -> why not, that's the "min/max business" I may say. But the "unpacking" operator is a builtin and should be allowed for all func with a variadic input para

[go-nuts] Re: inconsistent min max signatures with variadics

2025-01-20 Thread Stephen Illingworth
Oh I see what you mean now. Should max(slice...) be allowed (ie. just the slice and no unary value) ? It would behave like slices.Max() I think. Maybe there is deep reason for not allowing but it would be nice to have for sure. On Monday, 20 January 2025 at 15:21:10 UTC Benoît Marguerie wrote:

[go-nuts] Re: inconsistent min max signatures with variadics

2025-01-20 Thread Benoît Marguerie
Hi Stephen, max(5,slice) has no sense by itself, I'm agree with you. But the issue is about max(5,*slice...*) which should accept the "unpacking" operation like the append function. I know there's a buildin type "Type" for append while the min/max functions use the Generic with the interface cm

[go-nuts] Re: inconsistent min max signatures with variadics

2025-01-20 Thread Stephen Illingworth
What value do you think should be returned for "max(5, slice)" ? On Monday, 20 January 2025 at 15:00:04 UTC Benoît Marguerie wrote: > Hi, > > Even if the spec precises : > > slice arguments are not permitted > > I wonder if there's any real technical reason to prohibit the use of the > slice var

[go-nuts] inconsistent min max signatures with variadics

2025-01-20 Thread Benoît Marguerie
Hi, Even if the spec precises : > slice arguments are not permitted I wonder if there's any real technical reason to prohibit the use of the slice variadics during *min/max* buildin functions, when it's allowed with *append* (which creates inconsistent behavior between buildin functions)? Exam