• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • C
      • Proof-checker-array
      • Soft
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Ethereum
      • Leftist-trees
      • Java
        • Atj
          • Atj-implementation
            • Atj-types
            • Atj-java-primitive-array-model
            • Atj-java-abstract-syntax
              • Jbinop
              • Jmethod
              • Jtype
                • Jtype-case
                  • Jtypep
                  • Jtype-fix
                  • Jtype-equiv
                  • Jtype-count
                  • Jtype-prim
                  • Jtype-class
                  • Jtype-array
                  • Jtype-kind
                • Jfield
                • Jexprs
                • Jliteral
                • Junop
                • Jlocvar
                • Jcunit
                • Jaccess
                • Maybe-jexpr
                • Jparam
                • Jimport
                • Jcinitializer
                • Jresult
                • Jstatems+jblocks
                • Jexpr-get-field
                • Jliteral-long-dec-nouscores
                • Nat-to-dec-chars-theorems
                • Jmethods-to-jcbody-elements
                • Jclasses-to-jcbody-elements
                • Jblock-locvar-final
                • Jblock-locvar
                • Jliteral-int-dec-nouscores
                • Jfields-to-jcbody-elements
                • Jblock-for
                • Jblock-smethod
                • Jblock-imethod
                • Jblock-ifelse
                • Jblock-asg-name
                • Jparam-list->types
                • Jparam-list->names
                • Jexpr-lit-long-dec-nouscores
                • Jexpr-lit-int-dec-nouscores
                • Jexpr-literal-string
                • Jexpr-literal-floating
                • Jexpr-literal-character
                • Jblock-while
                • Jblock-method
                • Jblock-if
                • Jblock-expr
                • Jblock-do
                • Jblock-asg
                • Jexpr-name-list
                • Jblock-throw
                • Jblock-return
                • Jparam-list
                • Jimport-list
                • Jexpr-literal-true
                • Jexpr-literal-null
                • Jexpr-literal-false
                • Jexpr-literal-1
                • Jexpr-literal-0
                • Jclass-list
                • Jblock-continue
                • Jtype-short
                • Jtype-long
                • Jtype-list
                • Jtype-int
                • Jtype-float
                • Jtype-double
                • Jtype-char
                • Jtype-byte
                • Jtype-boolean
                • Jmethod-list
                • Jliteral-list
                • Jfield-list
                • Jblock-list
                • Jblock-break
                • Jclasses+jcmembers
              • Atj-input-processing
              • Atj-java-pretty-printer
              • Atj-code-generation
              • Atj-java-primitives
              • Atj-java-primitive-arrays
              • Atj-type-macros
              • Atj-java-syntax-operations
              • Atj-fn
              • Atj-library-extensions
              • Atj-java-input-types
              • Atj-test-structures
              • Aij-notions
              • Atj-macro-definition
            • Atj-tutorial
          • Aij
          • Language
        • Riscv
        • Taspi
        • Bitcoin
        • Zcash
        • Des
        • X86isa
        • Sha-2
        • Yul
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Axe
        • Poseidon
        • Where-do-i-place-my-book
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Jtype

    Jtype-case

    Case macro for the different kinds of jtype structures.

    This is an ACL2::fty sum-type case macro, typically introduced by fty::defflexsum or fty::deftagsum. It allows you to safely check the type of a jtype structure, or to split into cases based on its type.

    Short Form

    In its short form, jtype-case allows you to safely check the type of a jtype structure. For example:

    (jtype-case x :prim)

    is essentially just a safer alternative to writing:

    (equal (jtype-kind x) :prim)

    Why is using jtype-case safer? When we directly inspect the kind with equal, there is no static checking being done to ensure that, e.g., :prim is a valid kind of jtype structure. That means there is nothing to save you if, later, you change the kind keyword for this type from :prim to something else. It also means you get no help if you just make a typo when writing the :prim symbol. Over the course of developing VL, we found that such issues were very frequent sources of errors!

    Long Form

    In its longer form, jtype-case allows you to split into cases based on the kind of structure you are looking at. A typical example would be:

    (jtype-case x
      :prim ...
      :class ...
      :array ...)

    It is also possible to consolidate ``uninteresting'' cases using :otherwise.

    For convenience, the case macro automatically binds the fields of x for you, as appropriate for each case. That is, in the :prim case, you can use fty::defprod-style foo.bar style accessors for x without having to explicitly add a prim b* binder.