Skip to content

902 Attributes, Spec, And Typed Parameters ​

902-attributes-spec-typed-parameters.mc covers typed constructor parameters and spec = [...] attributes. Tutorial first use: 05-dynamic-pins-and-conditions for typed string parameters; this reference also shows unit-typed parameters.

Syntax synopsis:

text
component TYPE_NAME(value::UV.OHM)
{
    spec = [
        resistance = value
    ]
}
bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 90-language-reference/902-attributes-spec-typed-parameters.mc --lib mcode --pass1 --pass2

Source ​

text
// Reference: Attributes, Spec, And Typed Parameters
// Focus: typed constructor parameters and spec attributes.

component REF_RESISTOR(resistance::UV.OHM, voltage::UV.VOLT)
{
    name = "Reference Resistor"
    spec = [
        resistance = resistance
        voltage = voltage
    ]
    package = "0603"

    pins = [
        1 = 1
        2 = 2
    ]
}

module main
{
    DC.SRC PWR(3.3V, 10mA)
    REF_RESISTOR R_LIMIT(330R, 50V)
    LED D_STATUS(2.0V, 5mA)

    PWR.1 -> R_LIMIT -> D_STATUS.A
    D_STATUS.K -> PWR.2
}

MCode Bench is the public face of the MCode stack. Closed capabilities are served through the MCode gateway.