[go-nuts] Re: Link: Getting specific about generics

2018-09-02 Thread wilk
On 02-09-2018, Tristan Colgate wrote: > --633c2e0574df037c > Content-Type: text/plain; charset="UTF-8" > Content-Transfer-Encoding: quoted-printable > > It's a great read, clarified stuff for me. An approach that embraces > interfaces feels preferable to me. +1 -- William --

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread haskell_mustard via golang-nuts
I prefer seeing the contract by example over having a combination of two dozens of interface names like Eq, Lesser, Adder, Muler, Convertible(x), Ranger, Lener, Caper, ... that have to be mentally mapped to their actual syntactic representation. This smells like taxonomy ("the lowest form of

Re: [go-nuts] Alternate syntax for Go2 generics and contracts

2018-09-02 Thread Tristan Colgate
Just read: https://emilymaier.net/words/getting-specific-about-generics/ I think I concur, keep specification of behaviour in interfaces if possible. Contracts overlap too much. If interfaces can do the job, all be it less elegantly, the extra verbosity seems worth it to avoid the feature

[go-nuts] Link: Getting specific about generics

2018-09-02 Thread 'Charlton Trezevant' via golang-nuts
Link: [Getting specific about generics, by Emily Maier](https://emilymaier.net/words/getting-specific-about-generics/) The interface-based alternative to contracts seems like such a natural fit- It’s simple, straightforward, and pragmatic. I value those aspects of Go’s philosophy and consider

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Tristan Colgate
It's a great read, clarified stuff for me. An approach that embraces interfaces feels preferable to me. On Sun, 2 Sep 2018, 09:09 'Charlton Trezevant' via golang-nuts, < golang-nuts@googlegroups.com> wrote: > Link: [Getting specific about generics, by Emily Maier]( >

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Sebastien Binet
Hi, On Sun, Sep 2, 2018, 12:55 haskell_mustard via golang-nuts < golang-nuts@googlegroups.com> wrote: > I prefer seeing the contract by example over having a combination of two > dozens of interface names like Eq, Lesser, Adder, Muler, Convertible(x), > Ranger, Lener, Caper, ... that have to be

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Wojciech S. Czarnecki
On Sun, 2 Sep 2018 07:23:55 -0700 (PDT) Manlio Perillo wrote: > What happens if you need to divide 7 pennies by 4? I do not know about pennies peculiarities, so I'll stay with ¤ ;) I divide 7µ¤ by 4 then It gives 17500µ¤. On customer account it still is 17500µ¤ but on his statement it

[go-nuts] [ANN] Mage 2.3.0 - Now with Go Modules Support

2018-09-02 Thread Nate Finch
Please check it out, and let me know if there are any problems with modules support. https://github.com/magefile/mage https://magefile.org *About Mage* I don't think I've posted here about Mage, so for those that haven't seen it, it's a Make replacement, sort of like Ruby's Rake, except

Re: [go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Paul Jolly
The v2 of the module needs a /v2 suffix on the module name in go.mod: https://github.com/dc0d/farsi/blob/a31316716e58115e7f7eb987d4e6476aa092cbab/go.mod#L1 You should then be set. On Sun, 2 Sep 2018 at 13:07, Kaveh Shahbazian wrote: > > Sure! > > This is the module that is being imported:

Re: [go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Paul Jolly
The main thing to remember is (from go help modules): > A module is a collection of related Go packages. > Modules are the unit of source code interchange and versioning. Your module import path is github.com/dc0d/farsi. Your module's v2 import path is github.com/dc0d/farsi/v2 etc. Any packages

[go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Kaveh Shahbazian
A required modules is added to my go.mod file with version v2.0.0 - which I expect to give me the v2.1.0. But after running go mod tidy the version inside go.mod file becomes v0.0.0-20180902075018-e96d84f0b065. The project is public on GitHub and has tags v1.0.0, v2.0.0 and v2.1.0. What am I

Re: [go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Paul Jolly
Please can you share details of the project, and/or repro steps? On Sun, 2 Sep 2018 at 12:58, Kaveh Shahbazian wrote: > > A required modules is added to my go.mod file with version v2.0.0 - which I > expect to give me the v2.1.0. > > But after running go mod tidy the version inside go.mod file

Re: [go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Kaveh Shahbazian
Sure! This is the module that is being imported: https://github.com/dc0d/farsi And the consumer app: package main import ( "fmt" "github.com/dc0d/farsi/calendar" ) func main() { fmt.Println(calendar.IranNow()) } And its go.mod file: module draft require github.com/dc0d/farsi

Re: [go-nuts] Go Module Vesion and Git Tags

2018-09-02 Thread Kaveh Shahbazian
Thanks! Apparently it works now. And I am a bit confused now since version is part of both the path and the version and it has to be imported like "github.com/dc0d/farsi/v2/calendar". But I guess understanding that is my homework - it just feels a bit odd! -- You received this message

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Manlio Perillo
What happens if you need to divide 7 pennies by 4? Using integers will result in 1, and this is probably not what you want, if this result needs to be used in further calculations. For financial applications you should use decimal floating-point numbers. Manlio On Thursday, August 30, 2018 at

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Jan Mercl
On Sun, Sep 2, 2018 at 4:24 PM Manlio Perillo wrote: > What happens if you need to divide 7 pennies by 4? > Using integers will result in 1, and this is probably not what you want, if this result needs to be used in further calculations. > > For financial applications you should use decimal

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Wojciech S. Czarnecki
On Sun, 2 Sep 2018 09:58:39 -0700 (PDT) Manlio Perillo wrote: > Then can I assume that all people using the Python decimal module are going > to jail? Not **all**. Only ones using it where either law or mutual agreements mandate fixed point calculations and mandate strict rounding rules (i.e.

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Wojciech S. Czarnecki
On Sun, 2 Sep 2018 20:11:40 +0200 "Wojciech S. Czarnecki" wrote: > error-prone s/error-prone/error-proof/ of course. Though this slip tells me that in fact either way (use ints/use libs) has its error-prone spots. Peace, -- Wojciech S. Czarnecki << ^oo^ >> OHIR-RIPE -- You received this

Re: [go-nuts] Re: Go2 Error Handling - Alternate Handler Concept

2018-09-02 Thread Liam Breck
Well, that was then, this is now... I'll just note that 10 of 30 feedback posts on the error handling draft feedback wiki have asked for named handlers. Can I add your link there? On Sun, Sep 2, 2018, 4:33 PM Vlad Didenko wrote: > Some time ago, after going through a very similar design

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread roger peppe
On Sun, 2 Sep 2018, 5:09 pm Bakul Shah, wrote: > People may find this excellent paper “Datatype-Generic Programming” by > Jeremy Gibbons useful in this discussion. It’s 72 pages long. > https://www.cs.ox.ac.uk/jeremy.gibbons/publications/dgp.pdf > > I want generics but I still don’t know if I

[go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread José Colón
Maybe this comparison is completely wrong or unfair, but calculations with Go untyped constants is much faster than the github.com/ericlagergren/decimal package. In the end, they both produce the same correct answer: 0 . func BenchmarkUntypedConstants(b *testing.B) { b.Log(0.3 - 0.1*3)

[go-nuts] Re: Working or Not

2018-09-02 Thread Dave Cheney
Hi John Unless the variables a1, a2, a3, b1, ... are defined in the same package as your showBoard function, ie var a1, a2, a3 int then Go will report that they are undefined. Unlike some other languages, Go does not implicitly define a variable on first occurance. All variables must be

[go-nuts] Re: Go2 Error Handling - Alternate Handler Concept

2018-09-02 Thread Vlad Didenko
Some time ago, after going through a very similar design (really, even had the catch clause in there), I have arrived at a more generalized version of it. That contemplation (still available at https://didenko.github.io/grab/grab_worth_it_0.1.1.html ) was very much unaccepted here. Well, I

Re: [go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread Dan Kortschak
This is not much different. I is the same as const c = 0.3 - 0.1*3 func BenchmarkUntypedConstants(b *testing.B) { b.Log(0.3 - 0.1*3) for i := 0; i < b.N; i++ { z = c } } On Sun, 2018-09-02 at 20:25 -0700, José Colón wrote: > Yeah, after posting I realized that the compiler

Re: [go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread Michael Jones
for money there is a natural limit to the number of digits that are useful, with certain exceptions . add to this the number of digits of fractional

[go-nuts] Working or Not

2018-09-02 Thread nvcnvn
Hi, Your blok of code will not work and throw error on COMPILE time. It will not RUN at all. (Do you have Javascript or PHP or similar background? I know some scripting language will allow you to put whatever the identifier in your code and check them on RUNTIME). -- You received this message

[go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread José Colón
This thread is very similar to what you can find if you do a Web search for how to handle financial calculations. From my perspective, and like all matters in programming, the answer is "it depends". It depends on your goals; do you want the highest performance, the highest precision, comply

[go-nuts] Working or Not

2018-09-02 Thread John
I am currently making a program with variables, but when I tried to run it says that the variables are not defined. So below are may code for using the variable: func showBoard() { fmt.Println(" 1 2 3") fmt.Println("a", a1, a2, a3) fmt.Println("b", b1, b2, b3)

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Michael Jones
Decimal arithmetic is good for money. Decimal fixed point is good for money. Decimal floating point may not be. Dividing 7 pennies by 4 is a good example. 7/4 = 1 3/4, so the 3/4 is accurately expressed in d fractional digits where base^d mod 4 == 0. For base-10 decimal arithmetic, this means two

Re: [go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread José Colón
Yeah, after posting I realized that the compiler would probably be smart enough to optimize that out, so I changed them to: func BenchmarkUntypedConstants(b *testing.B) { var z float64 for i := 0; i < b.N; i++ { z = 0.3 - 0.1*3 } b.Log(z) } func BenchmarkDecimalPackage(b *testing.B) { var z

Re: [go-nuts] Re: Go2 Error Handling - Alternate Handler Concept

2018-09-02 Thread Vlad Didenko
Absolutely, go ahead, thank you! I can add more "why" reasoning about "grab" design differences from "catch", but won't get to it until next weekend :( On Sunday, September 2, 2018 at 6:46:08 PM UTC-5, Liam wrote: > > Well, that was then, this is now... > > I'll just note that 10 of 30 feedback

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Bakul Shah
> On Sep 2, 2018, at 3:19 PM, roger peppe wrote: > > > > On Sun, 2 Sep 2018, 5:09 pm Bakul Shah, > wrote: > People may find this excellent paper “Datatype-Generic Programming” by Jeremy > Gibbons useful in this discussion. It’s 72 pages long. >

Re: [go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread Wojciech S. Czarnecki
On Sun, 2 Sep 2018 15:54:08 -0700 (PDT) José Colón wrote: > if a package that could provide similar ease of use in performing > infinite precision calculations would be a good idea https://github.com/ericlagergren/decimal It does not fit into stdlibs imo. -- Wojciech S. Czarnecki << ^oo^

Re: [go-nuts] Re: Are Go floats smarter?

2018-09-02 Thread Dan Kortschak
This is not a benchmark of the untyped constant expression evaluation. The expression in the loop is performed once and thrown away *at compile time*. The benchmark here is really: func BenchmarkUntypedConstants(b *testing.B) { b.Log(0.3 - 0.1*3) for i := 0; i < b.N; i++ {     } } On

Re: [go-nuts] Re: Go2 Error Handling - Alternate Handler Concept

2018-09-02 Thread Liam Breck
Posted your link to the feedback wiki, and to my design-revision draft, which will land on the issue tracker this week. https://golang.org/wiki/Go2ErrorHandlingFeedback https://gist.github.com/networkimprov/c6cb3e2dff18d31840f2ef22e79d4a1e On Sun, Sep 2, 2018, 4:49 PM Vlad Didenko wrote: >

Re: [go-nuts] Link: Getting specific about generics

2018-09-02 Thread Bakul Shah
People may find this excellent paper “Datatype-Generic Programming” by Jeremy Gibbons useful in this discussion. It’s 72 pages long. https://www.cs.ox.ac.uk/jeremy.gibbons/publications/dgp.pdf I want generics but I still don’t know if I like this go2 generics proposal. At least as an exercise

Re: [go-nuts] Alternate syntax for Go2 generics and contracts

2018-09-02 Thread Scott Cotton
Hi all, I just found out that there is a wiki for this kind of discussion, looks to me like a better venue, more organised, more interest, and just recently proposed on golang.org. Scott On Sunday, 2 September 2018 10:09:43 UTC+2,

Re: [go-nuts] Are Go floats smarter?

2018-09-02 Thread Manlio Perillo
On Sunday, September 2, 2018 at 5:16:16 PM UTC+2, ohir wrote: > > On Sun, 2 Sep 2018 07:23:55 -0700 (PDT) > Manlio Perillo > wrote: > > > What happens if you need to divide 7 pennies by 4? > > I do not know about pennies peculiarities, so I'll stay with ¤ ;) > > I divide 7µ¤ by 4 then It