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

feat: Lang::intern_symbols #1181

Closed
wants to merge 1 commit into from
Closed

feat: Lang::intern_symbols #1181

wants to merge 1 commit into from

Conversation

arthurpaulino
Copy link
Contributor

@arthurpaulino arthurpaulino commented Feb 28, 2024

  • Add Lang::intern_symbols to facilitate lang installations
  • Use Lang::intern_symbols on the REPL
  • Create an alias for Rc<RefCell<State>> and use it
  • Rewrite some functions to one-liners

@arthurpaulino arthurpaulino requested review from a team as code owners February 28, 2024 16:35
@arthurpaulino arthurpaulino force-pushed the ap/lang-interning branch 2 times, most recently from 32a96e3 to 666fa41 Compare March 1, 2024 18:49
* Add `Lang::intern_symbols` to facilitate lang installations
* Use `Lang::intern_symbols` on the REPL
* Create an alias for `Rc<RefCell<State>>` and use it
* Rewrite some functions to one-liners
pub fn intern_symbol(
&mut self,
symbol: &Symbol,
create_unknown_packges: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

typo, should create_unknown_packages.

Comment on lines +140 to +142
pub fn intern_symbol(
&mut self,
symbol: &Symbol,
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 okay, although it points to a weirdness — which is that symbols should usually be interned. So it's a bit funny to pass a symbol to a function meant to intern it. We should try to work toward a world where the default is for symbols to be interned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because of our API to create symbols from strings like ".lurk.foo" out of thin air. It was removed on the mega pr but was reintroduced later on with the help of the symbol parser

pub fn mk_lang<F: LurkField>(state: &StateRcCell) -> Lang<F, TrieCoproc<F>> {
let mut lang = Lang::new();
install(state, &mut lang);
lang
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 a bit of a weird public function. I would normally expect that one would want to build Langs with a number of different coprocessors, composed with something like install. In a world where that's possible, which we target, a function like this would be little more than a convenience for testing, in most cases. What about putting this in the test module or something? I'm a little wary of adding it to the public API since that might create confusion about what is sensible.

Copy link
Contributor

@porcuquine porcuquine left a comment

Choose a reason for hiding this comment

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

I would rather see mk_lang be in the test module, but this all seems basically fine.

@arthurpaulino
Copy link
Contributor Author

Closing in favor of #1189, which moves us closer to where we want to be

@arthurpaulino arthurpaulino deleted the ap/lang-interning branch March 6, 2024 15:00
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.

2 participants