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

[Feature] Static constants for scalar types #709

Open
3 tasks
collinc97 opened this issue Feb 27, 2021 · 3 comments
Open
3 tasks

[Feature] Static constants for scalar types #709

collinc97 opened this issue Feb 27, 2021 · 3 comments
Labels
blocked Blocked. feature A new feature. proposal A proposal for something new.

Comments

@collinc97
Copy link
Collaborator

🚀 Feature

For scalar types: signed and unsigned integers, fields, groups.

Add support for the following methods:

  • min - the smallest value that can be represented by this type
  • max - the largest value that can be represented by this type
  • bits - the size of this type in bits

Motivation

Initially proposed by @damirka here
These methods will be easy to implement after #705 and add great convenience to the developer experience.

Implementation

Proposed syntax 1

Static function methods added to the types.

let a = u8::min();
let b = u8::max();
let c = u8::bits();

Proposed syntax 2

Non-static function methods added to the types.

let a = u8.min();
let b = u8.max();
let c = u8.bits();

We can discuss additional proposed syntaxes below.

@acoglio
Copy link
Collaborator

acoglio commented Feb 27, 2021

I vote for proposal 1 because so we maintain the currently true fact that

  • :: is preceded by a type
  • . is preceded by an expression

@acoglio
Copy link
Collaborator

acoglio commented Feb 27, 2021

I guess another option could be something like

u8::MIN
u8::MAX
u8::BITS

(or their lowercase counterparts) if we independently decide to add static member variables to circuit and other types. These would be constants in this case.

@gluax gluax added the blocked Blocked. label Jul 7, 2021
@gluax
Copy link
Contributor

gluax commented Jul 7, 2021

Blocked by #975.

@d0cd d0cd added proposal A proposal for something new. and removed module-ast labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked. feature A new feature. proposal A proposal for something new.
Projects
None yet
Development

No branches or pull requests

4 participants