fuzion
fuzion copied to clipboard
hide specific apis?
An example:
# create string from the given utf8 bytes
#
public type.from_bytes(utf8_bytes Sequence u8) String =>
ref : String is
public redef utf8 Sequence u8 := utf8_bytes.as_array_backed
# create string from the given codepoints
#
public type.from_codepoints(codepoints Sequence codepoint) String =>
String.from_bytes (codepoints.flat_map (.utf8))
# create string from the given data
#
# where data might either be utf8 bytes or codepoints
#
public type.from(data choice (Sequence u8) (Sequence codepoint)) String =>
match data
bytes Sequence u8 => String.from_bytes bytes
codepoints Sequence codepoint => String.from_codepoints codepoints
Here we could set visibility of from_codepoints, from_bytes to private, exposing only from.
Upside would be that the API surface is smaller and thus possible easier to grasp.
Your opinions on cases like this?
I think this would make sense, maybe we could even delete those APIs.
Somewhat related: It might make sense to use | syntax sugar to improve readability here, maybe like this (hope this works, I think it should ...:-)
public type.from(data Sequence u8
| Sequence codepoint
) String
=>
I don't think we should delete the private APIs, this keeps the implementation of the "unified" from feature clean.