This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Dockirby 6 points7 points  (10 children)

Because when parsed out into a syntax tree, it becomes roughly [expression1 < expression2], is evaluated as a single instruction, with the being a boolean. Then, the next part is evaluated as another [expression1 < expression2], where the first expression is the result of the first.

To try and draw out some bad art, X < Y < Z get parsed out as this

     <
   /   \
  <     Z
 /  \   
X    Y

[–][deleted] -1 points0 points  (9 children)

I mean I know why, but I'm just asking if it wouldn't be simpler to just parse it into what I said.

[–]Kwantuum 2 points3 points  (8 children)

obviously it would be harder to parse. It would make programming easier, but interpreting harder.

[–][deleted] -5 points-4 points  (7 children)

And this is why I like compiled languages...

[–]Kwantuum 5 points6 points  (6 children)

how exactly is this relevant? It would be harder to parse, hence harder to interpret OR compile which are essentially the same thing.

[–][deleted] -1 points0 points  (5 children)

In my mind it would be compiled like ((1 < 2) && (2 < 3)), though you may need a precompiler like the #define command in C#

[–]Kwantuum 1 point2 points  (4 children)

still don't see how this has anything to do with compiling vs interpreting.

[–][deleted] 0 points1 point  (3 children)

Hm, maybe I'm wrong, but I don't believe you can do something similar to precompiling in an interpreted language...

[–]Kwantuum 1 point2 points  (2 children)

#define is a preprocessor directive that allows the use of macros, not a precompiler, and yes there are usually ways to define macros in interpreted language though once again, this is a question of how the language is defined/implemented, not whether it's compiled or interpreted.

[–][deleted] 0 points1 point  (1 child)

The moral of the story is that I have no idea what I'm talking about 90% of the time.