On Jan 30, 9:04 am, "Edward K. Ream" <[email protected]> wrote:
> it suggests an important new invariant: namely that canonicalizing an
> already-canonicalized shortcut should be a no-op.
I am seriously considering creating a KeyStroke class, a very thin
wrapper around a string.
Despite its miniscule size, this could be an important class: it
announces that its contents have been canonicalized once and *only*
once.
With this class in place, the code can now easily distinguish between
"raw" key-related settings strings and canonicalized KeyStroke
objects. This will drastically reduce the importance of the (missing)
identity::
shortcutFromSetting(S) ==
shortcutFromSetting(shortcutFromSetting(S))
The inability to distinguish canonicalized settings strings from raw
settings strings made the code *much* more difficult to understand
that it needed to be. Worse, the code was brittle: subtle
misunderstandings about the contents (history) of strings translated
directly into hard-to-find bugs.
This is yet another example of the importance of types in Python
programs. Not all strings are, in fact, equivalent! In fact,
changing the *contents* of a string can, in effect, change its type.
The new KeyStroke class will make the type transformation explicit, as
it should have been all along.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.