Re: = vs := and = vs ==

new topic     » goto parent     » topic index » view thread      » older message » newer message
_tom said...

What would it take to allow := in an assignment statement? (Phix by Lomax already does this.)

What would it take to allow = to compare atoms and == to compare objects?

These syntax changes could make it easier for a Euphoria initiate.

There is no need to introduce new operators. The reason for Euphoria's limitation on using '=' for boolean compare in statements is the because of a design decision to evaluate the expression before using the result in the test. Basically it boils down to the definition of IF is more like ...

IF integer THEN

So when the parser sees 'if a = b then' it first evaluates the 'a = b' like this ...

When 'a' or 'b' is a sequence, then each of its elements are evaluated for equality and a sequence is returned as the result. We end up with

IF sequence THEN

which is illegal.

The way to properly "fix" this is to change the parser to perform a boolean test in these situations rather than a sequence operation. This is quite a big deal though, given the way its coded.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu