Re: [go-nuts] what does p stand for in io.Reader.Read argument
now it makes sense. thanks Santhosh On Sat, Apr 6, 2019 at 11:20 PM andrey mirtchovski wrote: > It may help to note that in the earliest references to the Read > interface in the history of the language it accepted a *[]byte, hence > 'p' may indeed stand for pointer. > > > https://github.com/golang/go/commit/7c9e2c2b6c2e0aa3090dbd5183809e1b2f53359b#diff-bf734f53a84f388bf39699d291b06b1d > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] what does p stand for in io.Reader.Read argument
It may help to note that in the earliest references to the Read interface in the history of the language it accepted a *[]byte, hence 'p' may indeed stand for pointer. https://github.com/golang/go/commit/7c9e2c2b6c2e0aa3090dbd5183809e1b2f53359b#diff-bf734f53a84f388bf39699d291b06b1d -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] what does p stand for in io.Reader.Read argument
ok. got it my thinking is 'b' is obvious choice, then why invent new name 'p' ? On Sat, Apr 6, 2019 at 11:15 PM Jan Mercl <0xj...@gmail.com> wrote: > It can be whatever you like: passedBuf, payload, putBuffer, param, > pointer, ... > > It does not have to represent any word after all. Naming is hard, but in > the case of a single argument it does not matter that much, so it could be > just a case of author's C habits: void *p for buffers. > > On Sat, Apr 6, 2019, 19:34 Santhosh T wrote: > >> seems my question is not clear. >> my question is regarding naming of variables. >> i know that single name variables in go is idiomatic. >> >> r for reader >> w for writer >> etc... >> >> Read(p []byte) (n int, err error) >> >> i dont get why argument is named 'p' instead of 'b'. >> there should be some reasoning. >> I dont get why 'p' is chosen as argument name instead of 'b'. >> >> thanks >> Santhosh >> >> >> On Sat, Apr 6, 2019 at 9:54 PM Philip Chapman wrote: >> >>> p is the array of bytes that you want to fill with data read. The >>> method returns the count of the number of bytes read which may be any value >>> from zero to p's length. You must make multiple reads if the thing being >>> read from holds more data than your buffer array can hold. >>> >>> On Sat, Apr 6, 2019 at 9:16 AM Santhosh T >>> wrote: >>> Hi, method in io.Reader interface is: Read(p []byte) (n int, err error) what does `p` stands for ? thanks Santhosh -- 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. For more options, visit https://groups.google.com/d/optout. >>> >>> >>> -- >>> Philip A. Chapman >>> Java Software Development >>> Enterprise, Web, and Desktop >>> >> -- >> 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. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] what does p stand for in io.Reader.Read argument
It can be whatever you like: passedBuf, payload, putBuffer, param, pointer, ... It does not have to represent any word after all. Naming is hard, but in the case of a single argument it does not matter that much, so it could be just a case of author's C habits: void *p for buffers. On Sat, Apr 6, 2019, 19:34 Santhosh T wrote: > seems my question is not clear. > my question is regarding naming of variables. > i know that single name variables in go is idiomatic. > > r for reader > w for writer > etc... > > Read(p []byte) (n int, err error) > > i dont get why argument is named 'p' instead of 'b'. > there should be some reasoning. > I dont get why 'p' is chosen as argument name instead of 'b'. > > thanks > Santhosh > > > On Sat, Apr 6, 2019 at 9:54 PM Philip Chapman wrote: > >> p is the array of bytes that you want to fill with data read. The method >> returns the count of the number of bytes read which may be any value from >> zero to p's length. You must make multiple reads if the thing being read >> from holds more data than your buffer array can hold. >> >> On Sat, Apr 6, 2019 at 9:16 AM Santhosh T >> wrote: >> >>> Hi, >>> >>> method in io.Reader interface is: >>> Read(p []byte) (n int, err error) >>> >>> what does `p` stands for ? >>> >>> thanks >>> Santhosh >>> >>> -- >>> 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. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> -- >> Philip A. Chapman >> Java Software Development >> Enterprise, Web, and Desktop >> > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] what does p stand for in io.Reader.Read argument
seems my question is not clear. my question is regarding naming of variables. i know that single name variables in go is idiomatic. r for reader w for writer etc... Read(p []byte) (n int, err error) i dont get why argument is named 'p' instead of 'b'. there should be some reasoning. I dont get why 'p' is chosen as argument name instead of 'b'. thanks Santhosh On Sat, Apr 6, 2019 at 9:54 PM Philip Chapman wrote: > p is the array of bytes that you want to fill with data read. The method > returns the count of the number of bytes read which may be any value from > zero to p's length. You must make multiple reads if the thing being read > from holds more data than your buffer array can hold. > > On Sat, Apr 6, 2019 at 9:16 AM Santhosh T > wrote: > >> Hi, >> >> method in io.Reader interface is: >> Read(p []byte) (n int, err error) >> >> what does `p` stands for ? >> >> thanks >> Santhosh >> >> -- >> 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. >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > Philip A. Chapman > Java Software Development > Enterprise, Web, and Desktop > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] what does p stand for in io.Reader.Read argument
p is the array of bytes that you want to fill with data read. The method returns the count of the number of bytes read which may be any value from zero to p's length. You must make multiple reads if the thing being read from holds more data than your buffer array can hold. On Sat, Apr 6, 2019 at 9:16 AM Santhosh T wrote: > Hi, > > method in io.Reader interface is: > Read(p []byte) (n int, err error) > > what does `p` stands for ? > > thanks > Santhosh > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- Philip A. Chapman Java Software Development Enterprise, Web, and Desktop -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] what does p stand for in io.Reader.Read argument
Hi, method in io.Reader interface is: Read(p []byte) (n int, err error) what does `p` stands for ? thanks Santhosh -- 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. For more options, visit https://groups.google.com/d/optout.