Changeset 38202 in project


Ignore:
Timestamp:
02/25/20 17:22:50 (6 weeks ago)
Author:
juergen
Message:

messages docu updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/messages

    r38196 r38202  
    1717case-variant, a small wrapper around bind-case from the bindings module.
    1818Type specialized accessor macros, based on case-variant, are
    19 automatically generated as well.
     19automatically generated as well. So, for example, instead of
     20* case-variant Option opt ....
     21you can simply write
     22* Option-case opt ....
    2023
    2124Note that the arguments of variant constructors can accept zero or
     
    8891==== case-variant
    8992
    90 <macro>(case-variant type obj variant ....)</macro>
     93<macro>(case-variant Type obj variant ....)</macro>
    9194
    9295where each variant is either of the form
     
    100103This one macro replaces in algebraic messages the many accessor
    101104routines by destructuring the variants via pattern matching. It
    102 destructures obj of type depending on its variants, i.e.
     105destructures obj of Type depending on its variants, i.e.
    103106matches the variant-key and the argument-list (variant-key (arg ...))
    104107in sequence and invokes the body .... of the first matching pair.
    105108The else clause serves as catch-all.
     109
     110Note that you can alternatively write
     111
     112<macro>(Type-case obj variant ....)</macro>
     113
     114replacing "Type" with the actual algebraic or abstract type's name.
    106115
    107116==== define-algebraic-type
     
    161170
    162171(define (qux opt)
    163   (case-variant Option opt
     172  (Option-case opt
    164173    (#:none () #f)
    165174    (#:some (arg) arg)))
Note: See TracChangeset for help on using the changeset viewer.