Why isn't “close” a reserved keyword? [closed]












-1















close() seems to be a reserved keyword for channels. Seems a bit strong to make it a built-in, when it could just be a method on a channel, no? Like when creating and closing a file?



I guess the same could be asked for len()?










share|improve this question















closed as primarily opinion-based by Benjamin W., Kyslik, Volker, peterSO, Flimzy Nov 24 '18 at 8:48


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.























    -1















    close() seems to be a reserved keyword for channels. Seems a bit strong to make it a built-in, when it could just be a method on a channel, no? Like when creating and closing a file?



    I guess the same could be asked for len()?










    share|improve this question















    closed as primarily opinion-based by Benjamin W., Kyslik, Volker, peterSO, Flimzy Nov 24 '18 at 8:48


    Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.





















      -1












      -1








      -1








      close() seems to be a reserved keyword for channels. Seems a bit strong to make it a built-in, when it could just be a method on a channel, no? Like when creating and closing a file?



      I guess the same could be asked for len()?










      share|improve this question
















      close() seems to be a reserved keyword for channels. Seems a bit strong to make it a built-in, when it could just be a method on a channel, no? Like when creating and closing a file?



      I guess the same could be asked for len()?







      go standards






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 20:20









      Seaskyways

      1,45221530




      1,45221530










      asked Nov 23 '18 at 20:02









      MuppetMuppet

      2,00531727




      2,00531727




      closed as primarily opinion-based by Benjamin W., Kyslik, Volker, peterSO, Flimzy Nov 24 '18 at 8:48


      Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.









      closed as primarily opinion-based by Benjamin W., Kyslik, Volker, peterSO, Flimzy Nov 24 '18 at 8:48


      Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.


























          1 Answer
          1






          active

          oldest

          votes


















          3














          close is a function that takes a channel as a parameter. Just like new and make, they are functions, and you can name local variables or functions like them.



          Keywords are language constructs like struct, type, if, else ...






          share|improve this answer



















          • 1





            ok that's true, I mixed that up. But why is this a separate "built in" function? Why not make it a method of channels? e.g. for a file pointer created through os.Create() you have to use fp.Close() as well? Wouldn't it be more consistent to have that for channels as well, e.g. channel.Close()?

            – Muppet
            Nov 23 '18 at 20:23













          • channels are native types of Go, like int, uint, string, and others, channels cannot have methods. That's why you find packages like 'bytes' to manipulate byte, or 'strings' package to manipulate strings. In contrast to os.Create() which returns a struct instance, which can have methods.

            – Seaskyways
            Nov 23 '18 at 20:25













          • Please don't forget to make your question as answered

            – Seaskyways
            Nov 23 '18 at 20:54


















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          close is a function that takes a channel as a parameter. Just like new and make, they are functions, and you can name local variables or functions like them.



          Keywords are language constructs like struct, type, if, else ...






          share|improve this answer



















          • 1





            ok that's true, I mixed that up. But why is this a separate "built in" function? Why not make it a method of channels? e.g. for a file pointer created through os.Create() you have to use fp.Close() as well? Wouldn't it be more consistent to have that for channels as well, e.g. channel.Close()?

            – Muppet
            Nov 23 '18 at 20:23













          • channels are native types of Go, like int, uint, string, and others, channels cannot have methods. That's why you find packages like 'bytes' to manipulate byte, or 'strings' package to manipulate strings. In contrast to os.Create() which returns a struct instance, which can have methods.

            – Seaskyways
            Nov 23 '18 at 20:25













          • Please don't forget to make your question as answered

            – Seaskyways
            Nov 23 '18 at 20:54
















          3














          close is a function that takes a channel as a parameter. Just like new and make, they are functions, and you can name local variables or functions like them.



          Keywords are language constructs like struct, type, if, else ...






          share|improve this answer



















          • 1





            ok that's true, I mixed that up. But why is this a separate "built in" function? Why not make it a method of channels? e.g. for a file pointer created through os.Create() you have to use fp.Close() as well? Wouldn't it be more consistent to have that for channels as well, e.g. channel.Close()?

            – Muppet
            Nov 23 '18 at 20:23













          • channels are native types of Go, like int, uint, string, and others, channels cannot have methods. That's why you find packages like 'bytes' to manipulate byte, or 'strings' package to manipulate strings. In contrast to os.Create() which returns a struct instance, which can have methods.

            – Seaskyways
            Nov 23 '18 at 20:25













          • Please don't forget to make your question as answered

            – Seaskyways
            Nov 23 '18 at 20:54














          3












          3








          3







          close is a function that takes a channel as a parameter. Just like new and make, they are functions, and you can name local variables or functions like them.



          Keywords are language constructs like struct, type, if, else ...






          share|improve this answer













          close is a function that takes a channel as a parameter. Just like new and make, they are functions, and you can name local variables or functions like them.



          Keywords are language constructs like struct, type, if, else ...







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 23 '18 at 20:09









          SeaskywaysSeaskyways

          1,45221530




          1,45221530








          • 1





            ok that's true, I mixed that up. But why is this a separate "built in" function? Why not make it a method of channels? e.g. for a file pointer created through os.Create() you have to use fp.Close() as well? Wouldn't it be more consistent to have that for channels as well, e.g. channel.Close()?

            – Muppet
            Nov 23 '18 at 20:23













          • channels are native types of Go, like int, uint, string, and others, channels cannot have methods. That's why you find packages like 'bytes' to manipulate byte, or 'strings' package to manipulate strings. In contrast to os.Create() which returns a struct instance, which can have methods.

            – Seaskyways
            Nov 23 '18 at 20:25













          • Please don't forget to make your question as answered

            – Seaskyways
            Nov 23 '18 at 20:54














          • 1





            ok that's true, I mixed that up. But why is this a separate "built in" function? Why not make it a method of channels? e.g. for a file pointer created through os.Create() you have to use fp.Close() as well? Wouldn't it be more consistent to have that for channels as well, e.g. channel.Close()?

            – Muppet
            Nov 23 '18 at 20:23













          • channels are native types of Go, like int, uint, string, and others, channels cannot have methods. That's why you find packages like 'bytes' to manipulate byte, or 'strings' package to manipulate strings. In contrast to os.Create() which returns a struct instance, which can have methods.

            – Seaskyways
            Nov 23 '18 at 20:25













          • Please don't forget to make your question as answered

            – Seaskyways
            Nov 23 '18 at 20:54








          1




          1





          ok that's true, I mixed that up. But why is this a separate "built in" function? Why not make it a method of channels? e.g. for a file pointer created through os.Create() you have to use fp.Close() as well? Wouldn't it be more consistent to have that for channels as well, e.g. channel.Close()?

          – Muppet
          Nov 23 '18 at 20:23







          ok that's true, I mixed that up. But why is this a separate "built in" function? Why not make it a method of channels? e.g. for a file pointer created through os.Create() you have to use fp.Close() as well? Wouldn't it be more consistent to have that for channels as well, e.g. channel.Close()?

          – Muppet
          Nov 23 '18 at 20:23















          channels are native types of Go, like int, uint, string, and others, channels cannot have methods. That's why you find packages like 'bytes' to manipulate byte, or 'strings' package to manipulate strings. In contrast to os.Create() which returns a struct instance, which can have methods.

          – Seaskyways
          Nov 23 '18 at 20:25







          channels are native types of Go, like int, uint, string, and others, channels cannot have methods. That's why you find packages like 'bytes' to manipulate byte, or 'strings' package to manipulate strings. In contrast to os.Create() which returns a struct instance, which can have methods.

          – Seaskyways
          Nov 23 '18 at 20:25















          Please don't forget to make your question as answered

          – Seaskyways
          Nov 23 '18 at 20:54





          Please don't forget to make your question as answered

          – Seaskyways
          Nov 23 '18 at 20:54





          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin