How to do recursive structs?
I'm trying to implement a json decoder, but I can't even make a struct that will hold the result. Here is the code I'm trying to run:
```python
from stdlib_extensions.builtins import list, dict, HashableStr
from collections.optional import Optional...
Will Mojo ever support multi variable tuple unpacking?
let a, b = StaticIntTuple[2](1, 2)
let a, b = StaticIntTuple[2](1, 2)
Failed to initialize crashpad
Every time I try to install mojo I get:
Failed to initialize Crashpad. Crash reporting will not be available. Cause: while locating crashpad handler: unable to locate crashpad handler executable
How to resolve it? I'm on wsl with ubuntu 22.04. Tried on multiple pcs and every time same error....
SDK without modular
Is it going to happen in the nearest future to be able to simply download archieve / executable without need of
modular
CLI?Unsafe pointet to `let` and `alias` values
Is the way to create a pointer to
let
or alias
values?
Pointer.address_of requires value to be only mutable....Copy-and-Patch compilation in Mojo
Python is going to implement copy-and-patch compilation in 3.13 (https://fredrikbk.com/publications/copy-and-patch.pdf). It seems to be faster and aims to greatly reduce startup time over LLVM -O0. What is Mojo approach to that? Could it be applied somehow or benefits using that are not as high?
Tutorial / Example of targetting GPU with llvm_instrinsic or __mlir_op etc?
Does anyone know of any resources (other than https://docs.modular.com/mojo/notebooks/BoolMLIR.html#adding-functionality-with-mlir), that show examples or methodology behind targetting the GPU for Mojo code?
Jupyter - Import Custom Mojo Modules?
How can we import and use a custom Mojo module from a Jupyter notebook? I added details of what I've tried so far by replying to an existing post started by @hogepodge. Thanks!
Here's a link to that post: https://discord.com/channels/1087530497313357884/1119100298456215572/1198684128091058198...
Segmentation Fault, Got Object when returning a Float
mojo test.🔥
/mnt/d/Projects/QUk.YW5k.TUw/Cartoonify/test.🔥:18:32: error: cannot implicitly convert 'object' value to 'FloatLiteral' in assignment
pi = monte_carlo_simulation(10)
~~~~^~
mojo: error: failed to parse the provided Mojo...
Rewrite Mojo in Mojo
If Mojo will mature, would it be posible / reasonable to rewrite parts of its compiler (or whole compiler) in Mojo? It could lead to greater possibilities and maintainability in long term
Access Command Line arguments
How Can I access Command line arguments in mojo like we do in python using sys:
...
import sys
print(sys.argv[1])
import sys
print(sys.argv[1])
Struct to/from json
Is it possible to serialize a struct to json format and deserialize it back to struct?
use of unknown declaration 'Python'
I get the following error message when writing a line of Code i got from Mojo Playground
This is the line:
let py = Python.import_module("bultins")
...how to use the gather function
Standard library contains a gather function which I would like to use, but I can’t figure out how to create a SIMD[DType.address, 4] vector based on different locations in a DTypePointer or another SIMD vector.
Custom decorator
I am currently working on a custom mojo library, and i tried to implement a custom decorator so I could write less code. But while compilation an error ocurred, so I would like to ask:
Is it possible to implement custom decorators in Mojo and if yes, what is the syntax for that ?
Example Code (The code in my project is too long to mention here):
```python
defines a decorator extending a functions applicability from Integers to Vectors...
Handle errors like in Rust
I am aware, that Mojo internally is passing result as tuple containing OK variant and error variant. Due to lack of enums / pattern matching etc. this is not exposed to the user and
try except
is required. If the needed components will be added, is Mojo going to have monad error handling (like in Rust) or always there will be a need to use try except
block?initialise variadiclist with a python tuple
@kapa.ai I have some python code that works on the basis of a file on disk and generates a python tuple 'mytuple' based on that file content. Next I load and run this python code from a mojo file. In the mojo code I want to use 'mytuple' to initialise a variadiclist. Something like: alias a: VariadicList[Int] = mytuple. The intention is to pass 'a' as a compile time parameter to a function fn myfunctiona: VariadicList[Int]
In which situation are IntLiteral, FloatLiteral, StringLiteral useful?
I know those refer to the type use by the compiler, and they mean that they are compile time constant.
But it seems to interfer with the alias/var distinction. The constness isn't really clear here.
It seems to me that those type are just compiler implementation details. If we use
alias
and that the compiler cast automatically IntLiteral to Int, FloatLiteral to Float and StringLiteral to String, we don't loose anything (since those can be used in compile-time with alias
), or am I missing something?...Create 1D array of objects
How can I create a strcut which can create a 1-D array for HuffmanEntry shown in the example.
The copyinit function doesn't allow me to store data and gives the following error:
```...