Re: = vs := and = vs ==
- Posted by SDPringle May 10, 2014
- 2168 views
I like := for assignment and == for comparison. I don't see why they should even throw errors necessarily when used in a place where = would have the other meaning. If I were designing a language from the ground up, I would have := for assignment and == for comparison. Comparison like Phix with == and comparison one object down with something like (==), two objects down with ((==)). Conditionals would have to evaluate to a boolean type, which would have to be builtin to the language, like Java.
Honey (==) Money -- is (false, true, true, true, true) Honey == Money -- is false ( "Ha", "Ja" ) (==) ( "Ja", "Ja" ) -- is (false, true) ( "Ha", "Ja" ) ((==)) ( "Ja", "Ja") -- is [ (false, true), (true, true) ]As long as = retains its old meaning this wouldn't break code. There is a bug introduction risk associated to each change to the runtime and parser system as with any language though.
Shawn

