{"action":"opened","issue":{"url":"https://api.github.com/repos/cabo/cn-cbor/issues/27","labels_url":"https://api.github.com/repos/cabo/cn-cbor/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/cabo/cn-cbor/issues/27/comments","events_url":"https://api.github.com/repos/cabo/cn-cbor/issues/27/events","html_url":"https://github.com/cabo/cn-cbor/issues/27","id":77096219,"number":27,"title":"const behavior makes life difficult","user":{"login":"jimsch","id":4946037,"avatar_url":"https://avatars.githubusercontent.com/u/4946037?v=3","gravatar_id":"","url":"https://api.github.com/users/jimsch","html_url":"https://github.com/jimsch","followers_url":"https://api.github.com/users/jimsch/followers","following_url":"https://api.github.com/users/jimsch/following{/other_user}","gists_url":"https://api.github.com/users/jimsch/gists{/gist_id}","starred_url":"https://api.github.com/users/jimsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimsch/subscriptions","organizations_url":"https://api.github.com/users/jimsch/orgs","repos_url":"https://api.github.com/users/jimsch/repos","events_url":"https://api.github.com/users/jimsch/events{/privacy}","received_events_url":"https://api.github.com/users/jimsch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-16T18:17:58Z","updated_at":"2015-05-16T18:17:58Z","closed_at":null,"body":"The returning of const objects from a number of calls is making life difficult.  It is not clear that this is even the correct behavior.  It makes sense to say that items are const if one is looking at a tree which has been parsed.  But if one is looking at a tree that one is currently building then this is not so clear.\r\n\r\nConsider the following code:\r\n\r\nconst cn_cbor * pRecipients = cn_cbor_mapget_int(cose->m_message.m_cbor, 10);\r\nif (pRecipients == NULL) {\r\n\tcn_cbor * p = cn_cbor_array_create(NULL);\r\n\tcn_cbor_mapput_int(cose->m_message.m_cbor, 10, p, NULL);\r\n}\r\ncn_cbor_array_append(pRecipients, pobj->m_encrypt.m_message.m_cbor, NULL);\r\n\r\nIn this code, I am retrieving an array from the structure I am building, creating the array if it does not already exist, and then appending a new element to the array.  However, the fact that it wants to return a const cbor element means that I need to do a cast someplace which loses the const tag.  It is not clear to me that this is what should be happening.  Rather it might make more sense to have people apply const to locals in their own code when items are retrieved instead."}}