logoalt Hacker News

neilalexandertoday at 12:10 PM2 repliesview on HN

It's not really a hack. It's a hint to a static analyser, that's all.


Replies

woadwarrior01today at 12:14 PM

Most languages would encode such behavior in a trait or a protocol instead of a zero-length struct field. It's type information and ought to be encoded in the type. From that perspective, I think it is a hack.

show 2 replies
tgvtoday at 12:55 PM

Nah... I like Go, but this is a hack. Wiktionary --not the ultimate authority, I know, but still-- defines to hack as: To make a quick code change to patch a computer program, often one that, while being effective, is inelegant or makes the program harder to maintain.

I could accept having an anonymous embedding as a kind of syntax directive. So many languages have had directives bolted on later, so that wouldn't be a deal breaker. But then it should be accessible in all code and (external) code should be able to implement behavior as well.