QuerySignal.st
changeset 1954 05b137a75c75
parent 1734 c05da5185472
child 2037 d5644b390755
equal deleted inserted replaced
1953:c8a3af54acb3 1954:05b137a75c75
    15 	classVariableNames:''
    15 	classVariableNames:''
    16 	poolDictionaries:''
    16 	poolDictionaries:''
    17 	category:'Kernel-Exceptions'
    17 	category:'Kernel-Exceptions'
    18 !
    18 !
    19 
    19 
    20 !QuerySignal  class methodsFor:'documentation'!
    20 !QuerySignal class methodsFor:'documentation'!
    21 
    21 
    22 copyright
    22 copyright
    23 "
    23 "
    24  COPYRIGHT (c) 1995 by Claus Gittinger
    24  COPYRIGHT (c) 1995 by Claus Gittinger
    25 	      All Rights Reserved
    25 	      All Rights Reserved
    38     QuerySignals are like signals, except that they are not accepted
    38     QuerySignals are like signals, except that they are not accepted
    39     by handlers for ordinary signals.
    39     by handlers for ordinary signals.
    40     I.e. a signal handler for a normal signal will not handle a query
    40     I.e. a signal handler for a normal signal will not handle a query
    41     signal. Thus, these bypass anySignal handlers.
    41     signal. Thus, these bypass anySignal handlers.
    42     If unhandled, no error is raised, instead they are simply ignored
    42     If unhandled, no error is raised, instead they are simply ignored
       
    43     and nil is returned from the raise
    43     (as opposed to normal signals, which raise an unhandled signal exception).
    44     (as opposed to normal signals, which raise an unhandled signal exception).
    44     QuerySignals are also ignored, if a handler exists, but rejects.
    45     QuerySignals are also ignored, if a handler exists, but rejects.
    45 
    46 
    46     Their main use is to implement up-Queries via signals, that work even 
    47     Their main use is to implement upQueries via signals, that work even 
    47     if intermediate errorSignal handlers are present 
    48     if intermediate errorSignal handlers are present 
    48     (which is not possible with ordinary signals, since errorSignal handlers 
    49     (which is not possible with ordinary signals, since errorSignal handlers 
    49      would catch those signals).
    50      would catch those signals).
    50 
    51 
    51     Code deep down in the calling hierarchy can post such an up-Query to ask
    52     Code deep down in the calling hierarchy can post such an up-Query to ask
    56     up in the hierarchy (to show it in the windows info area) or simply
    57     up in the hierarchy (to show it in the windows info area) or simply
    57     ignored.
    58     ignored.
    58 
    59 
    59     Using QuerySignals for this (instead of regular Signals) helps in documenting
    60     Using QuerySignals for this (instead of regular Signals) helps in documenting
    60     the intended usage of those signals.
    61     the intended usage of those signals.
       
    62 
       
    63     Another use of querySignals is to provide additional information to
       
    64     deeply nested methods, which is only required in the uncommon case;
       
    65     or if another parameter is required by some method, which was not planned
       
    66     for in the beginning, and you do not want to hand this value (via an
       
    67     additional argument) through all intermediate levels.
       
    68     A highly elegant solution to this problem is to provide a handler somewhere
       
    69     at the top of the calling hierarchy, and raise an upQuery from whereever
       
    70     that value is required.
       
    71     A concrete application can be found in the windowGroup- and lastEvent-
       
    72     queries, provided by the windowGroup object. If anyone is interrested
       
    73     in the event which was responible for the anyone to be called, all he needs
       
    74     to do is to raise the lastEventQuerySignal, which returns that event.
       
    75     No intermediate methods are required to know anything about that.
       
    76 
       
    77     A final note (to C++ and Java fans):
       
    78         such upQueries are only possible, if the exception handling mechanism
       
    79         does not automatically unwind the stack for the handler invokation.
       
    80         Since the handler must be able to proceed the execution and return
       
    81         a value to the raiser ....
       
    82 
    61 
    83 
    62     [see also:]
    84     [see also:]
    63         Signal SignalSet Exception
    85         Signal SignalSet Exception
    64         Object
    86         Object
    65         (``Exception handling and signals'': programming/exceptions.html)
    87         (``Exception handling and signals'': programming/exceptions.html)
   269 
   291 
   270     "Created: 10.7.1996 / 15:08:20 / cg"
   292     "Created: 10.7.1996 / 15:08:20 / cg"
   271     "Modified: 14.10.1996 / 16:59:18 / cg"
   293     "Modified: 14.10.1996 / 16:59:18 / cg"
   272 ! !
   294 ! !
   273 
   295 
   274 !QuerySignal  class methodsFor:'documentation'!
   296 !QuerySignal class methodsFor:'documentation'!
   275 
   297 
   276 version
   298 version
   277     ^ '$Header: /cvs/stx/stx/libbasic/QuerySignal.st,v 1.15 1996-10-14 15:59:28 cg Exp $'
   299     ^ '$Header: /cvs/stx/stx/libbasic/QuerySignal.st,v 1.16 1996-11-09 16:12:01 cg Exp $'
   278 ! !
   300 ! !