Re: [go-nuts] The side effect of calling html.Token()

2018-01-15 Thread Tong Sun
Thanks a lot for the comprehensive explanation Nigel, really appreciate it !! -- 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

Re: [go-nuts] The side effect of calling html.Token()

2018-01-15 Thread Nigel Tao
On Sun, Jan 14, 2018 at 4:33 PM, Tong Sun wrote: > Not being able to do that, I have to save all the Token() info to different > variables, then pass all those variables to my function separately, instead > of passing merely a single tokenizer. Instead of using different variables, I'd just pass

Re: [go-nuts] The side effect of calling html.Token()

2018-01-13 Thread Tong Sun
On Sunday, January 14, 2018 at 12:33:46 AM UTC-5, Tong Sun wrote: > > > Token should be called at most once per Next call, > > Ah, that's exactly what my mistake was -- I use Token() in the loop the > standard way, but in the element handling, I used function calls, within > which I use the pa

Re: [go-nuts] The side effect of calling html.Token()

2018-01-13 Thread Tong Sun
> Token should be called at most once per Next call, Ah, that's exactly what my mistake was -- I use Token() in the loop the standard way, but in the element handling, I used function calls, within which I use the passed tokenizer to get the Token() again. Not being able to do that, I have to sav

Re: [go-nuts] The side effect of calling html.Token()

2018-01-13 Thread Nigel Tao
On Fri, Jan 12, 2018 at 2:24 PM, Tong Sun wrote: > but I really suggest that you give it a test. It is already tested directly by func TestTokenizer in token_test.go The Tokenizer.Text method implementation does not call Tokenizer.Next, and only the Next method moves on to the next token. It is

Re: [go-nuts] The side effect of calling html.Token()

2018-01-11 Thread Tong Sun
On Thu, Jan 11, 2018 at 8:57 PM, Nigel Tao wrote: > On Wed, Jan 3, 2018 at 1:03 PM, Tong Sun wrote: > > Shouldn't Token() be better returning the current one > > instead of the next? > > You're right. I sent out https://go-review.googlesource.com/c/net/+/87515 Thanks Nigel, for looking into i

Re: [go-nuts] The side effect of calling html.Token()

2018-01-11 Thread Nigel Tao
On Wed, Jan 3, 2018 at 1:03 PM, Tong Sun wrote: > Shouldn't Token() be better returning the current on > instead of the next? You're right. I sent out https://go-review.googlesource.com/c/net/+/87515 -- You received this message because you are subscribed to the Google Groups "golang-nuts" gro

[go-nuts] The side effect of calling html.Token()

2018-01-02 Thread Tong Sun
Hi, For golang.org/x/net/html, both Token() and Next() advance the token to the next, right? https://godoc.org/golang.org/x/net/html#Token > Token returns the next Token. What's the advantages of having them doing the same thing, while lacking one function to return the current token? Is thi