Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indexed-signal fails inside network macro #2

Closed
pdikmann opened this issue Sep 13, 2013 · 2 comments
Closed

indexed-signal fails inside network macro #2

pdikmann opened this issue Sep 13, 2013 · 2 comments

Comments

@pdikmann
Copy link

the network macro does not play nice with indexed-signal:

(define test/not-ok
  (network ()
           [out2 (indexed-signal (lambda (f) 0))]))

(define test/ok
  (let ([what (indexed-signal (lambda (f) 0))])
    (network ()
             [out2 (what)])))

play-signal of test/not-ok results in a contract violation for *:

*: contract violation
  expected: number?
  given: #<network/s>
  argument position: 2nd
  other arguments...:
   32767.0
@jbclements
Copy link
Owner

The short version is that this is a bad error message. The issue here is that the "network" macro implicitly lifts the RHS to a lazy application... unless it looks like a constant, in which case it just gets evaluated. In this case, it's going to lift the application of indexed-signal, which isn't what you want at all. I'm torn between more cleverness--in this case, the macro could see that the arguments aren't other names appearing as LHSes--or less cleverness; making the not-lifted nature explicit.

@pdikmann
Copy link
Author

For what it's worth, I think it's reasonable that only specific commands would work inside a network clause. In hindsight, the documentation is already pretty explicit about it.

a right-hand-side must be a constant, or an application, either of a primitive function or of a network.

In that light, this is the way it's supposed to (and does) work:

(define test/ok2
  (network ()
           [out2 ((indexed-signal (lambda (f) 0)))]))

So, uhm, pardon my dust? :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants