[go-nuts] Re: Generics - please provide real life problems

2020-12-24 Thread Viktor Kojouharov
> I have been arguing passionately against adding generics to Go because I truly believe that it is going against the simplicity of Go and the philosophy behind the design of Go. How about providing some evidence to back such an assertion, in the same spirit of asking others to provide justi

[go-nuts] Re: [error handling] RFC 'else'

2020-12-03 Thread Viktor Kojouharov
Also a lot of the proposals listed in the `Wrapping` section of https://seankhliao.com/blog/12020-11-23-go-error-handling-proposals/ On Wednesday, December 2, 2020 at 9:30:24 PM UTC+1 seank...@gmail.com wrote: > see also > > https://github.com/golang/go/issues/41908 > https://github.com/golang/go

[go-nuts] Limiting the max heap size of a Go process

2020-11-25 Thread Viktor Kojouharov
Hi, Is there a way to set a hard limit on the max heap size a process is allowed to consume, from within it? It's almost never a problem for a process to consume as much memory as is available, however, I've ran into real-life cases in a k8s environment, where a pod with a Go process will get

Re: [go-nuts] Any embedded scripting language for Go

2020-10-24 Thread Viktor Kojouharov
I've had success with using github.com/dop251/goja as a javascript interpreter On Thursday, October 22, 2020 at 7:00:34 PM UTC+2 Jan Mercl wrote: > In case you're on Linux and you like Tcl: > https://godoc.org/modernc.org/tcl#example-Interp-NewCommand > > On Wed, Oct 21, 2020, 07:32 Aravindhan K

[go-nuts] Re: Question on the generics proposal and arrays

2020-10-06 Thread Viktor Kojouharov
This would require something similar to rust's const generics. IIRC, that's not on the table with the initial draft On Tuesday, October 6, 2020 at 3:31:46 PM UTC+2 markus@gain.pro wrote: > It appears to me the current proposal does not allow you to write a > function that sorts an array of

Re: [go-nuts] Re: Proper way of mocking interfaces in unit tests - the golang way

2020-10-05 Thread Viktor Kojouharov
I don't find any difference between calling t.Errorf and assert.Something with a provided message. Both will populate the test log, with the later giving you more details exactly where things differ from the expectation. On Monday, October 5, 2020 at 3:03:48 PM UTC+2 Bryan C. Mills wrote: > I t

Re: [go-nuts] [generics] Allowing interfaces with type constraints

2020-09-10 Thread Viktor Kojouharov
't use interfaces with type lists. > I'm not sure exactly what you're trying to do in your example, but ISTM > that it could be somewhat simpler. You > only need one type parameter: https://go2goplay.golang.org/p/4E0ZnVxJwL9 > > > On Thu, 10 Sep 2020 at 15:54, Vik

[go-nuts] [generics] Allowing interfaces with type constraints

2020-09-10 Thread Viktor Kojouharov
Would using parametric interfaces be allowed in type assertion expressions / type switches? The current behavior in the go2go playground is for the compiler to return the error: "interface contains type constraints (T)" (https://go2goplay.golang.org/p/O1Un2Vm9Dh0) I was under the impression th

[go-nuts] Re: [generics] opposed

2020-08-29 Thread Viktor Kojouharov
"Doesn't really need to be there" is highly subjective On Friday, August 28, 2020 at 7:10:45 PM UTC+2 Ashton Cummings wrote: > My first impression of Go not having generics was negative. I came from > C#, Java, typescript, C++, and a few other languages that had generics. So, > learning Go and

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-22 Thread Viktor Kojouharov
On Saturday, August 22, 2020 at 12:49:21 AM UTC+2 rog wrote: > On Fri, 21 Aug 2020 at 23:12, jimmy frasche wrote: > >> I don't want a generic min unless it looks like this: >> >> func Min[T constraints.Ordered](a, b T) T { >> switch T { >> case float32: >> return T(math.Min(float32(a),

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-21 Thread Viktor Kojouharov
I like all points in the draft change. My 2 cents around the any alias would be that it shouldn't be a problem. I don't think people are suddently going to start overusing it, since using vaues of type `interface{}` is extremely tedious in Go, and that won't magically change if the type is shor

[go-nuts] Re: [proposal] Make go compiler work with different syntax versions in same project to support adaptivity

2020-08-09 Thread Viktor Kojouharov
What problems would you expect generics to bring in terms of syntax, where such flexibility would be a solution? On Sunday, August 9, 2020 at 4:51:40 AM UTC+2 ivaniva...@gmail.com wrote: > Add support of optional syntax_version to file beginning, allow compiler > to tokenize/compile file by the

Re: [go-nuts] Re: Generics: after type lists

2020-08-09 Thread Viktor Kojouharov
There's a big difference between creating arbitrary operators like c++, and just allowing the predefined set of operators to be implemented for custom types only. The later, combined with the overall aversion of the Go community towards operator overloading as a whole, will probably lead to ver

Re: [go-nuts] Re: Generics and parentheses

2020-07-18 Thread Viktor Kojouharov
None of my laptops have guillamets on them, so that's pretty much dead on arrival On Friday, July 17, 2020 at 5:56:32 PM UTC+2, Jon Conradt wrote: > > In the spirit of “show me, don’t tell me” and experience reports. How hard > would it be to release a beta which supports both [] and guillamets?

Re: [go-nuts] [generics] type list should not pass newtypes

2020-06-28 Thread Viktor Kojouharov
These type lists that are used in generic interfaces are not sum types. they are there to allow restrictions on operators, since only base types have operators in go (and types which use them as underlying types inherit). You are thinking of sum types, which go does not have. On Sunday, June 28

[go-nuts] Re: [generics] I think it's better have higher perfomance than lower compiling time

2020-06-27 Thread Viktor Kojouharov
I seem to recall that the compilation time of C (and C++) programs is directly proportional to the number of includes your program has. I'm sure that monomorphisation in C++ exacts some kind of cost to the compilation time, but perhaps it's not as much as people seem to think. On Friday, June

Re: [go-nuts] Re: Preventing SIGBUS errors when memmove-ing an unsafe.Pointer to multiple destinations

2020-06-10 Thread Viktor Kojouharov
20 at 9:41:21 PM UTC+3, Ian Lance Taylor wrote: > > On Mon, Jun 8, 2020 at 10:44 AM Viktor Kojouharov > wrote: > > > > The full code can be seen in this diff: > > > > > https://github.com/urandom/go/commit/d10ccdd907dac690bfcb31df1115ce1508775458 > &

Re: [go-nuts] Re: Preventing SIGBUS errors when memmove-ing an unsafe.Pointer to multiple destinations

2020-06-08 Thread Viktor Kojouharov
e runtime to call typedmemmove is very unsupported. > > On Sunday, June 7, 2020 at 10:02:21 AM UTC-7, Michael Jones wrote: >> >> Thank you. I now officially know that I don’t understand. Sorry. >> >> On Sun, Jun 7, 2020 at 7:54 AM Viktor Kojouharov >> wrote: >&

Re: [go-nuts] Re: Preventing SIGBUS errors when memmove-ing an unsafe.Pointer to multiple destinations

2020-06-07 Thread Viktor Kojouharov
y to fail, and > even when it does not, it is quite likely to be meaningless. (random data > from some other use). > > If I misunderstood, please forgive me. > > On Sun, Jun 7, 2020 at 6:15 AM Viktor Kojouharov > wrote: > >> p.s. should such questions be posted in gol

[go-nuts] Re: Preventing SIGBUS errors when memmove-ing an unsafe.Pointer to multiple destinations

2020-06-07 Thread Viktor Kojouharov
p.s. should such questions be posted in golang-dev, since it deals with runtime internals? -- 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..

[go-nuts] Preventing SIGBUS errors when memmove-ing an unsafe.Pointer to multiple destinations

2020-06-07 Thread Viktor Kojouharov
Hi, I'm playing around with the runtime, copying some data behind unsafe.Pointer to a destination whenever a function is invoked. I'm currently doing it with the 'typedmemmove' function from within the runtime. That works for certain code, but panics with "unexpected fault address" - going thr

Re: [go-nuts] if/switch statements as expressions

2018-12-22 Thread Viktor Kojouharov
gt; Not to say that this means Go should support it necessarily. > > On Wed, Dec 19, 2018 at 12:16 PM Jan Mercl <0xj...@gmail.com > > wrote: > >> On Wed, Dec 19, 2018 at 9:09 PM Viktor Kojouharov > > wrote: >> >> >> > I'm interested t

[go-nuts] if/switch statements as expressions

2018-12-19 Thread Viktor Kojouharov
Hello, I've tried and failed at finding any previous discussion on this topic, so do point me to one if it exists. I'm interested to know whether it was considered (I can't imagine that it wasn't) for if and switch statements to be expressions instead, and if so, why were they ultimately left

[go-nuts] Re: Generics and readability

2017-08-25 Thread Viktor Kojouharov
func Foo(in interface{}) { val, ok := in.(someTypeOrInterface) if !ok { // TODO HANDLE ERROR } ... } Wow, this is so much more readable /s On Thursday, August 24, 2017 at 6:14:58 PM UTC+3, JuciÊ Andrade wrote: > > A lot of people like Go becau

[go-nuts] Re: why context never been made as keyword rather than api ?

2017-04-15 Thread Viktor Kojouharov
Adding a new keyword would break backwards compatibility On Saturday, April 15, 2017 at 10:21:32 AM UTC+3, mhh...@gmail.com wrote: > > hi, > > > The question is in the title, > > the rationale, all the changes needed to apply on the source code to a add > context as a parameter. > > We may imagin

[go-nuts] Type declarations and the underlying type's methods

2017-01-19 Thread Viktor Kojouharov
Hello, Considering how easy it is to create new types based on underlying types, how come the newly created ones do not delegate method calls to their underlying types? Consider the following example: https://play.golang.org/p/Zs7Ve8ECk2 In the example, calling `b.num()` directly will not wor

[go-nuts] Re: Unmarshal into struct where root struct field is a dynamic field

2016-12-07 Thread Viktor Kojouharov
It seems to me that the response is always a map[string]SomeStruct{}. Nothing wrong with that. On Wednesday, December 7, 2016 at 12:02:57 AM UTC+2, vanmuld...@gmail.com wrote: > > An example JSON response : > > Query : /id/123456 > > Response : > > > {"123456":{"id":123456,"name":"qsdsdqsdqs

[go-nuts] Re: Deleting the /r/golang subreddit

2016-11-24 Thread Viktor Kojouharov
Or, you should just leave, stop saying /r/golang is an official go channel, and leave it to its fate. I see no reason to delete it whatsoever. On Friday, November 25, 2016 at 1:53:32 AM UTC+2, bradfitz wrote: > > In light of the CEO of Reddit admitting to editing user comments (see > dozen news

[go-nuts] Re: Implementation status of database/sql changes

2016-11-10 Thread Viktor Kojouharov
nd replace isn't going to cut it :) On Wednesday, November 9, 2016 at 5:21:04 PM UTC+2, mattn wrote: > > > On Wednesday, November 9, 2016 at 6:00:45 PM UTC+9, Viktor Kojouharov > wrote: >> >> Why doesn't the change standardize the placeholder format? The driver c

[go-nuts] Re: Implementation status of database/sql changes

2016-11-09 Thread Viktor Kojouharov
Why doesn't the change standardize the placeholder format? The driver can easily convert from a standard "[SOME-RUNE]PLACEHOLDER" to whatever the actual database supports. Having a non-standard format just introduces confusion and difficulty for the users of the api. On Tuesday, November 8, 201

[go-nuts] Re: building rss aggregator (thousands of goroutines sleeps at the same time)

2016-11-05 Thread Viktor Kojouharov
It's quite efficient to have a lot of goroutines. That's how I update the feeds in my aggregator. Though your network interface might not like it if you try to initiate thousands of connections at the same time. On Friday, November 4, 2016 at 11:14:24 PM UTC+2, Marwan abdel moneim wrote: > > i a

Re: [go-nuts] interface as valid method receivers ?

2016-10-19 Thread Viktor Kojouharov
On Wednesday, October 19, 2016 at 10:16:50 PM UTC+3, Jan Mercl wrote: > > On Wed, Oct 19, 2016 at 8:58 PM Viktor Kojouharov > wrote: > > > Not really, as this is all hypothetical, it might be implemented in a > way so that any type that wants to satisfy an interface with d

Re: [go-nuts] interface as valid method receivers ?

2016-10-19 Thread Viktor Kojouharov
On Wednesday, October 19, 2016 at 6:52:30 PM UTC+3, Jan Mercl wrote: > > > On Wed, Oct 19, 2016 at 5:40 PM Viktor Kojouharov > wrote: > > > That's just a default method implementation. There's nothing inherently > confusing about what gets called. If a co

Re: [go-nuts] interface as valid method receivers ?

2016-10-19 Thread Viktor Kojouharov
On Tuesday, October 18, 2016 at 9:27:36 PM UTC+3, Konstantin Khomoutov wrote: > > On Tue, 18 Oct 2016 11:11:59 -0700 (PDT) > parais...@gmail.com wrote: > > > Obviously in Go this is a compile time error : > > > > type Foo interface {} > > > > > > func (f Foo) DoSomething(){} > > > I w

[go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread Viktor Kojouharov
A future is just a special case of an observable. Honestly I'd prefer if an observable was built-in the language like a channel. You could use it like a channel in selects and the like, but with the possibility of receiver observables to be closable. When the list receiver observable is closed

[go-nuts] Re: unmarshaling json to byte type

2016-09-15 Thread Viktor Kojouharov
It would probably be pretty easy if you implement the json.Unmarshaler interface on the byte type: https://play.golang.org/p/hzGalLA2yA On Wednesday, September 14, 2016 at 6:06:41 PM UTC+3, Luke wrote: > > Hi, > > i have something like: https://play.golang.org/p/j5WhDMUTI- > > type A struct { >

Re: [go-nuts] Simple test runner

2016-08-12 Thread Viktor Kojouharov
go test ./... | fgrep -v '[no test files]' that should be perfectly sufficient to you On Friday, August 12, 2016 at 10:28:08 AM UTC+3, Simon Ritchie wrote: > > > go test ./... > > Sorry, I should have said, I already tried that. The problem is, if you > have any directories that don't contain a

Re: [go-nuts] Re: How to make the first character in a string lowercase?

2016-07-15 Thread Viktor Kojouharov
.@googlegroups.com [mailto: > golan...@googlegroups.com ] *On Behalf Of *Viktor Kojouharov > *Sent:* 2016 July 14, Thu 03:57 > *To:* golang-nuts > *Subject:* [go-nuts] Re: How to make the first character in a string > lowercase? > > > > https://play.golang.org/p/miLAFSDjrS &g

[go-nuts] Re: How to make the first character in a string lowercase?

2016-07-14 Thread Viktor Kojouharov
https://play.golang.org/p/miLAFSDjrS For unicode On Thursday, July 14, 2016 at 7:26:13 AM UTC+3, Tamás Gulácsi wrote: > > But this works only for ASCII input! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and st

Re: [go-nuts] log.Logger, Why is this not an interface?

2016-07-08 Thread Viktor Kojouharov
It would have been quite useful for the stdlib to define a logger interface, so that third party loggers would implement it and allow for easier switching between them On Friday, July 8, 2016 at 11:34:01 AM UTC+3, Ian Davis wrote: > > On Fri, Jul 8, 2016, at 05:29 AM, zger...@pivotal.io wrote:

[go-nuts] Re: Idiomatic way to signal error using websockets

2016-07-07 Thread Viktor Kojouharov
You have to define your protocol that goes through the websocket. For example, the json-rpc protocol has a special error field when an error occurs. On Thursday, July 7, 2016 at 10:45:04 AM UTC+3, Johann Höchtl wrote: > > I am using the gorilla websocket implementation. I am also new to > webso

[go-nuts] Re: Relaxing rules on slice comparison: would it make sense?

2016-06-29 Thread Viktor Kojouharov
This would probably introduce unnecessary confusion. People are used to the equality operator comparing values in go, as opposed to references. It's much better if the slices finally support the equality operator, even though the comparison speed will depend on the number of items in the slices

Re: [go-nuts] Re: A proposal for generic in go

2016-06-22 Thread Viktor Kojouharov
On Tuesday, June 21, 2016 at 9:56:01 PM UTC+3, Axel Wagner wrote: > > The issue is, that a "KeyValuePair" (no matter if you implemented it > via generics or like you mention via interfaces) is a fundamentally useless > type and generics encourage people to add useless types. A "KeyValuePair V>"

[go-nuts] Re: A proposal for generic in go

2016-06-22 Thread Viktor Kojouharov
https://golang.org/pkg/math/ and https://golang.org/pkg/container/ are just two stdlib packages that would greatly benefit from some kind of generics. I'm pretty sure there are more packages in the stdlib that would be greatly improved. And that's just the standard library. On Tuesday, June 21

Re: [go-nuts] Better sum types for go

2016-06-13 Thread Viktor Kojouharov
I'm also for such types. There was also an interesting discussion about them here: https://www.reddit.com/r/golang/comments/46bd5h/ama_we_are_the_go_contributors_ask_us_anything/d03t6ji?context=3 On Monday, June 13, 2016 at 4:21:13 AM UTC+3, Michael Jones wrote: > > The position of the language d

[go-nuts] Re: polymorphism (for Go 2.0), new fast playground is live

2016-06-13 Thread Viktor Kojouharov
Polymorphism is a far cry from a bad idea. On Monday, June 13, 2016 at 12:05:34 PM UTC+3, Peter Kleiweg wrote: > > Op zaterdag 11 juni 2016 22:31:06 UTC+2 schreef charr...@gmail.com: > > What do you need to be added to the Go language? >> > > A garbage collector for bad ideas. > -- You received