Re:WASM_of_OCaml
by tome on Monday July 24, 2023 @02:48PM
(#36852599)
Well, if the word order is the most important aspect (as it is to me) then you have to think of another word you can use instead of "of". I know that in my early Haskell programming I was writing `intOfString` where other Haskellers wrote `stringToInt`. I'm a native English speaker so it certainly had nothing to do with French! "Of" just seemed to fit naturally there. Do you think "From" or some other English word would be more natural?
[ Parent
| on HN ]
Re:WASM_of_OCaml
by marcosdumay on Monday July 24, 2023 @03:05PM
(#36852849)
The Haskell culture clearly dictates "i = fromString s".
And as a consequence, Rust has it standardized as "i = from s".
What do you do if you want to disambiguate the return type? I suppose `intFromString` works. I'm not sure what I chose `intOfString`. It's not because I'm French!
Re:WASM_of_OCaml
by marcosdumay on Monday July 24, 2023 @09:02PM
(#36856440)
You would declare the type of the returning value:
(i :: Int) = fromString s
Although once in a while it's useful to make a short synonym for disambiguating the type, x_of_y is certainly not a short synonym, so it's not commonly used.