Hi,

Question about the receiver of a func.

It can be defined as star/no star, and consumed as star/nostar.

The understanding i have so far is,
it let the developer define the memory model he d like to use.

It leads to cases such as 
- define start/nostar on a type
- consume a stared type as a value
- consume a value type as a pointer

Which is quiet confusing for beginners, and me.

While i understand that someone would like to declare
a type is consumed by value, I do not understand the last two cases.
when why they might happen.

Can you explain their value added ?

Thinking further more,

Not speaking about dereferencing a pointer,
but initialization of a type in a way that is undesired to the provider.

The way a type is consumed by value or reference,
is an act of design rules (i add a property on the type that make sure it 
is never copied/referenced)
or an act of consumption, 
the designer did not enforce any rule on the type, i might initialize it as 
star/nostar at convenience.

The fact it is let possible today 
- to not enforce the way a type is manipulated, 
   leads to confusion and error (famous one is https://godoc.org/sync)
- to define at both declaration / usage the star/nostar,
   is confusing, again

so yeah, wondering quiet a lot about that,
and given the fact i do not understand few use cases,
i think this could be better handled.

For example, 

if a new keyword appear to ensure a type is 
consumed by value, that might be helpful to provide
a function to make sure that type won t exceed the stack size
and escape to the heap.
that keyword would help api designer to avoid consumption problems.
nop ?

If a new keyword would appear to ensure a type is initialized by reference,
might help to detect value copy and warn/error when that case is met.
That would helped consumers to avoid problems.
nop ?

If the receiver type was not able to be star/nostar,
that d probably help to get ride of confusion,
nop ?

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to