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

Question: Why do some primitives not overwrite formals? #103

Open
sebffischer opened this issue Mar 26, 2024 · 5 comments
Open

Question: Why do some primitives not overwrite formals? #103

sebffischer opened this issue Mar 26, 2024 · 5 comments
Labels
meta-good first issue Good for newcomers theme-base Function implementations type-enhancement New feature or request

Comments

@sebffischer
Copy link
Contributor

For example, c() uses the default formals method.

Is this simply not implemented or is there more to it?

@dgkf
Copy link
Owner

dgkf commented Mar 26, 2024

The reason is simple. They were forgotten! formals for primitives were added after these were introduced and I forgot to go back and add them.

@dgkf dgkf added type-enhancement New feature or request meta-good first issue Good for newcomers theme-base Function implementations labels Mar 26, 2024
@dgkf
Copy link
Owner

dgkf commented Mar 28, 2024

Maybe to add a bit more context. One of my personal goals is to make the internals rather easy to contribute to. I've been iteratively cleaning up old primitives with little experiments to make it easier to do things like match arguments, populate default values, handle the call stack - among many other behaviors.

It wasn't so much that they were forgotten, just that a lot of this development starts as an experiment. Instead of re-writing everything with each experiment, I usually start with just a few targeted implementations to stress test an idea before committing to it throughout the whole codebase.

It's safe to say the experiment worked, so it's a good reminder to go back and flesh these all out. Thinking about it now, though... I think they could be made even simpler using something like the r! macro that was first made as an experiment for simplifying tests.

    fn formals(&self) -> ExprList {
        r! { (a = 1, b = 2, ...) }
    }

@sebffischer
Copy link
Contributor Author

I think we don't want to directly use the r! macro, right? At least intuitively, calling into the interpreter from the interpreter feels a bit convoluted.

@dgkf
Copy link
Owner

dgkf commented Apr 5, 2024

Yeah, you're right, probably not exactly r! because it evaluates and returns a result, but maybe something like r_expr! that stops after parsing and just returns the Expr (or ExprList).

    fn formals(&self) -> ExprList {
        r_expr! { (a = 1, b = 2, ...) }
    }

is probably manageable. Not sure if I feel it's specialized enough to just call it formals! or whether it's nice to leave it broad, but naming can be decided (and changed) later.

@sebffischer
Copy link
Contributor Author

I think this will be a good chance to familiarize myself with macros so I would love to give this one a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta-good first issue Good for newcomers theme-base Function implementations type-enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants