Re: [go-nuts] [generics] Awkwardness interfacing between primitives and structs

2020-06-17 Thread Robert Engels
This is not how it is typically done in Java. You create an immutable List that 
is backed by the array. No copy required. 

You will also implement RandonAccess to distinguish from linked lists. 

Lastly, it doesn’t need to be immutable, and lots of structures like ArrayList 
are mutable and backed by arrays and have nearly identical performance and 
memory characteristics as an actual array (except for very small arrays). 

> On Jun 17, 2020, at 11:35 AM, Hunter Herman  wrote:
> 
> Suppose I want to write a function over any list like container (histogram, 
> reverse...) how can I? Java requires special code if you want to process 
> arrays — thus most code takes Lists, and accepting an array (eg a vararg) is 
> likely to lead to a copy into a list at some point. Is go fated to inherit 
> this sort of awkwardness? 
> 
> -- 
> 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/msgid/golang-nuts/5048-d7fa-4089-ab1a-ce0adbd80c20o%40googlegroups.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/msgid/golang-nuts/B3D9007F-058E-4BF0-A7C8-753417BC4415%40ix.netcom.com.


[go-nuts] [generics] Awkwardness interfacing between primitives and structs

2020-06-17 Thread Hunter Herman
Suppose I want to write a function over any list like container (histogram, 
reverse...) how can I? Java requires special code if you want to process arrays 
— thus most code takes Lists, and accepting an array (eg a vararg) is likely to 
lead to a copy into a list at some point. Is go fated to inherit this sort of 
awkwardness? 

-- 
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/msgid/golang-nuts/5048-d7fa-4089-ab1a-ce0adbd80c20o%40googlegroups.com.