Re: [go-nuts] [Generics] Constraints package name

2020-08-18 Thread Frederik Zipp
ma...@acln.ro schrieb am Montag, 27. Juli 2020 um 08:34:04 UTC+2:

> The entire notion of the constraints package feels a little suspicious to 
> me. What if the comparable and ordered constraints were pre-declared in the 
> universe block, and the numeric constraint were named math.Numeric?
>

In this case 'Ordered' might belong in the "sort" package: sort.Ordered, 
and most other constraints in the 'math' package: math.Numeric, 
math.Complex, math.Unsigned. Or maybe 'Complex' belongs in "math/cmplx" as 
cmplx.Number.

But from a dependency hygiene perspective it is probably better to have the 
most common constraints in a dedicated package rather than distribute them 
over existing packages. I suppose we would not want "math" to import "sort" 
in order to implement Min and Max.

>

-- 
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/7a189321-ff08-4ca7-a7fd-fe00fc9ce613n%40googlegroups.com.


Re: [go-nuts] [Generics] Constraints package name

2020-07-27 Thread Andrei Tudor Călin
The entire notion of the constraints package feels a little suspicious to
me. What if the comparable and ordered constraints were pre-declared in the
universe block, and the numeric constraint were named math.Numeric? What
other universal (or close to universal) constraints would belong in this
entirely agnostic "constraints" package?

On Sun, Jul 26, 2020 at 10:30 AM  wrote:

> The package name "constraints" is quite a mouthful to read:
>
>   func Min[Elem constraints.Ordered](s []Elem) Elem {}
>
> Did you consider other package names like "is"?
>
>   func Min[Elem is.Ordered](s []Elem) Elem {}
>
> is.Ordered
> is.Integer
> is.Signed
> is.Unsigned
>
> --
> 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/fb694112-7d2f-4db0-a0fd-86fd05459ae3o%40googlegroups.com
> 
> .
>


-- 
Andrei Călin

-- 
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/CANnvmN6bccEB7Jw-6ufAeZaGw-LqRGUDmu9_0HBoZg4_tgMurw%40mail.gmail.com.


Re: [go-nuts] [Generics] Constraints package name

2020-07-26 Thread 'Axel Wagner' via golang-nuts
On Sun, Jul 26, 2020 at 1:05 PM  wrote:

> Also, the name "is" doesn't follow the usual naming style of Go packages.
>>
>
> I'm not sure if there is a Go standard library package naming style other
> than "relatively short name".
>

"relatively short name" is less consistently applied than "be descriptive
of what's in there". Without the context of generics, what would you think
is in "is"? What's in "constraints"? What's in "quotedprintable"?


>
>
>> I tend to find such package names risky because they don't really say
>> what they contain.
>>
>
> The package doc comment can say that it contains constraints.
>
>
>> This means they become attractors of all kinds of different functionality
>> over time, where most of that functionality isn't belonging in there but in
>> separate packages. It is like declaring a package such as "util", "misc",
>> or "aux".
>>
>
> I'd trust the Go maintainers that they can resist to clutter it with
> unrelated things.
>
> --
> 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/f623ffc6-757c-44a7-bbcf-0e8b59efa714o%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/CAEkBMfH_q%2Bzqszfn%3D-8CjrTGJQ%2Bx1P%2BMjnDtitW4RObmvw2mjw%40mail.gmail.com.


Re: [go-nuts] [Generics] Constraints package name

2020-07-26 Thread Robert Engels
I like ‘is’. Very readable and Go-like. 

> On Jul 26, 2020, at 6:05 AM, frederik.z...@gmail.com wrote:
> 
> 
>> On Sunday, July 26, 2020 at 12:46:38 PM UTC+2, Jesper Louis Andersen wrote:
>> 
>> You can always solve that with a rename:
>> 
>> import (
>>   is "constraints"
>> )
>> 
>> but you run the risk of users not knowing what the "is" package is.
> 
> Of course, but like you said, "is" would be unfamiliar to most other users. 
> People usually use the default package name and that's what we will have to 
> read the most.
>  
>> Also, the name "is" doesn't follow the usual naming style of Go packages.
> 
> I'm not sure if there is a Go standard library package naming style other 
> than "relatively short name". 
>  
>> I tend to find such package names risky because they don't really say what 
>> they contain. 
> 
> The package doc comment can say that it contains constraints.
>  
>> This means they become attractors of all kinds of different functionality 
>> over time, where most of that functionality isn't belonging in there but in 
>> separate packages. It is like declaring a package such as "util", "misc", or 
>> "aux".
> 
> I'd trust the Go maintainers that they can resist to clutter it with 
> unrelated things.
> -- 
> 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/f623ffc6-757c-44a7-bbcf-0e8b59efa714o%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/D9F02A8E-8BD6-425F-8646-38FCE30E9044%40ix.netcom.com.


Re: [go-nuts] [Generics] Constraints package name

2020-07-26 Thread frederik . zipp
On Sunday, July 26, 2020 at 12:46:38 PM UTC+2, Jesper Louis Andersen wrote:
>
>
> You can always solve that with a rename:
>
> import (
>   is "constraints"
> )
>
> but you run the risk of users not knowing what the "is" package is.
>

Of course, but like you said, "is" would be unfamiliar to most other users. 
People usually use the default package name and that's what we will have to 
read the most.
 

> Also, the name "is" doesn't follow the usual naming style of Go packages. 
>

I'm not sure if there is a Go standard library package naming style other 
than "relatively short name". 

>  

> I tend to find such package names risky because they don't really say what 
> they contain. 
>

The package doc comment can say that it contains constraints.
 

> This means they become attractors of all kinds of different functionality 
> over time, where most of that functionality isn't belonging in there but in 
> separate packages. It is like declaring a package such as "util", "misc", 
> or "aux".
>

I'd trust the Go maintainers that they can resist to clutter it with 
unrelated things.

-- 
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/f623ffc6-757c-44a7-bbcf-0e8b59efa714o%40googlegroups.com.


Re: [go-nuts] [Generics] Constraints package name

2020-07-26 Thread Jesper Louis Andersen
On Sun, Jul 26, 2020 at 9:30 AM  wrote:

> The package name "constraints" is quite a mouthful to read:
>
>   func Min[Elem constraints.Ordered](s []Elem) Elem {}
>
> Did you consider other package names like "is"?
>
>   func Min[Elem is.Ordered](s []Elem) Elem {}
>
>
You can always solve that with a rename:

import (
  is "constraints"
)

but you run the risk of users not knowing what the "is" package is. Also,
the name "is" doesn't follow the usual naming style of Go packages. I tend
to find such package names risky because they don't really say what they
contain. This means they become attractors of all kinds of different
functionality over time, where most of that functionality isn't belonging
in there but in separate packages. It is like declaring a package such as
"util", "misc", or "aux".

-- 
J.

-- 
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/CAGrdgiW48GA1-GU%3DiPBcYsm6W507YXRNbBsLROkQa1HBFbPzxA%40mail.gmail.com.


[go-nuts] [Generics] Constraints package name

2020-07-26 Thread frederik . zipp
The package name "constraints" is quite a mouthful to read:

  func Min[Elem constraints.Ordered](s []Elem) Elem {}

Did you consider other package names like "is"?

  func Min[Elem is.Ordered](s []Elem) Elem {}

is.Ordered
is.Integer
is.Signed
is.Unsigned

-- 
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/fb694112-7d2f-4db0-a0fd-86fd05459ae3o%40googlegroups.com.