{"action":"created","issue":{"url":"https://api.github.com/repos/ceylon/ceylon-sdk/issues/419","labels_url":"https://api.github.com/repos/ceylon/ceylon-sdk/issues/419/labels{/name}","comments_url":"https://api.github.com/repos/ceylon/ceylon-sdk/issues/419/comments","events_url":"https://api.github.com/repos/ceylon/ceylon-sdk/issues/419/events","html_url":"https://github.com/ceylon/ceylon-sdk/issues/419","id":106568405,"number":419,"title":"ceylon.file: Parent of relative paths","user":{"login":"lucaswerkmeister","id":2346599,"avatar_url":"https://avatars.githubusercontent.com/u/2346599?v=3","gravatar_id":"","url":"https://api.github.com/users/lucaswerkmeister","html_url":"https://github.com/lucaswerkmeister","followers_url":"https://api.github.com/users/lucaswerkmeister/followers","following_url":"https://api.github.com/users/lucaswerkmeister/following{/other_user}","gists_url":"https://api.github.com/users/lucaswerkmeister/gists{/gist_id}","starred_url":"https://api.github.com/users/lucaswerkmeister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucaswerkmeister/subscriptions","organizations_url":"https://api.github.com/users/lucaswerkmeister/orgs","repos_url":"https://api.github.com/users/lucaswerkmeister/repos","events_url":"https://api.github.com/users/lucaswerkmeister/events{/privacy}","received_events_url":"https://api.github.com/users/lucaswerkmeister/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-09-15T14:29:33Z","updated_at":"2015-09-15T17:24:10Z","closed_at":null,"body":"When running in `/a/b/c`, what should the following print?\r\n```ceylon\r\nprint(parsePath(\"foo\").parent);\r\nprint(parsePath(\".\").parent);\r\nprint(parsePath(\"..\").parent);\r\n```\r\n\r\n1. **`foo`**, **`.`**, **`..`**: Current behavior. Simple. But violates the assumption that `path.parent.childPath(path.elementPaths.last) == path`.\r\n\r\n2. **`/a/b/c`**, **`/a/b`**, **`/a`**: Correct, but ugly:\r\n - `Path.absolute` is no longer the only `Path` member that depends on system state (current working directory)\r\n - silent transformation from relative to absolute path\r\n\r\n3. **`.`**, **`..`**, **`../..`**: Also correct, though in a way that could be considered lazy or cheaty. But I think it’s better than 2. Composes well with other paths if you normalize afterwards.\r\n\r\n4. **`null`** – change return type to `Path?` (suggested by @quintesse). Also correct, and allows users to detect when the end of a relative path has been reached. However, they’ll have to deal with the `null` possibility all the time (even for paths known to be absolute); I suspect that would be pretty annoying.\r\n\r\nNote: if we go for 3, then\r\n```ceylon\r\nprint(parsePath(\"foo/..\").normalizedPath)\r\n```\r\nshould also print `.` (currently prints empty string)."},"comment":{"url":"https://api.github.com/repos/ceylon/ceylon-sdk/issues/comments/140472565","html_url":"https://github.com/ceylon/ceylon-sdk/issues/419#issuecomment-140472565","issue_url":"https://api.github.com/repos/ceylon/ceylon-sdk/issues/419","id":140472565,"user":{"login":"lucaswerkmeister","id":2346599,"avatar_url":"https://avatars.githubusercontent.com/u/2346599?v=3","gravatar_id":"","url":"https://api.github.com/users/lucaswerkmeister","html_url":"https://github.com/lucaswerkmeister","followers_url":"https://api.github.com/users/lucaswerkmeister/followers","following_url":"https://api.github.com/users/lucaswerkmeister/following{/other_user}","gists_url":"https://api.github.com/users/lucaswerkmeister/gists{/gist_id}","starred_url":"https://api.github.com/users/lucaswerkmeister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucaswerkmeister/subscriptions","organizations_url":"https://api.github.com/users/lucaswerkmeister/orgs","repos_url":"https://api.github.com/users/lucaswerkmeister/repos","events_url":"https://api.github.com/users/lucaswerkmeister/events{/privacy}","received_events_url":"https://api.github.com/users/lucaswerkmeister/received_events","type":"User","site_admin":false},"created_at":"2015-09-15T17:24:10Z","updated_at":"2015-09-15T17:24:10Z","body":"Good point, not the entire path should be normalized. Perhaps the logic for normalizing a single “transition” could be shared…"}}