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

Math Postfix expressions on numbers #5328

Open
ogoffart opened this issue Jun 1, 2024 · 2 comments
Open

Math Postfix expressions on numbers #5328

ogoffart opened this issue Jun 1, 2024 · 2 comments
Labels
a:language-slint Compiler for the .slint language (mO,bF) enhancement New feature or request

Comments

@ogoffart
Copy link
Member

ogoffart commented Jun 1, 2024

We should support for postfix (memeber) functions on number for math expressions:

So we could write things like

foo.clamp(0, 1)
foo.max(bar)
foo.floor()
foo.round()
foo.abs()
foo.sin()
@ogoffart ogoffart added enhancement New feature or request a:language-slint Compiler for the .slint language (mO,bF) labels Jun 1, 2024
@ogoffart
Copy link
Member Author

ogoffart commented Jun 1, 2024

In order to implement this, we need to add lookup to the integer types in this trait implementation:

impl LookupObject for Expression {

Then add a NumberExpression similar to StringExpression in that file.

@WilstonOreo
Copy link
Contributor

WilstonOreo commented Jun 4, 2024

This looks useful, especially for the clamp function!
The clamp function, like min/max could support other types than float/int though, e.g. a duration or length.

Btw: I really like how things in lookup.rs are implemented!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:language-slint Compiler for the .slint language (mO,bF) enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants