Re: = vs := and = vs ==

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

I have no clear idea what you really mean by that. If you are thinking of some mythical performance-related issue, I have found that it is almost always faster to use a non-sequence-op method, and in fact hll code such as that above can be aggressively pass-by-reference-optimized [although I should admit to recently breaking that handling in Phix] and therefore (at least for quite long/nested sequences) massively outperform the equivalent low-level code.

Pete

Obviously neither one of us is understanding the other here, since I cannot interpret your question. I'm certainly not thinking of any performance-related issue, but rather principle of least surprise.

if "ABC" = "ABC" should evaluate to 1 or true, not to {1, 1, 1}. if {1.29, {3, "foo", 255}, 'A'} = {1.29, {3, "foo", 255}, 'A'} should also return a true or false value.

Inside the interpreter, first the references would be compared, and then the value, and then recurse through the sequence doing the same for every element.

This would obviously be most useful for strings, but also for lists of strings and lists of other objects.

To return a sequence of booleans instead of reducing a comparison to a single boolean, then I would use bool_equal() or some other as yet non-existent function. An alternative if it is important would be to make new operators using a . or a : along with =, <, >, != in order to specify returning a list of booleans instead of a single boolean.

Just some thoughts I'm playing with. I'm not suggesting changing Euphoria's existing behavior, just playing "what if".

Edit I'm going to backtrack a bit on the sequence arithmetic operations -- doing an arithmetic operation on sequences of different lengths is a possible error and so Euphoria's current behavior should be maintained.

I stand by the boolean thing though.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu