Skip to content

Implement when-some, if-some, with-open, doseq etc #106

@vemv

Description

@vemv

Context

speced.def is designed with toggleability in mind. One can add or remove speced/(those literal 7 chars) to existing forms written in vanilla Clojure and get desirable properties in exchange.

That proposition is true for defn, defprotocol, let, etc but not for others like if-let, when-some, when-let, if-some, with-open, doseq, binding... basically anything that expects a binding. Also ->, ->>

That limitation was there for no strong reason, simply the latter group is less frequently used and I was inclined to "start small". After time has shown no problems for speced.def's approach, it seems a good idea to expand the offered "speced" forms.

Importantly, this allows a fully automated rewriting from non-speced to speced, using no fine-grained reasoning or noisy (possibly incorrect) manual changes.

Example use case

I want to address reflection warnings in a project that doesn't use speced.def.

I create a PR that simply adds type hints. But for QA purposes, in a separate branch I also add speced/ in all the surrounding forms so that I'm confident that the type hints are veridic.

This adding of speced/ to forms like with-open, binding etc is automated via rewrite-clj.

Task

Create the mentioned speced forms.

I foresee each form's impl would be quite thin, see e.g. let's https://github.com/nedap/speced.def/blob/4d2982a546fb671952f4b3833b854eb3751a6f67/src/nedap/speced/def/impl/let_impl.cljc

Acceptance criteria

The mentioned forms are implemented with the usual test coverage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions