Hacker News new | past | comments | ask | show | jobs | submit login

true, tho slight savings in characters not worth the less-clear definition imo



On the other hand, you may want to set `now` to return a deterministic time value when testing, which the variable allows.


Is that really less clear?


I think so -- if I see this it's obvious now is a function.

    func now() time.Time { return time.Now() } 
If I see this:

    var now = time.Time
My first instinct is, "hmmm, some kind of variable?" And then I have to remember, "oh yeah, it's just a variable that holds a function."

Obviously not a big deal either way.

(I think this further shows how type aliases would not be adding much possibility for confusion compared to what already exists in the language.)


btw if you want you can explicit mention the type in the var declaration




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: