You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As shown above, we can also use the `@classmethod` and `@property` decorators to define class methods and properties.
178
+
179
+
#### Custom Type Promotion
180
+
181
+
Similar to how an `int` can be automatically upcasted to an `i64`, we also support registering conversion to your custom types. For example:
182
+
183
+
```{code-cell} python
184
+
converter(int, Math, Math)
185
+
converter(str, Math, Math.var)
186
+
187
+
Math(2) + 30 + "x"
188
+
# equal to
189
+
Math(2) + Math(i64(30)) + Math.var(String("x"))
171
190
```
172
191
173
192
### Declarations
@@ -328,7 +347,7 @@ Since it uses a fluent API, static type checkers can verify that the type of the
328
347
329
348
The `(birewrite ...)` command in egglog is syntactic sugar for creating two rewrites, one in each direction. In Python, we can use the `birewrite(expr).to(expr, *when)` function to create two rules that rewrite in each direction.
330
349
331
-
### Using funcitons to define vars
350
+
### Using functions to define vars
332
351
333
352
Instead of defining variables with `vars_`, we can also use functions to define variables. This can be more succinct
334
353
and also will make sure the variables won't be used outside of the scope of the function.
Alongside [the support for builtin `egglog` functionality](./egglog-translation.md), `egglog` also provides functionality to more easily integrate with the Python ecosystem.
0 commit comments