question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC: overloading the >> operator for connections

See original GitHub issue

While working on #25 I had some thoughts that could help make circuits more readable. It may be possible to overload the >> operator in a way that turns

vin       += r1[1], r2[1]
r2[2]     += c1[1]
c1[2]     += gnd
led1['a'] += r1[2]
led1['k'] += gnd

into

vin >> r2 >> c1 >> gnd
vin >> r1 >> led1['a']; led1['k'] >> gnd 

Some things to note:

  • It needs to accept Net, Pin and Part (edit: and Bus!)
  • Giving a Part will assume it “flows” into pin 1 and out pin 2 so these are equivalent:
vin >> r1[1]; r1[2] >> gnd
vin >> r1 >> gnd

There may some blocker for making this possible in the way Python works, haven’t investigated fully, but for now it would just be good to know if others agree that it would be desirable.

I don’t think overloading <<, allowing connections in the other direction, would be desirable as it would make for more confusing circuit descriptions.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
xesscorpcommented, Aug 26, 2018

I took another look at this and implemented something using the & operator to make series connections and the | operator to make parallel connections. I think this gets most of what you want except for the bus connections. You can see some examples in the section “Making Parallel and Serial Networks” here.

0reactions
kasbahcommented, Oct 25, 2017

I agree that it bares some experimentation and it would be nice to have warnings or errors on stupid behaviour. An easy one might be to allow it only on components with two pins (i.e. allow vcc >> r1, disallow vcc >> u5 and allow vcc >> u5[1]). Detecting polarized components would be a step above that.

I coming round to your point though, maybe it’s not worth the effort.

Thanks for your help. Right now, it’s just important for me to be able to bounce these ideas off of you and be able to ask stupid questions about your design choices (by the by I still have a stupid question open in #29).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Diameter Overload Control Requirements RFC 7068
Diameter Overload Control Requirements (RFC 7068, November 2013)
Read more >
Operator Overloading RFC is in voting. What are your ... - Reddit
Personally I feel PHP needs this RFC. It adds parity between the built-in features and userland features of the language, because we already ......
Read more >
PHP RFC: User Defined Operator Overloads
This RFC deals with allowing each class to define its own interaction with operators. However, if overloading the operator itself were desired ...
Read more >
0439-cmp-ops-reform - The Rust RFC Book
This RFC proposes a number of design improvements to the cmp and ops modules in ... The comparison traits provide overloads for operators...
Read more >
Is there an way to use Operator Overloading in PHP? [closed]
Well PHP doesn't support Operator Overloading altho I'd recommend looking at the thread bellow to read about possible similar solutions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found