Is there a way to create lists of Strings yet?
I'm working on an implementation of Apache Arrow and it looks like we can't make lists of memory only types.
Screenshot shows the full code but a minimal example is here:
Is there another way to create a list of strings?
![No description](https://cdn.answeroverflow.com/1149994350152011776/image.png)
17 Replies
As a potential workaround, maybe one can interact with the MLIR String Type directly: https://mlir.llvm.org/docs/Dialects/Builtin/#stringattr
Builtin Dialect - MLIR
Multi-Level IR Compiler Framework
Maybe you need to use StringLiteral or StringRef. I'm not really sure about both.
see https://docs.modular.com/mojo/roadmap.html#no-lifetime-tracking-inside-collections - my read is that this isn't possible in a safe way until mojo supports polymorphism
Modular Docs - Mojo🔥 roadmap & sharp edges
A summary of our Mojo plans, including upcoming features and things we need to fix.
And how about a concrete implementation without polymorphism, traits etc.?
Let us forget DRY for a moment, why does so many people think that without traits or polymorphism it will not work? If implemented as concrete functions or higher-order functions as some kind of dispatching, it should work, shouldn't it?
I'm not too familiar with MLIR - do you have an example of doing that in mojo?
well you could do
var x:object = object([])
x.append("hello")
x.append("world")
and to remove it needs a function that rebuild a new array without the one you want to delete,
'object' is a dynamic type. Did you made benchmarks about the performance?
I think because of the dynamic nature, it could be very costly in performance.
it is a workaround yes there is some valgrind benchmark, i will run some time benchmark good idea
i dont know if that link has his place in this public thread so, u can check it out and i remove the message
are we even suppose to use that type @PriNova ? or do you think its only for internals function arguments ?
Done, you earned your fisrt stargazer
nice thank
i dont know if it is only for the function param but its pretty versatile
As function param as generic, Mojo uses 'AnyType'. Maybe this is an alias to 'object'
it seems that it behave like arrays in ruby, js and python where the reference is not mutated its nice
so if you keep the string inside the array, the array act like a pointer if u will
For immutable stuff, you have to look into functional programming approaches, like linked lists, etc. But then you have Monads, Functors etc.
I made a custom one with some of the devs, I’ll link to it.
https://discord.com/channels/1087530497313357884/1146821935112667288/1148339799808299038
This looks promising but there's no way to encode this to binary 😦