Rephrase the basic words in Mojo to become as follows #1433
Replies: 3 comments 1 reply
-
If you think about it, when we say or use "ref" we can be talking about two things:
Therefore, I would prefer two different syntax forms to represent each concept. Instead of using
this way, the "special" syntax forms are reduced. As a model of what not to do, I hope they don't overload
ughh, that's kind of confusing honestly. And we haven't even used lifetimes yet. So in rust, So I hope that mojo makes it more clear with the distinction between a reference as a type, and as an operator. |
Beta Was this translation helpful? Give feedback.
-
I actually like
For newcomers, concept of reference and pointers already are one level of indirection . If we introduce syntax that's overloaded it becomes much more harder for them as they need to decode multiple levels of syntax and semantics. The one above is clear and lines nicely to the syntax they are already used to, so I think it would be easier for them . May be lifetime should be towards the end as it sometimes can be elided.
|
Beta Was this translation helpful? Give feedback.
-
FWIW, this proposal suggests removing let entirely: #1456 |
Beta Was this translation helpful? Give feedback.
-
I read Chris Lattner's suggestion regarding rephrasing the keywords and the question here is why don't we actually put this suggestion into practice? I mean the keyword (inout) has no real meaning and it confuses any programmer. Let's be honest, what is the purpose of (inout)? Isn't it to create a mutable reference to what? We do not abbreviate a mutable reference to (mutref) because (mutref) is more readable, understandable, and more authentic in literal meaning than (inout). And why do we not rephrase the main word (borrowed) to (ref), as Chris Latner says. Let us take a simple example, but it conveys the meaning in a way. better:
let s: String = "Hello chris"
ref reference_to_string: String = s
Here's another example:
fn function(r1: ref String, r2: mutref String):
pass
fn main():
let s1: String = "Hello"
let s2: String = "chris"
Beta Was this translation helpful? Give feedback.
All reactions