sora
sora
MModular
Created by sora on 2/24/2024 in #questions
How to disambiguates the call to `f`?
Consider the following code:
trait A: ...
trait B: ...

@value
struct S(A, B):
...

fn f[ty: A](s: ty): ...
fn f[ty: B](s: ty): ...

fn test():
let s = S()
f(s)
trait A: ...
trait B: ...

@value
struct S(A, B):
...

fn f[ty: A](s: ty): ...
fn f[ty: B](s: ty): ...

fn test():
let s = S()
f(s)
What do I pass to f as the parameter? Named trait instance can be helpful here.
2 replies
MModular
Created by sora on 2/14/2024 in #questions
Mojo `Dict` implementation choice
Why does Mojo has a Dict implementation that is said to be "closely mirrors Python's dict" rather than something like absl::flat_hash_map? The latter makes use of SIMD instructions and can potentially be a breeze to port to a language with first class SIMD. I wouldn't want Mojo to miss the opportunity to make its stdlib SIMD saturated.
6 replies
MModular
Created by sora on 2/10/2024 in #questions
Why is the dtype of `String`'s underlying storage `int8` and not `uint8`?
As title.
5 replies
MModular
Created by sora on 2/10/2024 in #questions
`DynamicVector`, the name
Why is it not called DynamicArray? I find dynamic vector a bit tautological, given the vector terminology (likely) comes from C++, which literally means "dynamic sized array"[ref].
49 replies
MModular
Created by sora on 10/25/2023 in #questions
Should the language server warn about this case?
Consider the following code:
fn f() -> Int:
<body>
fn f() -> Int:
<body>
Mojo language server doesn't produce a type error when body doesn't contain a return. There are cases where this makes sense, like when <body> contains only pass or .... However, for the majority of cases, this clearly won't type check. So, I'm not sure if it's a bug or intended behaviour. FYI, Python language server like pyright produces the following error message:
def f() -> int:
# ^^^ Function with declared return type "int" must return value on all code paths
a = 1
def f() -> int:
# ^^^ Function with declared return type "int" must return value on all code paths
a = 1
13 replies