Hal Fulton said:
Michael campbell wrote:
Well, I like the syntax, because I’ve trained my brain to understand
it.
Well, it runs counter to the rest of Ruby.
My complaints about the flip/flop op are:
-
It is context sensitive. Is the following snippet of code a
flip/flop? …
expression1 … expression2
You can’t tell unless you know the context where the snippet appears.
Although Perl is full of context dependencies, it is rare in Ruby
(this is the only one that comes to mind).
-
Although it looks like a range of regular expressions, it is not.
Understanding the behavior of Regexps and Ranges gives no clue to
the behavior of the flip flop op. In addition, understanding the
difference between a two-dot and three-dot range doesn’t shed any
light on the difference between a two-dot and three-dot flip flop
op.
-
It has state (hidden!), but it is not an object. I can’t assign
it to a variable or pass it to a function, nor can I send it
messages.
There have been a number of library based suggestions. I think
something along those lines will make a nice replacement, and I
suspect will be even more flexible in the end.
IMHO.
···
“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)
Jim Weirich wrote:
- It is context sensitive. Is the following snippet of code a
flip/flop? …
I will agree that on a purely academic level, that’s true. However, I (nor anyone I’ve ever worked with) don’t run, read, write, or otherwise deal with code that has absolutely 0 context around it, so the argument there is somewhat moot.
- It has state (hidden!), but it is not an object. I can’t assign
it to a variable or pass it to a function, nor can I send it
messages.
The fact that it has state is a /good/ thing. The fact that it isn’t an object and thus eliminates being used as one I haven’t found to ever be an issue, but I like the idea of that possibility.
There have been a number of library based suggestions. I think
something along those lines will make a nice replacement, and I
suspect will be even more flexible in the end.
I’d be willing to use a replacement if/when one presents itself. I doubt it will be as flexible or concise, but we will have to see.
Jim Weirich wrote:
- It is context sensitive. Is the following snippet of code a
flip/flop? …
I will agree that on a purely academic level, that’s true.
However, I (nor anyone I’ve ever worked with) don’t run, read,
write, or otherwise deal with code that has absolutely 0 context
around it, so the argument there is somewhat moot.
It’s a POV thing. I agree with what you’re saying on an academic
level, but … 
[…]
There have been a number of library based suggestions. I think
something along those lines will make a nice replacement, and I
suspect will be even more flexible in the end.
I’d be willing to use a replacement if/when one presents itself.
I doubt it will be as flexible or concise, but we will have to see.
I certainly nominate you for a position on the Flip-Flop Object-Based
Solution Selection Committee 
(Which means I’d like to see your comments on existing posted
solutions. What are their drawbacks?)
Cheers,
Gavin
···
On Monday, February 2, 2004, 2:25:47 AM, Michael wrote: