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

2024-12-28 Thread Kaiming Yang
An update from the bug: Seems the behavior is WAI because the execution order of dereference and function calls are not defined. deference of `foo.bar` may happen before or after (which is this case) the function call of `compute_value()` Spec states following about order of evaluation: > whe

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

2024-12-28 Thread Amnon
A nice thing about Go is that it is easy on the eye. Names are short, and easy to read. When you look at Go code, you are not faced with a wall of black text. The signal to noise ratio is high. Variable and function names general convey what they do, what they mean, rather than the types of thei

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

2024-12-28 Thread 'Axel Wagner' via golang-nuts
I don't see a good argument for the lack of a suffix "naturally" implying returning a slice. I don't think `ValuesSlice` would be less natural than `ValuesSeq`. At the end of the day, it's purely a question of what you think would be more frequently used. That should get the better name. `Values`

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

2024-12-28 Thread Kaiming Yang
Thanks for the confirmation, I created https://github.com/golang/go/issues/71054 for this. On Saturday, December 28, 2024 at 6:11:52 PM UTC-8 Ian Lance Taylor wrote: > On Sat, Dec 28, 2024 at 5:38 PM Kaiming Yang wrote: > > > > I'm trying to understand execution order of assignment statement, a

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

2024-12-28 Thread Mike Schinkel
> On Dec 28, 2024, at 2:41 PM, Amnon wrote: > > There are big advantages in maps.Keys and maps.Values returning iterators. > It allows us to iterate very big maps without having to allocate vast amounts > of memory. I definitely agree there is a big advantage to have functions in the standard

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

2024-12-28 Thread Ian Lance Taylor
On Sat, Dec 28, 2024 at 5:38 PM Kaiming Yang wrote: > > I'm trying to understand execution order of assignment statement, as spec > mentioned: > > > The assignment proceeds in two phases. First, the operands of index > > expressions and pointer indirections (including implicit pointer > > indir

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

2024-12-28 Thread Kaiming Yang
Hi everyone, I'm trying to understand execution order of assignment statement, as spec mentioned: > The assignment proceeds in two phases. First, the operands of index expressions and pointer indirections (including implicit pointer indirections in selectors) on the left and the expressions on

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

2024-12-28 Thread Amnon
There are big advantages in maps.Keys and maps.Values returning iterators. It allows us to iterate very big maps without having to allocate vast amounts of memory. When maps was moved from x/exp to the standard library, the Keys and Values methods were not added until 1.23.0 when iterators beca

[go-nuts] fun w/ benchmarking os.ReadDir versus os.File.ReadDir...

2024-12-28 Thread 'TheDiveO' via golang-nuts
Background#1: working on Linux system diagnosis tools, I often end up scraping the process and system filesystems quite extensively using os.ReadDir. On busy systems this might be a place to optimize things a little bit, or at least see if it does reap any benefits. Background#2: "*You can copy