Modular

M

Modular

This server is the home of the MAX and Mojo community. Join us to chat about all things Modular!

Join

questions

community-showcase

Segfault when `Tuple.get()` rebinds

```py fn cmd_unchecked(args: Tuple) raises -> UnixSocket: buf = ListByte buf.size = 4 ...

why does this String init work without len?

buf = InlineArray[UInt8, 640](0)
...
s = String(buf.unsafe_ptr())
buf = InlineArray[UInt8, 640](0)
...
s = String(buf.unsafe_ptr())
...

Global variable support?

Hello! I know there’s an open issue on GitHub for tracking global/file scoped variable support, but is there any high level estimate when it might come? It would helpful to understand if that’s a topic that’s to be broached in the short/mid/long term or if it’s unplanned as of now. A lot of the projects I’m working on would benefit from them. So, I’m curious if this is a “maybe in 6 months” kind of thing or potentially years down the road....

why is this return a copy?

```py @value struct UnixSocket: var address: Optional[UnixAddress] var fd: Int32...

Not sure why these strings are missing the last char

```py buf = InlineArrayUInt8, 32 while True: client = server.accept() read = client.read_into(buf)...

List of references in Mojo

I'm a bit out of the loop with the latest Mojo developments, so I could use some guidance. In Python, creating a list of references is simple: ```python m1 = [1, 2]...

mojo compile is non-deterministic ? (video)

I only call mojo run main.mojo again and again, and - it breaks - it gives a result - it gives another result I can't see where the randomness is coming from, it is certainly not intended...

print breaks code

the following isn't catched by the linter but breaks, what am I doing wrong? ``` from python import Python, PythonObject from memory import memcpy...

List of SIMD bug

The following simple code doesn't work, is this because of memory? I find the documentation is lacking, it only says SIMD are restricted to powers of 2, which I compy with... ``` alias S: Int = 256 alias S2: Int = S*S alias SquareMatrix = SIMD[size=S2]...

alias and os.getenv

Hi I have a question regarding constants and env variable. I was hoping to do something like ```...

How do safe Reference and List work together?

From my understanding Reference is just a pointer in memory with associated lifetime. But I don't understand how the following code doesn't crash ``` var list: List[Int] = List(10,11,12) var element = Reference(list[0]) list.resize(0)...

Fastest way to count trailing zeros from a SIMD[Bool,32]?

The summary says it all. I have a SIMD with 32 bools, and would like to find the first appearance of a True value. Right now I'm doing the following: ...

How to publish on github in these magic times

I'm wondering if there's a recommended way to publish Mojo/Max projects on GitHub , now that we have Magic as the recommended installation tool. Among other questions: * In mojoproject.toml, how should we set platforms = ["osx-arm64", "linux-64"]? * Should we recommend users to use magic shell or magic run? * ......

Error on magic self-update

Failed to fetch packages data ├─▶ error sending request for url (https://dl.modular.com/public/magic/raw/index.json) ├─▶ client error (Connect) ├─▶ dns error: failed to lookup address information: Try again ╰─▶ failed to lookup address information: Try again...

Magic/Mojo on MacOS 12 not supported?

Just starting to play around with Mojo. Following the instructions in the docs on MacOS 12 on an M1 macbook I am getting this error on running magic shell about MacOS 13 being required. I can't find any docs suggesting MacOS 12 is not supported. Googling that error, I can't find anything relevant. So before I go to the trouble of updating the OS I thought I'd ask whether anyone else has experienced this. ``` $ magic shell × The current system has a mismatching virtual package. The project requires '__osx' to be at least version '13.0' but the system has version '12.4'...

Does Mojo implements the Debug Adapter Protocol?

Could we understand that Mojo implements the Debug Adapter Protocol? Meaning, it's created by Microsoft and we can debug Mojo in vscode, so I guess then we could use it for debugging Mojo in other IDEs like nvim (using nvim-dap). Am I right?

Reshape MAX API OP giving error

My code: ``` fn main() raises: dim1 = Dim(2) dim2 = Dim(2)...

Is there a disdain for Rust from the Mojo team?

I read Chris' proposal on naming of provenance. I don't understand why can't we just adopt Rust's convention of using &'a T and &'a mut T instead of going one round of inventing new keywords ref[lifetime] and refmut[lifetime]. Mojo is unique on its own:...

Value Semantics and async code

What does Mojo's value semantics mean for writing asynchronous code? Can Mojo sidestep the problem of coloured functions, or make it easier to write asynchronous code?

Mojo vs Rust memory safety

Does Mojo's value ownership and lifecycle mean that it can compete with Rust for memory safety?
Next