Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

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

Open
amstan opened this issue Apr 23, 2020 · 2 comments
Open

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

amstan opened this issue Apr 23, 2020 · 2 comments
Labels
feature request New feature, request or enhancement help wanted Extra attention is needed

Comments

@amstan
Copy link
Contributor

amstan commented Apr 23, 2020

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.

@amstan amstan added feature request New feature, request or enhancement help wanted Extra attention is needed labels Apr 23, 2020
@ghost
Copy link

ghost commented Apr 23, 2020

Maybe define := operand borrowed from Pascal?

@amstan
Copy link
Contributor Author

amstan commented Apr 23, 2020

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request New feature, request or enhancement help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant