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

[WIP] Coprocessor with evaluated arguments #428

Closed
wants to merge 2 commits into from

Conversation

gabriel-barrett
Copy link
Contributor

I've modified coprocessors so that it extracts arguments from the environment instead of the argument list (which are unevaluted). So instead of (foo-coproc x y z) you do ((lambda (_x _y _z) foo-coproc) x y z). I've also updated the Trie coprocessor and showed that this strategy works. All that is needed is that we automatically wrap the coprocessors in these lambdas. I'm thinking maybe add a new method to coprocessors to install these expressions correctly

Now, instead of coprocessors taking the arguments from the
s-expression, it will retrieve the arguments from the (dynamic)
environment, meaning they will take evaluated arguments. We have to be
careful to wrap coprocessors around lambdas so that it behaves as
expected.
@gabriel-barrett gabriel-barrett requested review from porcuquine and a team as code owners June 6, 2023 16:06
return IO {
expr: args,
// TODO: instead of `env` put coprocessor symbol
expr: env,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe.

@@ -10,34 +10,29 @@ fn trie_lang() {

install(s, &mut lang);

let expr = "(let ((trie (.lurk.trie.new)))
// TODO wrap .lurk.trie.new, .lurk.trie.lookup and .lurk.trie.insert in lambdas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be handled at the coprocessor level. Having this test case is good because it's an example of what the ux should be like for a coprocessor user (here) and implementer (elsewhere in the Trie implementation, which should not require significant — or ideally any — changes to absorb the corrected/improved coprocessor behavior.


let expr3 = "(.lurk.trie.insert 0x1cc5b90039db85fd519af975afa1de9d2b92960a585a546637b653b115bc3b53 123 456)";
let expr3 = "((lambda (_x _y _z) .lurk.trie.insert) .lurk.trie.new 123 456)";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine as an intermediate example of what the coprocessor 'macroexpansion' should potentially look like. I think when we are done, this should revert back to the code I would like to have written in the first place for the trie test:

(let ((trie (.lurk.trie.new))
  (.lurk.trie.insert trie 123 456))

_ => return None,
}
}
_ => return None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably distinguish between the malformed list case and the case in which the list is shorter than anticipated. Certainly the name 'truncate' suggests that a shorter-than-expected list should be returned whole, rather than as None.

If you look at the implementation of fetch_list, which this morally replaces, you'll see an example of the expected behavior.

In other words, I think this should only return None if the input is malformed up to the first len elements.

@arthurpaulino
Copy link
Contributor

Achieved via LEM

@gabriel-barrett gabriel-barrett deleted the gb/new-trie branch November 22, 2023 16:44
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

Successfully merging this pull request may close these issues.

3 participants