Skip to content

Constructor overloading #1980

Closed
Closed
@hanw

Description

Do we allow overloading constructor with the same arity but different type for constructor parameters in P4-16? See code below for an example.

#include <core.p4>

enum HashAlgorithm_t {
    CRC16
}

extern Polynomial<W> {
    Polynomial(W w);
}

extern Hash {
    Hash(HashAlgorithm_t algo);
    Hash(Polynomial<_> poly);
    bit<16> get<D>(in D data);
}

struct meta_t {
    bit<16> f0;
}

control ingress(inout meta_t meta) {
    Hash(Polynomial<bit<16>>(16w5678)) hash;
    apply {
        hash.get({meta.f0});
    }
}

Metadata

Assignees

No one assigned

    Labels

    questionThis is a topic requesting clarification.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions