r/Compilers • u/AuraLanguage • May 13 '26
For string/file Apis which one is better Also should i change read_text to read contains(read_text("messages.aura"), "...") vs read_text("messages.aura").contains("...")
3
Upvotes
1
u/TerraCrafterE3 May 13 '26
I think the second one, for the following reason:
If you got something like contains(), you have no idea if it’s for a string, an array or something else.
With string.contains() it is obvious
1
u/un_virus_SDF May 14 '26
You can have both, just use '.' as a operator that pass the lhs as a args to the rhs.
Having smth.fn() is easier to write, but having a simple overloaded function could be easier in some case.
And the readability depends on context, so this way you'll have both
1
u/WittyStick May 14 '26 edited May 14 '26
My preference is to use the forward pipe operator (
|>)Works best if you have partial application (or auto-currying).