{"action":"created","issue":{"url":"https://api.github.com/repos/keean/zenscript/issues/11","repository_url":"https://api.github.com/repos/keean/zenscript","labels_url":"https://api.github.com/repos/keean/zenscript/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/keean/zenscript/issues/11/comments","events_url":"https://api.github.com/repos/keean/zenscript/issues/11/events","html_url":"https://github.com/keean/zenscript/issues/11","id":178798168,"number":11,"title":"Syntax summary","user":{"login":"shelby3","id":247731,"avatar_url":"https://avatars.githubusercontent.com/u/247731?v=3","gravatar_id":"","url":"https://api.github.com/users/shelby3","html_url":"https://github.com/shelby3","followers_url":"https://api.github.com/users/shelby3/followers","following_url":"https://api.github.com/users/shelby3/following{/other_user}","gists_url":"https://api.github.com/users/shelby3/gists{/gist_id}","starred_url":"https://api.github.com/users/shelby3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shelby3/subscriptions","organizations_url":"https://api.github.com/users/shelby3/orgs","repos_url":"https://api.github.com/users/shelby3/repos","events_url":"https://api.github.com/users/shelby3/events{/privacy}","received_events_url":"https://api.github.com/users/shelby3/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":767,"created_at":"2016-09-23T06:47:56Z","updated_at":"2016-10-26T14:37:33Z","closed_at":null,"body":"I will maintain in this OP a summary of current proposed syntax as I understand it to be. Note this is not authoritative, subject to change, and it may be inaccurate. Please make comments to discuss.\r\n\r\n`: Type` is always optional.\r\n\r\n1. [Sum, Recursive](http://stackoverflow.com/questions/5911267/what-are-sums-and-products-data-structures), [Record](https://github.com/keean/zenscript/issues/1#issuecomment-249349283), and [Product](https://github.com/keean/zenscript/issues/1#issuecomment-249348936) parametrized data type with optional Record member names and optional Record (e.g. `Cons`) and Product (e.g. `MetaData`) names:\r\n\r\n   `data List<T> = MetaData(Nil | Cons{head: T, tail: List<T>}, {meta: Meta<T>})`\r\n\r\n2. Typeclass interface and implementation:\r\n\r\n   ```\r\n   typeclass Name<A<B>, ...>   // or 'pluggable'?; optional <B> for higher-kinds¹?\r\n      method(B): A<B>           // TODO: add default arguments, named arguments?\r\n\r\n   List<A> implements Name\r\n      method(x) => ...\r\n   ```\r\n\r\n3. References:\r\n\r\n   ```\r\n   let x:Type = ...      // final assignment, not re-assignable (same as const in ES5/6)\r\n   var x:Type = ...      // (same as let in ES5/6)\r\n   ```\r\n\r\n4. Functions:\r\n\r\n   Type parameters [do not require declaration](https://github.com/keean/zenscript/issues/6#issuecomment-248742773) `<A,B>`.\r\n\r\n   ```\r\n   someCallback(x:Type y:Type(:Type) => x + y)     //            also  ():Type => x + y\r\n   var f = x:Type y:Type(:Type) => x + y           // not named, also  ():Type => x + y\r\n   f = x:Type y:Type(:Type) => x + y               // not named, also  ():Type => x + y\r\n   let f(x:Type, y:Type):Type => x + y             // named f,   also f():Type => x + y\r\n   let parametrized(x: A, y: B):A|B => x || y\r\n   let parametrizedWhere(x: A, y: B):A|B where ... => x || y\r\n   ```\r\n\r\n   Note that iterator types can be specified for the return value to return a lazy list as a generalized way of implementing generators. The optional `(:Type)` is necessited for [generator functions](https://github.com/keean/zenscript/issues/17). Note the `(x: Type y: Type): Type => x + y` form [is unavailable](https://github.com/keean/zenscript/issues/11#issuecomment-249770741).\r\n\r\n5. [Assignment-as-expression](https://github.com/keean/zenscript/issues/6#issuecomment-248744745):\r\n\r\n   ```\r\n   if ((x = 0))      // force extra parenthesis where expected type is Boolean\r\n   ```\r\n\r\n† Not yet included in the syntax, as would be a premature optimization. May or may not be added.\r\n¹ https://github.com/keean/zenscript/issues/10"},"comment":{"url":"https://api.github.com/repos/keean/zenscript/issues/comments/256367262","html_url":"https://github.com/keean/zenscript/issues/11#issuecomment-256367262","issue_url":"https://api.github.com/repos/keean/zenscript/issues/11","id":256367262,"user":{"login":"shelby3","id":247731,"avatar_url":"https://avatars.githubusercontent.com/u/247731?v=3","gravatar_id":"","url":"https://api.github.com/users/shelby3","html_url":"https://github.com/shelby3","followers_url":"https://api.github.com/users/shelby3/followers","following_url":"https://api.github.com/users/shelby3/following{/other_user}","gists_url":"https://api.github.com/users/shelby3/gists{/gist_id}","starred_url":"https://api.github.com/users/shelby3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shelby3/subscriptions","organizations_url":"https://api.github.com/users/shelby3/orgs","repos_url":"https://api.github.com/users/shelby3/repos","events_url":"https://api.github.com/users/shelby3/events{/privacy}","received_events_url":"https://api.github.com/users/shelby3/received_events","type":"User","site_admin":false},"created_at":"2016-10-26T14:37:33Z","updated_at":"2016-10-26T14:37:33Z","body":"I mentioned this upthread, but I will mention it again, just to make sure you don't disagree.\r\n\r\nWhen the result type is annotated, function definitions will always agree with the format of function type signatures w.r.t. to the arrow and the return type. Also the result type annotation will not be allowed on function definitions which aren't blocks (but an `as` cast can be employed instead).\r\n\r\n```\r\nf(x: Int) => Int\r\n   if (x > 0) x\r\n   else x - 1\r\n\r\nf(x: Int) => if (x > 0) x else x - 1\r\n\r\nf(x: Int) -> store(x) as ()  // cast the result type to unit, because we can't annotate on inline functions\r\n\r\nf(x: Int) -> ()\r\n   if (x > 0) store(x)\r\n```\r\n\r\nThis seems to be much more coherent and consistent.\r\n\r\nNote impure \"functions\" (i.e. imperative procedures) use the non-fat arrow.\r\n\r\n```\r\narrow:\r\n   '->'   // impure procedure; input arguments are implicitly read/write and `const`\r\n   '=>'   // pure function means no side-effects within type system; input arguments are implicitly read-only and `const`\r\n```\r\n\r\nI know [you don't like pure functions](https://github.com/keean/zenscript/issues/4#issuecomment-250945039), but I disagree."}}
{"actor":{"display_login":"shelby3"}}