Hacker News new | ask | show | jobs
by Kinrany 482 days ago
Is it possible to put the 'producer side' into a 'consumer side' of another wire?

Should ~ be considered part of the type signature? Does `let ~x = y` work as destructuring?

1 comments

> Is it possible to put the 'producer side' into a 'consumer side' of another wire?

Yes; you can take the producer side of an `N32` wire `x` and link it to the consumer side of an `N32` wire `y`; that just means that the value that is sent across `y` will be sent across `x`.

> Should ~ be considered part of the type signature? Does `let ~x = y` work as destructuring?

In `let ~x = y`, the `~` is part of the pattern, and is destructuring, yes. So assuming `y` is some `~N32`, that statement declares a new variable `x`, with no initial value, and whatever the final value of `x` is, that's what passed along the wire. So re: what happens when a variable is assigned more than once, the last assignment wins.