Skip to content

Missing arithmetic operators - #761

Draft
jonasstrehle wants to merge 25 commits into
release/0.0.12from
feat/operator-mul-div
Draft

Missing arithmetic operators #761
jonasstrehle wants to merge 25 commits into
release/0.0.12from
feat/operator-mul-div

Conversation

@jonasstrehle

Copy link
Copy Markdown
Member

…ypes, so now implement them anywhere will be more easy.

…ypes, so now implement them anywhere will be more easy.
@github-actions

github-actions Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Test Results (datex_macros)

14 tests   14 ✅  0s ⏱️
 3 suites   0 💤
 1 files     0 ❌

Results for commit 7ec8247.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Test Results (no_std)

218 tests   218 ✅  6s ⏱️
  4 suites    0 💤
  1 files      0 ❌

Results for commit 7ec8247.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Test Results (std)

233 tests   233 ✅  6s ⏱️
  4 suites    0 💤
  1 files      0 ❌

Results for commit 7ec8247.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Test Results (no_std_full)

806 tests   806 ✅  10s ⏱️
  4 suites    0 💤
  1 files      0 ❌

Results for commit 7ec8247.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Test Results (std_full)

825 tests   825 ✅  11s ⏱️
  4 suites    0 💤
  1 files      0 ❌

Results for commit 7ec8247.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchfeat/operator-mul-div
Testbedubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Upper Boundary
nanoseconds (ns)
(Limit %)
dxb to json/test1.json📈 view plot
🚷 view threshold
54,790.00 ns
(-19.70%)Baseline: 68,228.70 ns
110,877.17 ns
(49.42%)
dxb to json/test2.json📈 view plot
🚷 view threshold
15,634,000.00 ns
(-3.42%)Baseline: 16,187,100.00 ns
31,137,986.22 ns
(50.21%)
dxb to runtime value/test1.json📈 view plot
🚷 view threshold
35,400.00 ns
(-10.97%)Baseline: 39,760.60 ns
63,909.50 ns
(55.39%)
dxb to runtime value/test2.json📈 view plot
🚷 view threshold
9,577,000.00 ns
(-13.09%)Baseline: 11,019,700.00 ns
17,035,511.13 ns
(56.22%)
json to dxb/test1.json📈 view plot
🚷 view threshold
54,938.00 ns
(-86.82%)Baseline: 416,940.80 ns
1,276,323.07 ns
(4.30%)
json to dxb/test2.json📈 view plot
🚷 view threshold
18,137,000.00 ns
(-85.63%)Baseline: 126,231,300.00 ns
365,090,360.46 ns
(4.97%)
json to runtime value datex auto static detection/test1.json📈 view plot
🚷 view threshold
79,459.00 ns
(-81.75%)Baseline: 435,458.10 ns
1,257,780.93 ns
(6.32%)
json to runtime value datex auto static detection/test2.json📈 view plot
🚷 view threshold
28,188,000.00 ns
(-79.24%)Baseline: 135,757,600.00 ns
362,440,556.27 ns
(7.78%)
json to runtime value datex forced static/test1.json📈 view plot
🚷 view threshold
63,945.00 ns
(-84.76%)Baseline: 419,480.70 ns
1,275,110.77 ns
(5.01%)
json to runtime value datex forced static/test2.json📈 view plot
🚷 view threshold
23,394,000.00 ns
(-81.47%)Baseline: 126,245,800.00 ns
374,294,689.83 ns
(6.25%)
json to runtime value datex/test1.json📈 view plot
🚷 view threshold
91,303.00 ns
(-79.53%)Baseline: 445,946.00 ns
1,248,144.03 ns
(7.32%)
json to runtime value datex/test2.json📈 view plot
🚷 view threshold
29,760,000.00 ns
(-78.26%)Baseline: 136,913,300.00 ns
372,400,041.62 ns
(7.99%)
json to runtime value json_syntax/test1.json📈 view plot
🚷 view threshold
9,223.70 ns
(-47.25%)Baseline: 17,487.30 ns
30,151.27 ns
(30.59%)
json to runtime value json_syntax/test2.json📈 view plot
🚷 view threshold
3,353,700.00 ns
(-42.08%)Baseline: 5,790,340.00 ns
9,270,799.74 ns
(36.17%)
json to runtime value serde_json/test1.json📈 view plot
🚷 view threshold
4,266.60 ns
(-26.89%)Baseline: 5,835.67 ns
8,058.23 ns
(52.95%)
json to runtime value serde_json/test2.json📈 view plot
🚷 view threshold
1,334,500.00 ns
(-33.40%)Baseline: 2,003,850.00 ns
2,583,725.29 ns
(51.65%)
runtime init📈 view plot
🚷 view threshold
0.27 ns
(-100.00%)Baseline: 101,757.03 ns
1,033,065.87 ns
(0.00%)
runtime value to dxb/test1.json📈 view plot
🚷 view threshold
3,308.50 ns
(-17.58%)Baseline: 4,014.01 ns
8,296.46 ns
(39.88%)
runtime value to dxb/test2.json📈 view plot
🚷 view threshold
964,500.00 ns
(-10.64%)Baseline: 1,079,335.00 ns
2,314,164.21 ns
(41.68%)
runtime value to json datex/test1.json📈 view plot
🚷 view threshold
58,337.00 ns
(-20.32%)Baseline: 73,210.30 ns
121,363.17 ns
(48.07%)
runtime value to json datex/test2.json📈 view plot
🚷 view threshold
17,188,000.00 ns
(-2.02%)Baseline: 17,541,900.00 ns
34,634,050.54 ns
(49.63%)
runtime value to json json_syntax/test1.json📈 view plot
🚷 view threshold
4,819.70 ns
(-48.88%)Baseline: 9,427.65 ns
15,551.86 ns
(30.99%)
runtime value to json json_syntax/test2.json📈 view plot
🚷 view threshold
2,047,700.00 ns
(-49.06%)Baseline: 4,019,720.00 ns
6,527,691.85 ns
(31.37%)
runtime value to json serde_json/test1.json📈 view plot
🚷 view threshold
1,102.40 ns
(-56.81%)Baseline: 2,552.38 ns
5,203.71 ns
(21.18%)
runtime value to json serde_json/test2.json📈 view plot
🚷 view threshold
386,970.00 ns
(-55.38%)Baseline: 867,309.00 ns
1,813,101.71 ns
(21.34%)
🐰 View full continuous benchmarking report in Bencher

Comment thread crates/datex-core/src/values/core_value.rs Outdated
Comment thread crates/datex-core/src/values/core_value.rs Outdated
@jonasstrehle jonasstrehle added this to the Release 0.0.11 milestone Mar 27, 2026
@jonasstrehle
jonasstrehle marked this pull request as draft March 27, 2026 14:41
Comment thread crates/datex-core/src/values/value.rs Outdated
Comment thread crates/datex-core/src/values/core_values/decimal/mod.rs
Comment thread crates/datex-core/src/values/core_values/decimal/mod.rs
Comment thread crates/datex-core/src/values/core_values/decimal/mod.rs Outdated
@jonasstrehle
jonasstrehle marked this pull request as ready for review March 27, 2026 14:45
@Vasyl-Trefilov

Vasyl-Trefilov commented Mar 27, 2026

Copy link
Copy Markdown
Collaborator

Test (datex-macros) / Test (datex-macros) (pull_request)
this is not my fail, its some macros, I never ever touched it
screenshot_20260327_202409

@Vasyl-Trefilov
Vasyl-Trefilov requested a review from benStre April 21, 2026 15:17
Comment thread crates/datex-core/src/values/core_values/set.rs Outdated
Comment thread crates/datex-core/src/values/core_values/set.rs
Comment thread crates/datex-core/src/values/core_values/set.rs Outdated
Comment thread crates/datex-core/src/values/core_values/set.rs Outdated
Comment thread crates/datex-core/src/values/core_values/set.rs
@@ -1,3 +1,30 @@
//! [`Integer`] is precise number that can be used for very fast and cheep Math operations that doesnt need

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid backticks for linked modules. Prefer [Integer] over [`Integer`]

}

#[test]
fn doc_test() {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename eq. test

}

impl Mul for TypedInteger {
type Output = Option<TypedInteger>;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use wrapped instead, and not return a option but TypedInteger

TypedInteger::I8(v1) => TypedInteger::I8(match rhs {
TypedInteger::I8(v2) => v1.checked_mul(v2)?,
TypedInteger::I16(v2) => {
i8::try_from((v1 as i16).checked_mul(v2)?).ok()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to checked_mul and implement a non fallible wrapped_mul


impl Neg for Value {
impl Mul for Value {
type Output = Result<Value, ValueError>;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be an error

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error where? Or ths microsoft or I am dumb

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impl Mul for Value {
    type Output = Result<Value, ValueError>; // here it should be Value and not Result

as multiplication can never fail, we can transition the Result<X, Y> to X.
Only Rem and Div might fail, as divisions by zero for integers can occur. For decimals we never expect errors for all arithmentic operators.

@@ -61,84 +73,183 @@ pub enum InstructionCode {

To allow for serialization of the new instruction and it's potential payload, it
might be necessary to add a new entry to the `Instruction` enum in the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new entry to either RegularInstruction enum or TypeInstruction enum, not to Instruction enum directly

might be necessary to add a new entry to the `Instruction` enum in the
[`datex-core/src/global/protocol_structures/instructions.rs`](../../src/global/protocol_structures/instructions.rs)
file:
[`/cratesdatex-core/src/global/protocol_structures/instructions.rs`](../../crates/datex-core/src/global/protocol_structures/instructions.rs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crates/datex-core

```

Is, // New instruction for the `is` operator
There are two types of `Instruction`, if your `Data Type` or `Data Structure` produces a runtime value then its a `RegularInstruction` e.g.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The distinction is not completely correct. Both Type Instructions and Regular Instructions can produce "runtime values". The distinction is more between "normal" values and "type space" values.
E.g. when defining a type with

type example = integer | text

the right hand side is represented by type instructions. But when defining a normal variable with

var example = "example";

the right hand side are regular instructions

the [`datex-core/src/compiler/parser.rs`](../../src/compiler/ast_parser) module.
The parser is responsible for converting the sequence of tokens recognized by
the lexer into an Abstract Syntax Tree (AST).
If you want to understand exactly why `push_next_regular(2)` and how does it work you can either look for something that is close for your new syntax, for example you add something like `Array`, then look at `List`, or try to read each function that is used in `InstructionCode` creating to use 100% correct one

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be explained in the guide.
The push_next_regular just indicated how many additional instructions are guaranteed to follow after the current instruction. So e.g. a list with 3 elements will have the LIST instruction followed by at least 3 more instructions resolving to the 3 elements of the list.


and add there instruction how your Syntax must be converted in `ValueContainer`

Again here is `List` example

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also specify the name of the function where this mapping must be added

Token::RightCurly => Some("}"),
Token::LeftAngle => Some("<"),
Token::RightAngle => Some(">"),
Token::SetOpen => Some("<|"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Set will probably not have a custom syntax, it will just be written as Set(...)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% it will not have a custom syntax, I just wanted to try to add something with custom Token, and I know and understand that special Token for Set is not the best idea

@jonasstrehle

Copy link
Copy Markdown
Member Author

is #273 second code block handled properly? @Vasyl-Trefilov

@jonasstrehle

Copy link
Copy Markdown
Member Author

This should be applied on the release/v0.0.13 - I couldn't get it rebased due to the heavy changes that we worked parallel on release/0.0.12. Feel free to include your changes (pick by hand) in this PR and force overrwrite this branch. Then we can merge with release/v0.0.13 @Vasyl-Trefilov

@jonasstrehle
jonasstrehle marked this pull request as draft August 22, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants