From: Jamis Buck Date: 2004-02-03T23:23:32+09:00 Subject: Re: flip flop operator and assignment nobu.nokada@softhome.net wrote: >Hi, > >At Tue, 3 Feb 2004 13:08:50 +0900, >Jamis Buck wrote: > > >>So, instead of '..' and '...', how about something completely new, like >>perhaps '--', or '~~'? Or even a new keyword, like 'flip' or >>'flipflop'? It would be nice to also somehow provide a way to access >>some underlying objectified represention of the flip-flop, so that its >>state could be queried and manipulated, >> >> > >Ruby already has both of unary and binary '-' operators, so the >former will conflict. But '~' operator is only unary now, the >later wouldn't. > > > Good point. Another option would be to retain the use of the '..' and '...', but prefix any flip-flop expression with some disambiguating operator or keyword, a la: a .. b #-> range flip a..b # -> flip-flop With that, you could then add another piece of syntax to obtain the internal "objectified" representation: flip a..b => c The expression would still return boolean, as the regular flip-flop, but would assign the object to 'c', which could then be manipulated and queried: current_value = c.get_state c.set_state( false ) - Jamis -- Jamis Buck jgb3@email.byu.edu ruby -h | ruby -e 'a=[];readlines.join.scan(/-(.)\[e|Kk(\S*)|le.l(..)e|#!(\S*)/) {|r| a << r.compact.first };puts "\n>#{a.join(%q/ /)}<\n\n"'