Manuel Saelices
Manuel Saelices
MModular
Created by Sarctiann on 1/2/2025 in #community-showcase
Current NEOVIM config
Installed with :TSInstall mojo
15 replies
MModular
Created by Sarctiann on 1/2/2025 in #community-showcase
Current NEOVIM config
This is my tree-sitter config for Mojo, using Lazy:
{
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPost", "BufNewFile" },
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" },
build = ":TSUpdate",
dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects",
},
opts = function()
return require "plugins.configs.treesitter"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "syntax")
require("nvim-treesitter.configs").setup(opts)
-- use the python highlighter for .mojo files, which are recognized as conf ones
-- vim.treesitter.language.register('python', 'conf')

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.mojo = {
install_info = {
url = "https://github.com/lsh/tree-sitter-mojo", -- local path or git repo
files = {"src/parser.c"}, -- note that some parsers also require src/scanner.c or src/scanner.cc
-- optional entries:
branch = "main", -- default branch in case of git repo if different from master
generate_requires_npm = false, -- if stand-alone parser without npm dependencies
requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
},
filetype = "mojo", -- if filetype does not match the parser name
}

-- Set the comment string for Mojo files
vim.api.nvim_create_autocmd("FileType", {
pattern = "mojo",
callback = function()
vim.bo.commentstring = "# %s"
end,
})
end,
},
{
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPost", "BufNewFile" },
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" },
build = ":TSUpdate",
dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects",
},
opts = function()
return require "plugins.configs.treesitter"
end,
config = function(_, opts)
dofile(vim.g.base46_cache .. "syntax")
require("nvim-treesitter.configs").setup(opts)
-- use the python highlighter for .mojo files, which are recognized as conf ones
-- vim.treesitter.language.register('python', 'conf')

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.mojo = {
install_info = {
url = "https://github.com/lsh/tree-sitter-mojo", -- local path or git repo
files = {"src/parser.c"}, -- note that some parsers also require src/scanner.c or src/scanner.cc
-- optional entries:
branch = "main", -- default branch in case of git repo if different from master
generate_requires_npm = false, -- if stand-alone parser without npm dependencies
requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
},
filetype = "mojo", -- if filetype does not match the parser name
}

-- Set the comment string for Mojo files
vim.api.nvim_create_autocmd("FileType", {
pattern = "mojo",
callback = function()
vim.bo.commentstring = "# %s"
end,
})
end,
},
15 replies
MModular
Created by Manuel Saelices on 12/17/2024 in #questions
Tried the new Max custom_ops examples with my RTX 3050 and using CPU
No description
17 replies
MModular
Created by Manuel Saelices on 12/16/2024 in #questions
cannot return reference iwth incompatible origin
As there is a Drawable trait that does not know the shapes attribute, we cannot just replace ref [self] with ref [self.shapes]
4 replies
MModular
Created by Manuel Saelices on 12/16/2024 in #questions
cannot return reference iwth incompatible origin
This is the whole code snippet:
@value
struct Shape:
var area: Float64


trait Drawable:
fn get_shapes(ref self) -> ref [self] List[Shape]:
...

@value
struct Canvas(Drawable):
var shapes: List[Shape]

fn get_shapes(ref self) -> ref [self] List[Shape]:
return self.shapes

fn total_area(self) -> Float64:
var total: Float64 = 0
for shape in self.shapes:
total += shape[].area
return total

fn main():
var canvas = Canvas(shapes=List[Shape]())

shapes = canvas.get_shapes()
shapes.append(Shape(area=10.5))
print(canvas.total_area())
@value
struct Shape:
var area: Float64


trait Drawable:
fn get_shapes(ref self) -> ref [self] List[Shape]:
...

@value
struct Canvas(Drawable):
var shapes: List[Shape]

fn get_shapes(ref self) -> ref [self] List[Shape]:
return self.shapes

fn total_area(self) -> Float64:
var total: Float64 = 0
for shape in self.shapes:
total += shape[].area
return total

fn main():
var canvas = Canvas(shapes=List[Shape]())

shapes = canvas.get_shapes()
shapes.append(Shape(area=10.5))
print(canvas.total_area())
4 replies
MModular
Created by ivellapillil on 5/15/2024 in #community-showcase
Online book on Mojo
Great new section about associated aliases
45 replies
MModular
Created by Tyler Hillery on 12/4/2024 in #questions
1 Billion nested loop iterations Mojo Implementation - seeking feedback
And will be even faster soon CC/ @Martin Vuyk
67 replies
MModular
Created by Tyler Hillery on 12/4/2024 in #questions
1 Billion nested loop iterations Mojo Implementation - seeking feedback
Also, I would make sure you are using the nightly version, as it's faster than the current stable one
67 replies
MModular
Created by Tyler Hillery on 12/4/2024 in #questions
1 Billion nested loop iterations Mojo Implementation - seeking feedback
Meaning, var a = List[Int, hint_trivial_type=True](capacity=size)
67 replies
MModular
Created by Tyler Hillery on 12/4/2024 in #questions
1 Billion nested loop iterations Mojo Implementation - seeking feedback
Also, you can add hint_trivial_type=True
67 replies
MModular
Created by Tyler Hillery on 12/4/2024 in #questions
1 Billion nested loop iterations Mojo Implementation - seeking feedback
I would change var a = List[Int]() with var a = List[Int](capacity=size) just to prevent an memory allocation on each a.append(0) sentence
67 replies
MModular
Created by Manuel Saelices on 11/28/2024 in #questions
Passing method references to high-order functions
Wow! Good trick!
8 replies
MModular
Created by Manuel Saelices on 11/28/2024 in #questions
Passing method references to high-order functions
Note that comptime, meaning, passing the function as a parameter instead of an argument, is not possible here as we need to instantiate the Foo object
8 replies
MModular
Created by Manuel Saelices on 11/28/2024 in #questions
Passing method references to high-order functions
The alternative fn() -> Int definition of the function param, instead of the fn(Foo) -> Int one does not work either.
8 replies
MModular
Created by Manuel Saelices on 11/28/2024 in #questions
Passing method references to high-order functions
The error I receive is something like this:
error: invalid call to 'high_order_func': argument #0 cannot be converted from unknown overload to an instance of 'fn(Foo) -> Int'; did you mean to instantiate 'fn(Foo) -> Int'?
print(high_order_func(foo.func))
~~~~~~~~~~~~~~~^~~~~~~~~~
error: invalid call to 'high_order_func': argument #0 cannot be converted from unknown overload to an instance of 'fn(Foo) -> Int'; did you mean to instantiate 'fn(Foo) -> Int'?
print(high_order_func(foo.func))
~~~~~~~~~~~~~~~^~~~~~~~~~
8 replies
MModular
Created by gamendez98 on 2/19/2024 in #questions
How long until mojo is production ready(guesstimate)?
I think the "how long until Mojo is production ready" question is hard to answer because it depends on the specific needs of the company or person who wants to use Mojo. For example: * Can you write a non-gpu production-ready isolated Mojo program today? Yes. It may be harder as the stdlib is not complete and the Mojo ecosystem is still pretty small, so you will probably end up writing more code than you expected or importing third-party Python modules. * Will you need to rewrite the production-ready code in the future because of backward incompatible changes? Yes, 100%. The difference with e.g. Python2 -> Python3 migration is that you will have the help of the compiler and most of the work would be making the compiler happy and you will be 95% ready to go. * Can you compile Mojo modules to be called from Python? Not yet.
89 replies
MModular
Created by Juan Casta on 11/17/2024 in #questions
Exploring Mojo for Real-Time AI Voice Call Solutions
Welcome to the Mojo community, Juan Manuel. I am also interested in real-time voice calls backed by AI, and I actually work on a company that provides these kinds of products, but using Python instead of Mojo. In my spare time, I try to play with Mojo, but my approach is just using websockets and rely on the big AI companies underneath. I initially started the mojo-openai-realtime-api repo but I then realized that I don't want to rely on Python websockets but a Mojo alternative, so I started mojo-websockets, but I cannot put a lot of hours per week yet so it's evolving pretty slow.
6 replies
MModular
Created by Helehex on 8/5/2024 in #community-showcase
Thermo
Hopefully you will find this talk interesting: https://www.youtube.com/watch?v=PND2Wpy6U-E
60 replies
MModular
Created by asosoman on 10/16/2024 in #questions
Fastest way to count trailing zeros from a SIMD[Bool,32]?
I don't know if we should allow it directly without bitcast
9 replies
MModular
Created by asosoman on 10/16/2024 in #questions
Fastest way to count trailing zeros from a SIMD[Bool,32]?
No description
9 replies