google / pcbdl

PCB Design Language: A programming way to design schematics.
Other
155 stars 23 forks source link

saved_net = Net() ^ R() ^ Net() on one line #25

Open amstan opened 4 years ago

amstan commented 4 years ago

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.

kiavash-at-work commented 4 years ago

Maybe define := operand borrowed from Pascal?

amstan commented 4 years ago

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?