Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What is the point of making echo a special syntax and not just a function? And add another function to retrieve stack info.


The compiler can inject information at compile time so no runtime reflection is necessary.


Well, there's nothing stopping the language from having builtin functions and constants in the standard library that are handled specially by the compiler, the same way this echo keyword is. That would've had the added benefit of being backwards compatible (which new keywords are not).


Gleam reserved a handful of keywords in 1.0 (including echo), so it isn't a new keyword.


What you're describing is what `echo` is in terms of functionality and implemented, and it's not a new keyword so it is backwards compatible.

There are disadvantages of blurring the lines of what a function is an can do. Gleam values clarity above all things, so we don't have back-doors or special-cases. Everything plays by the same rules.


that is basically just a keyword with extra steps...


> That would've had the added benefit of being backwards compatible (which new keywords are not).


except it’s not a new keyword. and is your argument that you could easily define python print() to something else in a way that having a “print” keyword disallows? no wonder python 2=>3 was such a bear…


Call site can be inlined in compile time, without special syntax. Full stack trace would require runtime support anyway.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: