You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently when a contributor wants to add a new feature they sometimes add new concepts and functions that could be inconsistent with the current std.
To fix this problem Mojo could add a new future directory with stubs of how the future std library functions, structs and traits should look like.
For example some core concepts are missing from Mojo like io, crypto, compression algorithms, serialization, etc. I think it's better to design how the std lib should look like before starting implementing this code.
After the std stubs are defined contributors can write the implementation based on what are their needs, without doing any design work.
For example Mojo could add an future/io.mojo file with the following contents (taken from the typeshed python std stubs)
# future/io.mojo# ...classFileIO(RawIOBase, BinaryIO):
mode: str# The type of "name" equals the argument passed in to the constructor,# but that can make FileIO incompatible with other I/O types that assume# "name" is a str. In the future, making FileIO generic might help.
name: Any
def__init__(
self, file: FileDescriptorOrPath, mode: str=..., closefd: bool=..., opener: _Opener |None=...
) -> None: ...@propertydefclosefd(self) -> bool: ...defwrite(self, b: ReadableBuffer, /) -> int: ...defread(self, size: int=-1, /) -> bytes: ...def__enter__(self) -> Self: ...classBytesIO(BufferedIOBase, BinaryIO): # type:ignore[misc]# incompatible definitions of methods in the base classesdef__init__(self, initial_bytes: ReadableBuffer =...) -> None: ...# BytesIO does not contain a "name" field. This workaround is necessary# to allow BytesIO sub-classes to add this field, as it is defined# as a read-only property on IO[].
name: Any
def__enter__(self) -> Self: ...defgetvalue(self) -> bytes: ...defgetbuffer(self) -> memoryview: ...defread1(self, size: int|None=-1, /) -> bytes: ...classBufferedReader(BufferedIOBase, BinaryIO): # type:ignore[misc]# incompatible definitions of methods in the base classesdef__enter__(self) -> Self: ...def__init__(self, raw: RawIOBase, buffer_size: int=...) -> None: ...defpeek(self, size: int=0, /) -> bytes: ...# ...
This workflow separates the std library design and implementation steps. Std design is super important and should not be left to external contributors in my opinion, to keep the mojo std consistent. This also opens up the possibility of discussing API design and take the best parts from Go, Rust and Python, thanks to community knowledge and ideas.
When a contributor wants to add something new and needs one of these functions they can implement it themselves and move the file into the std folder.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently when a contributor wants to add a new feature they sometimes add new concepts and functions that could be inconsistent with the current std.
To fix this problem Mojo could add a new
future
directory with stubs of how the future std library functions, structs and traits should look like.For example some core concepts are missing from Mojo like io, crypto, compression algorithms, serialization, etc. I think it's better to design how the std lib should look like before starting implementing this code.
After the std stubs are defined contributors can write the implementation based on what are their needs, without doing any design work.
For example Mojo could add an
future/io.mojo
file with the following contents (taken from the typeshed python std stubs)This workflow separates the std library design and implementation steps. Std design is super important and should not be left to external contributors in my opinion, to keep the mojo std consistent. This also opens up the possibility of discussing API design and take the best parts from Go, Rust and Python, thanks to community knowledge and ideas.
When a contributor wants to add something new and needs one of these functions they can implement it themselves and move the file into the std folder.
Beta Was this translation helpful? Give feedback.
All reactions