Hello,
I didn't like list comprehensions when I first used them, but soon enough
you start to see how good they are, and they're fairly readable on the
whole, certainly once you've used them a few times. (They're also more
efficient than the alternative, as well as being one line instead of
four.)
I think "belonging" to a window is probably in the eye of the beholder.
Some people might say that is the case if the spectrum is visible (so, in
code, view.isPosVisible or view.isNegVisible), or perhaps is listed in the
toolbar (view.isInToolbar), or perhaps is just mappable (in theory) to the
window (view, period). We could have functions for each of these (we
already have two out of the three), and no doubt other alternatives (e.g.
related to ndim).
I should add that we have some utility code in Analysis (in the *Basic
modules) but no doubt much more could be written. These are generally
functions that expect data model objects as input. So in WindowBasic, for
example, we expect to have a window (SpectrumWindow in data model
parlance) as input. WindowPopup is a graphical module which points to the
corresponding window object (windowPopup.window). We'd probably prefer to
keep WindowPopup objects out of WindowBasic and leave functions that deal
with them either as part of WindowPopup itself (or its superclass
WindowDraw) or in some macro library. So if we wanted to have functions
in WindowBasic that accomplished the things mentioned in the second
paragraph, then have window as the input, not windowPopup.
Wayne
On Tue, 25 Sep 2007, Jeremy Craven wrote:
> OK, I have been misuing the term mapped in my head.
>
> I personally don't feel that "is in the toolbar" is the most intuitive
> way to talk about the idea that a particular set of spectra
> "particularly belong" in a certain window. This is one for the
> documentation project to work on ...
>
> (PS can we ban list (in)comprehensions .... ; but then just checked it
> out on Wikipedia to see whose wretched invention they were, and at least
> we should be glad not to have perl's version "@S = map{$_*2}
> grep{$_*$_>3} (0 .. 99);" .....)
>
> Jeremy
>
|