{"action":"closed","issue":{"url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/507","labels_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/507/labels{/name}","comments_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/507/comments","events_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/507/events","html_url":"https://github.com/matlab2tikz/matlab2tikz/issues/507","id":53282801,"number":507,"title":"opts_* API problem (in Octave)","user":{"login":"okomarov","id":3731173,"avatar_url":"https://avatars.githubusercontent.com/u/3731173?v=3","gravatar_id":"","url":"https://api.github.com/users/okomarov","html_url":"https://github.com/okomarov","followers_url":"https://api.github.com/users/okomarov/followers","following_url":"https://api.github.com/users/okomarov/following{/other_user}","gists_url":"https://api.github.com/users/okomarov/gists{/gist_id}","starred_url":"https://api.github.com/users/okomarov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okomarov/subscriptions","organizations_url":"https://api.github.com/users/okomarov/orgs","repos_url":"https://api.github.com/users/okomarov/repos","events_url":"https://api.github.com/users/okomarov/events{/privacy}","received_events_url":"https://api.github.com/users/okomarov/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/labels/discussion","name":"discussion","color":"5319e7"},{"url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/labels/octave","name":"octave","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-02T22:32:15Z","updated_at":"2015-03-08T22:02:11Z","closed_at":"2015-03-08T22:02:11Z","body":"The problem arises from:\r\n```matlab\r\nisequal('',[])\r\n```\r\nwhich returns `true` in Matlab and `false` in Octave (reported to Octave bug tracker on http://savannah.gnu.org/bugs/index.php?43918). \r\n\r\nThe following code will only error in Octave, although it shouldn't: \r\n```matlab\r\nopts = opts_new();\r\nopts = opts_add(opts, 'colormap/jet');\r\nopts = opts_add(opts, 'colormap/jet');\r\n```\r\n\r\nThe `opts_add()` checks if the key/value pair already exists and if not then `opts_append()`s it. However, if the value to append is empty (as in the example above), no matter what its type is, the appended value will be `[]`. When we try to add the same empty option a second time, `opts_add()` recognizes the `key` as existing and compares the old value against the new one. This comparison is false in Octave and thus it issues an error. This is because `opts_add()` converts the new empty value to `char` (on line 6), but the old value stored in the `opts` is double.\r\n\r\nI think, in **all** (public) write functions of the `opts_*` API,  we should either enforce the `char()` conversion of the value **OR** `error()` if it is not char. \r\n\r\nI personally prefer the second option (where empty value is converted to `''`) since I prefer to control conversions explicitly. "}}