On Sun, 13 Jul 2008, Bluebie, Jenna wrote:

oh, no, it totally doesn't have to! the keypress could emit an object which subclasses String which has an === method set up to be true for :control_x and :ctrl_x and 'x' and anything else along those lines... to_s would return the key thing, to_sym would return the normal long symbol form, and control?/ctrl?, alt?/option?, shift?, .command?/.meta?/.windows?/.tux?/.apple? would all give off booleans.

We could call this object.... Keystroke :)

Ruby is not the fastest language out there.  Keyboard handling needs to
be responsive. Emitting objects would be much more intensive than emitting
symbols, and if symbols are used, then only one can be emitted.  I'd suggest
turning this on its head, and have a Keyboard object which "knows" about
keystrokes (symbols) and if interrogated about :ctrl_x "knows" it is the same
as :control_x.   And it could do all the other translations you talk of
here.  But the symbols need to be small and nimble.

The first entry Google gives for "flyweight pattern" is [folded]:

Flyweight pattern - Wikipedia, the free encyclopedia
A classic example usage of the flyweight pattern are the data
structures for graphical representation of characters in a word
processor. ...
en.wikipedia.org/wiki/Flyweight_pattern - 43k - Cached - Similar
pages

        HTH
        Hugh

Reply via email to