I think newbies are going to be confused by ‘do’ and I wonder about it from a language design standpoint. You don’t want to confuse newbies at this stage of the life of a new language where pretty much everyone is a newbie and you want newbies in order to build a community and critical mass 😉
The documentation for ‘do’ (3.8.3. To do or not to do) says:
There is a very good reason for this construction: in Opa, every function definition (and more generally every value not at toplevel) ends with one value, which is the result of the function — conversely, once we have reached the first value, we have the result of the function, so the function is complete.
It’s the part I bolded above that I wonder about: why is it that after reaching the first value the function is complete? Was ‘do’ introduced in order to avoid things like this that you see in OCaml?:
let _ = (some expression)
What are the alternatives to this use of ‘do’ in Opa’s language design? How else could this have been approached (from a language design standpoint).
There is no straight answer.
dois needed with the current OPA syntax, but we could have chosen another philosophy.For example:
dois needed to know that the function doesn’t end at theDom.transformline, but the next one. As written in the book you quoted: “…once we have reached the first value, we have the result of the function, so the function is complete.”But with a js-like syntax it could have been:
We have already received plenty of feedback and suggestions for the OPA syntax, and we are trying to find the best approach. You can read this article to know more:
Crowdsourcing the OPA syntax
http://dutherenverseauborddelatable.wordpress.com/2011/05/30/crowdsourcing-the-syntax/
Read the comments as well. 😉