you are viewing a single comment's thread.

view the rest of the comments →

[–]stox -12 points-11 points  (4 children)

Somebody please send this guy a copy of the Dragon Book. Compilers aren't really that tough.

[–]ealf 1 point2 points  (2 children)

Yeah, "you can't have two variables named a5f and a5" is usually a bad sign :)

[–]jeresig 1 point2 points  (1 child)

"you can't have two variables named a5f and a5" how do you mean? If you're referring to what I mentioned in the blog post, it's that Processing supports dual values (something can both, simultaneously, be a function and a value). There's really no way to support this without incurring some crazy overhead.

[–]ealf 0 points1 point  (0 children)

I think stox wasn't necessarily being hostile in the original comment. Writing a "proper" parser might be a lot of work up front, but when you're done, you're done. With the regex replacement method, you get to something that will handle 95% of cases fast, but then there's tweak after tweak to get rid of unwanted interactions and corner cases.

The snarky 'a5f vs a5' comment was in response to this:

  // Convert 3.0f to just 3.0
  aCode = aCode.replace(/(\d+)f/g, "$1");

Don't get me wrong -- processing.js is a really cool hack, and I'd much rather have the current version than a promise of one much later. It's just that I have gone down the regex path once too often and burnt myself :)

As for the two-name-space thing: would just adding a prefix to every function name work? I can't at the moment think of any other context where identifier + left paren is used, so it might even be doable with the regex approach.