Skip to content

Pair values with metadata? #101

@cscherrer

Description

@cscherrer

For Soss.jl I'm moving toward all MCMC results being in the form of iterators. Currently, sample returns a pair (samples, stats), which is a bit awkward to work with.

It seems like this is a general problem: we have a value we're interested in (here a single sample) that has some metadata associated with it. We don't always want to throw away the metadata, but we don't want it to get in the way.

This seems like the exact problem addressed by MacroTools.jl's @forward macro.

For example, there could be a (maybe general-purpose) Meta struct with

struct Meta{T,S}
    value :: T
    meta  :: S
end

with methods for common functions @forwarded to the .value field. A new method for sample could then return an iterator of Metas. This could be really convenient - the metadata is there is you need it, but stays out of the way for computations.

What do you think?

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