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

Maybe adding lists isn't so hard ..? #19

Open
skx opened this issue Jun 25, 2022 · 1 comment
Open

Maybe adding lists isn't so hard ..? #19

skx opened this issue Jun 25, 2022 · 1 comment
Assignees
Labels
wontfix This will not be worked on

Comments

@skx
Copy link
Owner

skx commented Jun 25, 2022

  • Introduce an Object class
    • We'll have three objects, number, string, and list
      • list will hold Objects so it can contain strings, integers, or other lists.
  • Update the environment package so the variables are now map[string] *Object

Annoyingly at that point we'll almost certainly need to change our function signatures for HostFunction to read:

function func(i *Interpreter, args []*Object) (Object, error)

Once that is done we'll have:

  • The interpreter allowing different types.
  • The built-in functions, such as list, returning those types.

The other complication will be that we'll need to validate types on our primitives, not just argument-counts.

e.g. exit will need to ensure it has "string|number". Similarly the return value of interpreter.Evaluate and interpreter.Eval will need to be *Object,error rather than string,error

So significant churn, but the actual steps are pretty simple.

@skx skx self-assigned this Jun 25, 2022
@skx skx changed the title Maybe adding lists isn't so hard .. Maybe adding lists isn't so hard ..? Jun 25, 2022
@skx skx added the wontfix This will not be worked on label Jul 5, 2022
@skx
Copy link
Owner Author

skx commented Jul 5, 2022

Tagged wontfix because I think the effort involved will be pretty substantial, even if logically the description above shows that it can be done in a series of discrete steps.

The biggest stumbling block will probably be collecting the arguments ahead of calling the function(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant