pcbdl
pcbdl copied to clipboard
saved_net = Net() ^ R() ^ Net() on one line
Sometimes one wants to write something like this near an MCU:
saved_net_variable = Net("MORE_HERE") ^ R("100") ^ Net("NEARBY_PIN") << mcu.PIN
The idea is that saved_net_variable
(aka Net("MORE_HERE")
) is used in other places in the circuit later on.
The problem is that the ^ operator makes the expression lose the reference to Net("MORE_HERE")`
Then in needs to be rewritten in separate lines:
saved_net_variable = Net("MORE_HERE")
saved_net_variable ^ R("100") ^ Net("NEARBY_PIN") << mcu.PIN
But that's kind of ugly, and both me and Jim don't like it (especially if there's many of them).
The to= argument could have done this on one line, but it's even uglier:
saved_net_variable = Net("MORE_HERE") << R("100", to=(Net("NEARBY_PIN") << mcu.PIN))
Here's a bug to dump thoughts about improving this.
Maybe define :=
operand borrowed from Pascal?
I can't really define a new operand. It needs to already exist in python.
Luckly https://www.python.org/dev/peps/pep-0572/ does introduce it.
So yes, in the future we might be able to type:
(saved_net_variable := Net("MORE_HERE")) ^ R("100") ^ Net("NEARBY_PIN") << mcu.PIN
Toughts?