[Docs] How about merging the manual with the HelloMojo.ipynb ?
Where is the problem?
https://docs.modular.com/mojo/programming-manual.html
What can we do better?
I suggest we could merge the manual with the "HelloMojo.ipynb"
The reasons are:
- They are very similar. Not only they may cost writers excessive time, but confuse readers a little bit as well.
- Without running test, the manual may have some issues. For example, I can not run the example below:
struct MyString:
var data: Pointer[UI8]
# StringRef has a data + length field
def __init__(inout self, input: StringRef):
let data = Pointer[UI8].alloc(input.length+1)
data.memcpy(input.data, input.length)
data[input.length] = 0
self.data = Pointer[UI8](data)
def __del__(owned self):
self.data.free()
The example below seems not quite right if without proper comments:
fn useStrings():
var a: MyString = "hello"
print(a) # Should print "hello"
var b = a # ERROR: MyString doesn't implement __copyinit__
a = "Goodbye"
print(b) # Should print "hello"
print(a) # Should print "Goodbye"
Anything else?
No response
@scottamain I agree with this - we shouldn't have duplicate source of truth here, no rush but would love to know what you think about this.
Yeah I've actually been thinking about this a lot. (FYI, @lucianyao, we created that notebook precisely so we could execute the examples from the manual, so the similarity is by design. It was a late decision with short-term goals, so this document duality is not sustainable.) Solving this (and maintaining it) is more complicated than it might seem, but believe me, it will not be like this forever.
The programming manual is now written as a Jupyter notebook and will be available in the Mojo Playground in the next release. This also means there's a new and much shorter "HelloMojo" notebook.