Julia: Rename pwd() to cwd()

Created on 28 Nov 2017  路  8Comments  路  Source: JuliaLang/julia

pwd() doesn't actually print the working directory, it returns it:

julia> a = pwd();

julia> a
"U:\\"
doc

Most helpful comment

Looks like we are happy with pwd

All 8 comments

This isn't a doc issue per se, since the docs are correct:

help?> pwd
search: pwd powermod print_with_color

  pwd() -> AbstractString

  Get the current working directory.

It's just unfortunate that the function is named "print working directory", instead of cwd's "current working directory".

pwd

  • Matlab
  • Ruby

cwd

  • Python
  • Perl

Something else

  • Rust current_dir
  • R getwd

This function was previously named cwd and was renamed as part of a large file API rename. The name pwd was chosen because there's not a broad consensus on what to call this function across programming languages (cwd, pwd, getwd, getcwd). Before that the same function was called getcwd. Empirically, so far the name pwd seems to have generated the least confusion and complaints. It matches Ruby and Matlab which form a maximal agreeing set of languages for this function name in the API comparison spreadsheet linked above in issue #1782.

I would add all UNIX shells to the pwd set in the above. Technically the shell prints the working directory, but that's because printing is how the shell returns things. In general, we have tried to follow the same naming as UNIX shells for file and path operations since that's the interface that by far the largest number of people are familiar with.

Ok, I am satisfied that it was well considered.
I'm just going to have to say to myself Present Working Directory
10 times and get over it

Consider that the POSIX standard is itself inconsistent in a similar way: it defines

  1. The PWD environment variable which "shall represent an absolute pathname of the current working directory" Reference, and

  2. The pwd utility, which "shall write to standard output an absolute pathname of the current working directory". Reference

I like current_dir from rust

Looks like we are happy with pwd

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iamed2 picture iamed2  路  3Comments

i-apellaniz picture i-apellaniz  路  3Comments

musm picture musm  路  3Comments

omus picture omus  路  3Comments

m-j-w picture m-j-w  路  3Comments