Changeset 37197 in project


Ignore:
Timestamp:
02/02/19 17:12:36 (2 weeks ago)
Author:
juergen
Message:

simple-exceptions 1.3 docu updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/simple-exceptions

    r37041 r37197  
    5959without looping forewer, what with-exception-handler would have done.
    6060
    61 Another useful macro is assert* which -- contrary to assert -- allows
    62 many expressions to be tested and demands a location argument, which is
    63 used to produce a meaningful error-message.
    64 
    6561=== The interface
    6662
     
    171167executes the body xpr . xprs in this context.
    172168
    173 ==== assert*
    174 
    175 <macro>(assert* loc xpr . xprs)</macro>
    176 
    177 checks the expressions xpr . xprs in sequence and raises an exception
    178 for the first failing expression with location property loc and
    179 arguments property the failing expression quoted.
    180 
    181169==== argument-exception
    182170
     
    205193alias to result-exception
    206194
    207 ==== named-lambda
    208 
    209 <macro>(named-lambda (name . args) xpr . xprs)</macro>
    210 
    211 can replace anonymous procedures and can be used recursively.
    212 
    213 ==== <<
    214 
    215 <procedure>(<< x loc .. x? ...)</procedure>
    216 
    217 precondition test:
    218 passes x unchanged only if all predicates x? return #t on it,
    219 raises an argument-exception at location loc, if given,
    220 or '<< otherwise
    221 
    222 ==== >>
    223 
    224 <procedure>(>> x loc .. x? ...)</procedure>
    225 
    226 postcondition test:
    227 passes x unchanged only if all predicates x? return #t on it
    228 raises a result-exception at location loc, if given,
    229 or '>> otherwise
    230 
    231 ==== true?
    232 
    233 <procedure>(true? xpr)</procedure>
    234 
    235 returns always #t
    236 
    237 ==== false?
    238 
    239 <procedure>(false? xpr)</procedure>
    240 
    241 returns always #f
     195=== Outsourced
     196
     197The following routines are outsourced to the checks egg with slightly
     198modified syntax:
     199assert*, <<, <<<, >>, >>>, named-lambda, true?, false?
    242200
    243201=== Examples
     
    246204
    247205(import simple-exceptions)
    248 
    249 ((named-lambda (! n)
    250    (if (zero? n)
    251      1
    252      (* n (! (- n 1)))))
    253  5) ; -> 120
    254 (<< 5 integer? odd? (named-lambda (5<= x) (<= 5 x))) ; -> 5
    255 (condition-case
    256        (>> 5 integer? even?)
    257        ((exn results) #f)) ; -> #f
    258 (<< ((lambda () #f)) boolean?) ; -> #f
    259 
    260 ((<<< 'foo 'x) 5 integer? odd?) ; -> 5
    261 ((<<< 'foo 'x) 5 integer? even?)
    262  ; raises argument exception with location foo and arg-name x
    263 ((>>> 'foo 'x) 5 integer? even?)
    264  ; raises result exception with location foo and result-name x
    265206
    266207(define foo-exn (make-exception "foo-msg"))
     
    315256== Last update
    316257
    317 Jan 15, 2019
     258Feb 02, 2019
    318259
    319260== Author
     
    354295== Version History
    355296
     297; 1.3 : <<< and friends outsourced to checks
    356298; 1.2 : <<< and >>> with additional optional argument
    357299; 1.1 : zero argument case added to << and (<<< loc)
Note: See TracChangeset for help on using the changeset viewer.