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

Add support for declaring named constants (scalars, vectors, matrices) #60

Closed
3 tasks
Tracked by #77 ...
tohrnii opened this issue Nov 3, 2022 · 2 comments
Closed
3 tasks
Tracked by #77 ...

Comments

@tohrnii
Copy link
Contributor

tohrnii commented Nov 3, 2022

We should add support for constants. The syntax was defined by @bobbinth in the original Constraints Description Language discussion here. Taken directly from @bobbinth's original post:

Constants could be of the following three types:

  • scalars
  • vectors
  • matrices

The constants should be declared in a separate section.

Declaring constants could be done like so:

constants:
  a: 123 // a scalar constant
  b: [1, 2, 3] // a vector constant
  c: [
    [1, 2, 3],
    [4, 5, 6],
  ] // a matrix constant

Referring to vector constants inside expressions could be done with index notation:

let x = b[1]
let y = c[0][2]

Something like this could also be possible:

let x = c[1][1..3] // this sets x to [5, 6]

Other open suggestions by @grjte and @bobbinth to easily distinguish between trace columns and constants:

  • Use CAPITALS for constant names. If we do this, we should decide if we want to show an error to the user or a warning to use correct convention.
  • Another option is to prefix trace columns with a some special symbol.

This task involves making changes to the parser, IR and codegen.

  • parser
  • IR
  • codegen
@tohrnii tohrnii self-assigned this Nov 3, 2022
@tohrnii tohrnii added the v0.2 label Nov 3, 2022
@grjte grjte mentioned this issue Nov 22, 2022
14 tasks
@grjte grjte changed the title Add support for constants Add support for declaring named constants (scalars, vectors, matrices) Nov 22, 2022
@tohrnii
Copy link
Contributor Author

tohrnii commented Dec 2, 2022

We need to add a check for mismatch in the number of columns in rows in a matrix to the IR and throw an error if they are unequal. For eg, the following should throw an error:

A: [[1, 2, 3], [4, 5]]

@tohrnii
Copy link
Contributor Author

tohrnii commented Dec 8, 2022

Closed by #63, #94 and #95.

@tohrnii tohrnii closed this as completed Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant