Move println to io
dorian3343 opened this issue · 6 comments
Most languages don't have Println
builtin (with the notable exception being rust). The rest have them in an Io / Console or other package. I think we should follow this.
Most languages don't have Println builtin
Actually many do
- Python
- Javascript
- Kotlin
- Lua
- Swift
- PHP
- Ruby
- ...etc.
I think we should follow this.
What will we get from this except the need to import? I personally never like the need to import fmt
in Go to make basic IO stuff.
BTW Go has builtin print
function (it's never used tho)
I think we should keep builtin as small as possible and packages more grouped. We should decide what package is for what and break off pieces into those packages.
I agree that some stuff could (and maybe should) be moved from builtin
somewhere else, but I'm not sure about Println
.
builtin
package currently serves 2 purposes:
- compiler is aware of that package and uses knowledge about its structure in analyzer and desugarer
- things that are used frequently (I personally think that printing comes to this section)
Also, if there would be strong arguments for moving println out of builtin, then the question arise - should it be io
? Why not e.g. create fmt
like Go does? I believe there are other languages with this structure (e.g. Odin)
Also, if there would be strong arguments for moving println out of builtin, then the question arise - should it be
io
? Why not e.g. createfmt
like Go does? I believe there are other languages with this structure (e.g. Odin)
builtin.go
actually has a println
also. These builtins are meant for simple printing/debugging and the others under fmt
have error handling and more sophisticated things happening.
// implementation-specific way and writes the result to standard error.
// Print is useful for bootstrapping and debugging; it is not guaranteed
// to stay in the language.
func print(args ...Type)
// The println built-in function formats its arguments in an
// implementation-specific way and writes the result to standard error.
// Spaces are always added between arguments and a newline is appended.
// Println is useful for bootstrapping and debugging; it is not guaranteed
// to stay in the language.
func println(args ...Type)
Maybe this would be a good approach?
@swork1 I find it confusing. I saw many posts on the internet people asking why Go have 2 println functions. I don't think we have that problem they have, that they solved by having 2 println functions. We should have only one.
Moving to fmt
however might be a good point. Not sure
I'm going to close this one for now. We can reopen if needed