[go-nuts] Go predicts the end of the universe

2017-11-10 Thread Hal
Go predicts the end of the time, i.e. the end of the universe 😂

https://play.golang.org/p/THHvbdo_IS

package main


import (
 "fmt"
 "math"
 "time"
)


func main() {
 endOfTheTime := time.Unix(math.MaxInt64,81394542089).UTC()
 fmt.Println(endOfTheTime.String())
}

Hal

-- 
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.


[go-nuts] [generics] Why is constraint optional?

2020-06-17 Thread Hal
"If a constraint is specified for any type parameter, every type parameter 
must have a constraint. If some type parameters need a constraint and some 
do not, those that do not should have a constraint of interface{}."

"interface{}" equals to "Any Type" in the context of generics. So it seems 
that we don't have to support optional constraint, for the following 
reasons:

* the syntax defining generic function is verbose on purpose (type 
keyword), not only for clarification, but also a remind of the cost and 
complexity behind generics, so it is not a bad thing to be explicit about 
the the default constraint interface{}
* normal parameter list does not support default type, to be consistent, 
type parameter list should not either
* multiple generic types without constraints can be written as "type T1, 
T2, T3 interface{}", not too much boilerplate anyway

-- 
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/a1315d89-febe-4bac-9246-b463dc097af1o%40googlegroups.com.


[go-nuts] Re: [generics] Why is constraint optional?

2020-06-18 Thread Hal
Yes, an alternative syntax I can come up with (underscore as a placeholder):

func Foo(type T1 _, T2 Bar)

On Thursday, 18 June 2020 03:28:39 UTC+1, Andrey Tcherepanov wrote:
>
> Wouldn't it be nice to have just 
>
> func Foo(type T1, type T2 Bar)
>
> (type as keyword splitting it into 2 type declarations)
>
> On Wednesday, June 17, 2020 at 5:50:47 AM UTC-6, Brian Candler wrote:
>>
>> Consider a generic where you want T1 unconstrained but T2 constrained.  
>> If you write
>>
>> func Foo(type T1, T2 Bar)
>>
>> then Bar constrains both.  Hence the need for
>>
>> func Foo(type T1 interface{}, T2 Bar)
>>
>

-- 
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/ad8aee78-8e12-4dcf-8067-60062e782102o%40googlegroups.com.