22 Replies
You can use the return keyword with the ^ move sigil
return socket^
why doesn't the return in
accept
need that?
if I add it, the compiler says it's redundantThe first one is already basically an lval, the second one is an rval because you construct the socket in the expr
It shouldn't mark it as redundant
this is such a footgun
Oh, right, you don't need it on the second one because it is an rval
:)
I have my opinions but it's ultimately one of the various concessions for pythonicity
python doesn't copy structs either
that only makes sense with boxed classes
I agree, and am not a fan of the relatively loose copy semantics but it is at least possible to learn your way around (and is a hill I have already died on to little effect)
yeah I have to disable the constructors and watch what breaks
That's what I've taken to doing--completely nuking implicit copy constructors and combing through the rubble left behind
I think the situation will improve once explicit copy is better supported
I don't see how this impacts python users negatively, the copies will be rare and they would IMO appreciate the education
this is basically sweeping it under the rug
Python users (most programmers, honestly) are not often open to significant disruptions to their intended approach
Rust already steals a lot of that crowd, Haskell another chunk
say
^
did a copy vs transfer, and move was the default
it's a 2 second fix if you get an errorI personally don't like it being a magic char in the first place, but yeah--I personally might have swapped the two if it were my call
and you can say thank you compiler for ensuring I don't do wasteful things
if anything, the python people would go, wait python just yolos this stuff around?
mojo is awesome
I've honestly seen a good chunk of python devs be rather dismayed by being forced to consider it--systems dev folks who want that level of control are a surprisingly rare breed 🤓
I've seen more microbenchmarking from the python crowd that most others
they do care about critical code
when they find out there was a better default they will scratch their heads, like I am
And they aren't rewriting those parts in C?? 😵💫
and presumably you want them to use mojo instead?
I get it though, it's a gray area
@aurelian , there is a video that explains this:
https://www.youtube.com/watch?v=9ag0fPMmYPQ&ab_channel=Modular
Modular
YouTube
Mojo🔥: a deep dive on ownership with Chris Lattner
Learn everything you need to know about ownership in Mojo, a deep dive with Modular CEO Chris Lattner
If you have any questions make sure to join our friendly Discord community: https://modul.ar/discord
If you're ready to get started with Mojo, check out the programming manual and installation guide: https://modul.ar/mojo-get-started
0:00 Moj...
is there a written deep dive on lifetimes?
this video is great btw
There is the manual (which is really good ❤️🔥): https://docs.modular.com/mojo/manual/values/lifetimes
Lifetimes and references | Modular Docs
Working with lifetimes and references.