Skip to content

OnInit/CopyInit require dispatching on unbalanced union #32

@jariji

Description

@jariji

I just want to point this out.

init=OnInit(f) is another one of these things like Union{T,Nothing} I'm always complaining about, which I might be calling "unbalanced unions". This instance is much milder than most because it's in the argument rather than the return and OnInit is pretty much only for this purpose.

reduce(op, xs; init=OnInit(f)) doesn't pass an OnInit value to op. Instead it special-cases init values of that type and calls the function inside it. It'll probably be fine, but this isn't really correct. More properly it should be reduce(op, xs; oninit=f) or rejigger the whole init API to require a wrapper reduce(op, xs, Init(0)) | reduce(op, xs, OnInit(f)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions