payload: {"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-sdk-for-c/issues/59","repository_url":"https://api.github.com/repos/Azure/azure-sdk-for-c","labels_url":"https://api.github.com/repos/Azure/azure-sdk-for-c/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-sdk-for-c/issues/59/comments","events_url":"https://api.github.com/repos/Azure/azure-sdk-for-c/issues/59/events","html_url":"https://github.com/Azure/azure-sdk-for-c/issues/59","id":504270912,"node_id":"MDU6SXNzdWU1MDQyNzA5MTI=","number":59,"title":"[Design] AZ_RESULT and simple output values.","user":{"login":"sergey-shandar","id":902339,"node_id":"MDQ6VXNlcjkwMjMzOQ==","avatar_url":"https://avatars2.githubusercontent.com/u/902339?v=4","gravatar_id":"","url":"https://api.github.com/users/sergey-shandar","html_url":"https://github.com/sergey-shandar","followers_url":"https://api.github.com/users/sergey-shandar/followers","following_url":"https://api.github.com/users/sergey-shandar/following{/other_user}","gists_url":"https://api.github.com/users/sergey-shandar/gists{/gist_id}","starred_url":"https://api.github.com/users/sergey-shandar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergey-shandar/subscriptions","organizations_url":"https://api.github.com/users/sergey-shandar/orgs","repos_url":"https://api.github.com/users/sergey-shandar/repos","events_url":"https://api.github.com/users/sergey-shandar/events{/privacy}","received_events_url":"https://api.github.com/users/sergey-shandar/received_events","type":"User","site_admin":false},"labels":[{"id":1603567696,"node_id":"MDU6TGFiZWwxNjAzNTY3Njk2","url":"https://api.github.com/repos/Azure/azure-sdk-for-c/labels/Design","name":"Design","color":"37fc41","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2019-10-08T20:46:53Z","updated_at":"2019-10-09T00:34:13Z","closed_at":null,"author_association":"MEMBER","body":"# Options\r\n\r\n## 1. `az_result` and `az_result_VALUE_TYPE`\r\n\r\n`az_result` can't have non-error (non-negative) values except `AZ_OK`.\r\n\r\n`az_result_VALUE_TYPE` can have non-error values from `VALUE_TYPE`.\r\n\r\nFor example:\r\n\r\n### az_result.h\r\n```c\r\n// it's an error or a byte.\r\ntypedef az_result az_result_byte;\r\n\r\nenum {\r\n  // for compatibility with standard C EOF.\r\n  AZ_ERROR_EOF = AZ_MAKE_ERROR(AZ_C_FACILITY, 0xFFFF);\r\n};\r\n\r\nAZ_STATIC_ASSERT(AZ_ERROR_EOF == EOF);\r\n```\r\n\r\n### az_span.h\r\n\r\n```c\r\naz_result_byte az_span_get(az_span span, size_t i) {\r\n  if (span.size <= i) {\r\n    return AZ_ERROR_EOF;\r\n  }\r\n  return span.begin[i];\r\n}\r\n```\r\n\r\n### az_iter.h\r\n\r\n```c\r\n/**\r\n * Possible results:\r\n * - an error, for example `AZ_ERROR_TIME_OUT` or `AZ_ERROR_EOF`.\r\n * - a value is a byte (0..255).\r\n */\r\naz_result_byte az_iter_current(az_iter const * iter);\r\n```\r\n\r\n## 2. `az_result` and optional types (eg. `az_option_byte`)\r\n\r\n`az_result` can't have non-error (non-negative) values except `AZ_OK`.\r\n\r\nFor example\r\n\r\n### az_option_byte.h\r\n\r\nhttps://en.wikipedia.org/wiki/Option_type\r\n\r\n```c\r\n// `az_option_byte` can't be implicitly cast to `uint8_t` without compiler error/warning.\r\n// It's relatively safe to compare `az_option_byte` and `uint8_t`.  \r\ntypedef int16_t az_option_byte;\r\n\r\nenum {\r\n  AZ_OPTION_NONE = EOF\r\n};\r\n```\r\n\r\n### az_span.h\r\n\r\n```c\r\n/**\r\n * This function never returns an error so we don't need to use `az_result`.\r\n */\r\naz_option_byte az_span_try_get(az_span span, size_t i) {\r\n  if (span.size <= i) {\r\n    return AZ_OPTION_NONE;\r\n  }\r\n  return span.begin[i];\r\n}\r\n\r\naz_result az_span_get(az_span span, size_t i, uint8_t * out) {\r\n  AZ_CONTRACT_ARG_NOT_NULL(out);\r\n\r\n  if (span.size <= i) {\r\n    return AZ_ERROR_OUT_OF_RANGE;\r\n  }\r\n  *out = span.begin[i];\r\n  return AZ_OK;\r\n}\r\n```\r\n\r\n### az_iter.h\r\n\r\n```c\r\n/**\r\n * Possible results:\r\n * - `AZ_OK`, then `*out` is either AZ_OPTION_NONE (EOF, -1) or a byte (0..255).\r\n * - an error, for example `AZ_ERROR_TIME_OUT`\r\n */\r\naz_result az_iter_current(az_iter const * p_iter, az_option_byte * out);\r\n```"},"comment":{"url":"https://api.github.com/repos/Azure/azure-sdk-for-c/issues/comments/539762017","html_url":"https://github.com/Azure/azure-sdk-for-c/issues/59#issuecomment-539762017","issue_url":"https://api.github.com/repos/Azure/azure-sdk-for-c/issues/59","id":539762017,"node_id":"MDEyOklzc3VlQ29tbWVudDUzOTc2MjAxNw==","user":{"login":"barcharcraz","id":1304509,"node_id":"MDQ6VXNlcjEzMDQ1MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/1304509?v=4","gravatar_id":"","url":"https://api.github.com/users/barcharcraz","html_url":"https://github.com/barcharcraz","followers_url":"https://api.github.com/users/barcharcraz/followers","following_url":"https://api.github.com/users/barcharcraz/following{/other_user}","gists_url":"https://api.github.com/users/barcharcraz/gists{/gist_id}","starred_url":"https://api.github.com/users/barcharcraz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barcharcraz/subscriptions","organizations_url":"https://api.github.com/users/barcharcraz/orgs","repos_url":"https://api.github.com/users/barcharcraz/repos","events_url":"https://api.github.com/users/barcharcraz/events{/privacy}","received_events_url":"https://api.github.com/users/barcharcraz/received_events","type":"User","site_admin":false},"created_at":"2019-10-09T00:34:13Z","updated_at":"2019-10-09T00:34:13Z","author_association":"NONE","body":"I still think you need to write it with the out parameters, if we want a fancy functional interface we should deliver that as a wrapper in a functional language.\r\n\r\nAlso, this lacks a third option which is \"az_result can have non-error values but is never used as a channel for the return value\""}}
other: {"actor":{"display_login":"barcharcraz"}}