Hacker News new | ask | show | jobs
by olenhad 4513 days ago
I'm slightly surprised to see regex being used to parse and retrieve arguments from a function's source code. I would've normally assumed this to be a bad idea.
1 comments

I asked the original author about this at I/O last year shortly after I was introduced to Angular. I was baffled that they were just using toString and regexs. On the one hand, there isn't any (obvious) cleaner was to do it. On the other, it feels so duct taped I couldn't believe it was the foundation of a Google-sponsored project.
But it's not a foundation. A production Angular app really shouldn't rely on this (if for no other reason minification becomes impossible). This flavor of parameter parsing really only exists for demos and throw away code.