{"action":"opened","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/19508","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/19508/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/19508/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/19508/events","html_url":"https://github.com/JuliaLang/julia/issues/19508","id":193428288,"number":19508,"title":"clarify inner constructor behavior","user":{"login":"ssfrr","id":734386,"avatar_url":"https://avatars.githubusercontent.com/u/734386?v=3","gravatar_id":"","url":"https://api.github.com/users/ssfrr","html_url":"https://github.com/ssfrr","followers_url":"https://api.github.com/users/ssfrr/followers","following_url":"https://api.github.com/users/ssfrr/following{/other_user}","gists_url":"https://api.github.com/users/ssfrr/gists{/gist_id}","starred_url":"https://api.github.com/users/ssfrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssfrr/subscriptions","organizations_url":"https://api.github.com/users/ssfrr/orgs","repos_url":"https://api.github.com/users/ssfrr/repos","events_url":"https://api.github.com/users/ssfrr/events{/privacy}","received_events_url":"https://api.github.com/users/ssfrr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-05T07:25:37Z","updated_at":"2016-12-05T07:25:37Z","closed_at":null,"body":"In the [\"Inner Constructors\" section](http://docs.julialang.org/en/latest/manual/constructors/#inner-constructor-methods) of the manual, it says:\r\n\r\n> The default constructor is equivalent to writing your own inner constructor method that takes all of the object’s fields as parameters (constrained to be of the correct type, if the corresponding field has a type), and passes them to new, returning the resulting object\r\n\r\nWhich I would read to mean that:\r\n\r\n```julia\r\ntype T1\r\n  x::Int64\r\nend\r\n```\r\n\r\nwould be equivalent to:\r\n\r\n```julia\r\ntype T1\r\n  x::Int64\r\n  T1(x::Int64) = new(x)\r\nend\r\n```\r\n\r\nBut right below it gives the above equivalent example as:\r\n\r\n```julia\r\ntype T1\r\n  x::Int64\r\n  T1(x) = new(x)\r\nend\r\n```\r\n\r\nWhich seems to me to imply that `new` calls `convert` on the fields, because non-`Int64` arguments are `convert`ed to `Int64`.\r\n\r\nIn the [\"Types\" section](http://docs.julialang.org/en/latest/manual/types/#composite-types) of the manual it says:\r\n\r\n> Two constructors are generated automatically (these are called default constructors). One accepts any arguments and calls convert() to convert them to the types of the fields, and the other accepts arguments that match the field types exactly.\r\n\r\nWhich I would read to mean that:\r\n\r\n```julia\r\ntype T1\r\n  x::Int64\r\nend\r\n```\r\n\r\nwould be equivalent to:\r\n\r\n```julia\r\ntype T1\r\n  x::Int64\r\n  T1(x::Int64) = new(x)\r\nend\r\n\r\nT1(x) = T1(convert(Int64, x))\r\n```\r\n\r\nIt seems that these two descriptions of the default constructors (either converting in the outer constructor or converting in `new`) would behave identically, but it's confusing that it's described both ways in the manual. Is one of them more correct?"}}
{"actor":{"display_login":"ssfrr"}}