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
Problem: define-agent: We always want to define the 'agt symbol #217
Comments
I comment here, but it concerns #216 also. You are right we can clean a little the agent declaration, but I'm not sure to go as far as you describe in #216. I achieve this result to defining an agent (it is a complete file):
I don't think it is possible to get rid of the lambda arguments declaration... Do you have an example were there is argument in a "finish-close like"? |
How about this?: #lang racket
(require fractalide/modules/rkt/rkt-fbp/agent)
(define-agent
#:input '("a" "b")
#:output '("out")
#:fun input output input-array output-array
((define a (recv (input "a")))
(define b (recv (input "b")))
(send (output "out") (nand a b)))) |
feasible, but I don't find it is really "racket style".
|
If you look at the examples given in #216 it seems to be idiomatic racket. @mfelleisen could you weigh in on whether this is idiomatic racket please? (namely the body immediately following the |
Ok, so if I understand correctly, your concern here is that explicit is better than implicit, and it seems non-idiomatic to have I think it should be ok to offer a keyword for overriding them, but allowing them to have their usual names as defaults. After all, we're providing |
my real point is that I didn't achieve to write a macro to provide them implicitly... Otherwise, I think it's ok to be implicit. Here is my actual macro :
But I didn't achieve to incorporate the arguments myself... |
Maybe that's not such a bad idea to make the arguments #:input '("a" "b")
#:output '("out") So one could infer that Shall we try can get higher powers to help us make those arguments implicit. @dmichiels I can't seem to find that macro you posted, this is the nearest one I could find. fractalide/modules/rkt/rkt-fbp/graph.rkt Lines 18 to 26 in 00fcf7f
EDIT: ah I see, you tried to create the macro, but it didn't work, so didn't use it. |
Yes, the macro I posted is a WIP, doesn't work yet. But it allows to build agent as I posted in the second comment of this thread. |
I achieve this :
I will make a PR as soon as I refactor all our nodes. |
Awesome! I'll dig into it again later, have a look at how |
There are several tricksy things about this. One is that adding these symbols in the caller's namespace is unhygienic, so Racket works hard to prevent it. The workaround that 'fun' used with datum->syntax and creating the names outside the (syntax) forms is the only way. The other is the keyword arguments. To cleanly pick out the body and the keyword arguments, and not need define-agent-priv, syntax-parse is necessary. Solution: Implement new define-agent, merge define-agent-priv and fun. - Retain 'fun' as basically a noop until it has been removed from the codebase. - Remove #:proc as it is not used anywhere. Closes the discussion in fractalide#217
There are two tricky things about this: - Adding these symbols in the caller's namespace is unhygienic, so Racket works hard to prevent it. The workaround that `fun` used with `datum->syntax` and creating the names outside the `(syntax)` forms is the only way. - The keyword arguments. To cleanly pick out the body and the keyword arguments, and not need `define-agent-priv`, `syntax-parse` is necessary. Solution: Merge `define-agent-priv` and `fun` into new `define-agent`. - Remove `fun` from the codebase. - Remove `#:proc` as it is not used anywhere. Closes the discussion in fractalide#217
There are two tricky things about this: - Adding these symbols in the caller's namespace is unhygienic, so Racket works hard to prevent it. The workaround that `fun` used with `datum->syntax` and creating the names outside the `(syntax)` forms is the only way. - The keyword arguments. To cleanly pick out the body and the keyword arguments, and not need `define-agent-priv`, `syntax-parse` is necessary. Solution: Merge `define-agent-priv` and `fun` into new `define-agent`. - Retain `fun` as a noop and remove it from the codebase in a separate commit. - Remove `#:proc` as it is not used anywhere. Closes the discussion in fractalide#217
We are repeating ourselves with
(define agt (define-agent
, as the agent loader is always looking for theagt
symbol.Solution:
define-agent
or some other form includes the(define agt
bit.The text was updated successfully, but these errors were encountered: