On Tuesday, 19 July 2022 at 17:14:19 UTC+1 agra...@googlemail.com wrote:

> hello,
> i am new to everything is new in programming-heaven. old-c-guy. and i 
> thought it`s time to learn something most-modern ..
>

Welcome!

Go is a great language for old-c-guys (and girls). Go was,  in fact mainly 
invented by them...
You will have fun here...


 

>
>
> time.NewTicker( time.Second )           ok
> time.NewTicker( 5 * time.Second )     ok
> var n int = 5  
> time.NewTicker( n * time.Second ) error : int * duration 
> time.NewTicker( time.Duration(n) * time.Second )      ok : duration * 
> duration [s^2] square-seconds ?
>

Yes, this bothers the inner Physicist in me too.
But you can only multiply numbers if they are of the same type...
 

>
>
> tick := time.NewTicker( time.Duration( math.rand.Intn(10) ) * time.Second 
> ) 
>
> go func() { for { select {
>  case <-done : return 
> ,case tc := <-tick.C : **** tick **** 
> }}}()
>
> this strategy gets the tick if it has already happend in past and this 
> go-routine is active
> if it is suspended will it be notified as soon in either done or tick 
> something is to read ?
>

Yes
 

>
>
> when i (later) write own code / interfaces / struct where inside is like 
> in ticker the .C a channel, can i define something like an operator, so 
> that the outer object acts like a channel
>

You want user defined operations - so you can define the implementation of 
the <- operator on your type.
 But we don't have this in Go.
You need to use methods. (Less syntactic sugar, but more clarity).



>
> type S struct {
>  C chan time 
>  ..
> }
> s := S{C:make(chan time),..}
> s<- 
> <-s 
>

-- 
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/831b14b4-6a34-4ef2-85ef-858c74c1cc27n%40googlegroups.com.

Reply via email to