Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Making Wrong Code Look Wrong (2005). Parent comment
type Password string type Name string
func SayHello(name Name) { fmt.Println("Hello %s",string(name)) }
func Login(password Password) bool { if bcrypt.magicstuff([]byte(password)){ return true } log.Println("error: wrong password: ", string(password)) return false }
Now the type system does know whether it's a name or a password, and will throw a compiler error if you try to use the wrong one in the wrong place.
edit: really HN, no code formatting options? :(
There are no comments on this comment yet.
type Password string type Name string
func SayHello(name Name) { fmt.Println("Hello %s",string(name)) }
func Login(password Password) bool { if bcrypt.magicstuff([]byte(password)){ return true } log.Println("error: wrong password: ", string(password)) return false }
Now the type system does know whether it's a name or a password, and will throw a compiler error if you try to use the wrong one in the wrong place.
edit: really HN, no code formatting options? :(