Re: [go-nuts] Re: Why not tuples?

2022-12-07 Thread 'Thomas Bushnell BSG' via golang-nuts
Use the json package to parse the incoming data. Transform it as you please. Use the json package to format the output. I'm not sure I see the problem. On Sat, Dec 3, 2022, 10:47 PM Diogo Baeder wrote: > Hi there, sorry for weighting in so late in the game, but I just started > again to learn G

Re: [go-nuts] Re: Why not tuples?

2022-12-07 Thread Diogo Baeder
Thanks Brian, that's actually similar to what I'm already doing. Cheers! On Wednesday, December 7, 2022 at 8:16:53 AM UTC-3 Brian Candler wrote: > On Tuesday, 6 December 2022 at 22:27:38 UTC dple...@google.com wrote: > >> It'd be great if, for example, you could tag an entire type like: >> >> ty

Re: [go-nuts] Re: Why not tuples?

2022-12-07 Thread Brian Candler
On Tuesday, 6 December 2022 at 22:27:38 UTC dple...@google.com wrote: > It'd be great if, for example, you could tag an entire type like: > > type Row struct { `json:tuple` > date int64 > score float64 > city string > } > > so that > > var v []Row > json.Unmarshal(data, &v) > > would automa

Re: [go-nuts] Re: Why not tuples?

2022-12-06 Thread Diogo Baeder
That was perfectly put, Daniel, thanks! :-) And, indeed, what I've been doing is to unmarshal as a "[][]any" and then coercing to the right types. I also agree tuples have a place in the world. They're quite common when dealing with tabular data - for example, to reduce the amount of repetition

Re: [go-nuts] Re: Why not tuples?

2022-12-06 Thread 'Daniel Lepage' via golang-nuts
On Sat, Dec 3, 2022 at 11:34 PM burak serdar wrote: > > > On Sat, Dec 3, 2022 at 8:47 PM Diogo Baeder wrote: > >> Now, imagine this scenario: I have a web application which has to access >> a webservice that responds with JSON payloads; These payloads are a list of >> values, where each value is

Re: [go-nuts] Re: Why not tuples?

2022-12-06 Thread Roman Kuprov
I might be missing something, but you can just iterate over your list of structs and delete/set-to-default-value the offending field before shipping it to your client. Same as tuples afaic. On Monday, December 5, 2022 at 8:39:17 PM UTC-7 diogo...@gmail.com wrote: > Hi folks, > > Thanks for all

Re: [go-nuts] Re: Why not tuples?

2022-12-05 Thread Robert Engels
I worked on a system one time - in Java - that used a Sextuplet. I kid you not. Please. Please. Please use typed structures and save the futures maintainers they pain. It’s a little extra work up front that pays big dividends. > On Dec 5, 2022, at 9:39 PM, Diogo Baeder wrote: > >  > Hi folks

Re: [go-nuts] Re: Why not tuples?

2022-12-05 Thread Diogo Baeder
Hi folks, Thanks for all the inputs, I really appreciate the effort and help :-) Regardless of the whole discussion of whether or not tuples are a good or bad data structure, they exist out there in the wild, and we have to deal with them in many situations - of course, in our own code we can o

Re: [go-nuts] Re: Why not tuples?

2022-12-04 Thread Kevin Chowski
If you really need anonymous tuple types that support decoding that sort of JSON, it isn't too hard to write one: https://go.dev/play/p/Fn_wUXh2drs Go's generics don't support varargs types (...yet? who knows) so there'd be a little copypasta if you needed many different tuple lengths, but Java

Re: [go-nuts] Re: Why not tuples?

2022-12-03 Thread burak serdar
On Sat, Dec 3, 2022 at 8:47 PM Diogo Baeder wrote: > Hi there, sorry for weighting in so late in the game, but I just started > again to learn Go and was thinking why the language still doesn't have a > tuple type. > > Now, imagine this scenario: I have a web application which has to access a > w

Re: [go-nuts] Re: Why not tuples?

2022-12-03 Thread Diogo Baeder
Hi there, sorry for weighting in so late in the game, but I just started again to learn Go and was thinking why the language still doesn't have a tuple type. Now, imagine this scenario: I have a web application which has to access a webservice that responds with JSON payloads; These payloads ar

Re: [go-nuts] Re: Why not tuples?

2018-04-19 Thread Louki Sumirniy
Multiple return values. They do kinda exist in a declarative form of sorts, in the type signature, this sets the number and sequence and types of return values. You could even make functions accept them as also input values, I think, but I don't think it works exactly like this. I'm not a fan o

Re: [go-nuts] Re: Why not tuples?

2018-04-19 Thread Jan Mercl
On Thu, Apr 19, 2018 at 2:51 PM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > Sorry for the self-promotion but it was relevant in that I was working on how to tidy up the readability of my code and needed multiple returns and simple untyped tuples were really not nearly as convenient

Re: [go-nuts] Re: Why not tuples?

2018-04-19 Thread Louki Sumirniy
Just to clarify. Yes, the parent/child relationships are purely based on the indices of the nodes. It's not a conventional vector reference based binary tree. I was surprised when I came up with the idea that such did not even exist. Just to explain, it's a non-rectilinear array mapping. There i

Re: [go-nuts] Re: Why not tuples?

2018-04-19 Thread Louki Sumirniy
Ok, it may look like it but I don't want to track the cursor in the datatype itself most especially for reasons being that even one of the 'sideways walk' functions in the library needs to keep a copy of the coordinate of the previous node iterated past in order to identify when the direction (

Re: [go-nuts] Re: Why not tuples?

2018-04-18 Thread Jan Mercl
On Thu, Apr 19, 2018 at 6:57 AM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > > func (b *Bast) Parent(c Cursor) Cursor { > if c.Index == 0 { > c.Err = errors.New("No parent from the root") > return c > } > c.Row-- > c.Index = c.Index>>1 - (c.Index+1)%2 > c.Err = nil > return c > } >

[go-nuts] Re: Why not tuples?

2018-04-18 Thread Louki Sumirniy
I think there is no really big reason to make a special tuple type for return values. The extra burden comes in specifying the type and wrapping the list in curly brackets, and predefining the elements in a type struct declaration. I am writing a dense binary tree implementation (dense as in no