May. 3rd, 2007

jack: (Default)
Often words are fuzzy round the edges. A kite is a quadrilateral with adjacent pairs of sides equal that *normally* isn't a square. A parallelogram is a quadrilateral with opposite pairs of sides equal that *normally* isn't a square. So a kite *normally* isn't a parallelogram. But a square can legitimately be described as both.

IMHO, cucumbers and tomatoes are both a fruit and a vegetable.

And jaffa cakes may be both cakes and biscuits.

Understanding the definition of such words is fun and useful. But there may not be only one right answer. Or it could depend on context.

Also see: http://www.tailsteak.com/archive.php?num=87
jack: (Default)
So, in some programming languages I can say:

x=y=0

To mean "Set y equal to nought and x equal to that[1]". In others, you'd get "Set x equal to one if y is already zero, else zero."

But in what language can I say:

if (x===y==0)

to mean "if x and y are both zero"?

The obvious problem is common operator associativity doesn't work. If the operators are nested binary operators, "y==0" would have to return two values, both the result, and "0".

You could have a system whereby you *did* return a number of things, eg. the result in list[0] and the various operators or other hints in list[1..n], and then let logic decide how to use the hints. That might also be useful where a function really really wants to return two values.

But is there a consistent way of doing this without turning it into an unreadable mess? :)

[1] Non-pedant corner: non-pedants might say "set x and y equal to nought"

Active Recent Entries