helgee / RemoteFiles.jl

Download files from the Internet and keep them up-to-date.
Other
49 stars 8 forks source link

Is the macro interface needed? #14

Closed mauro3 closed 3 years ago

mauro3 commented 4 years ago

The macro expansion of @RemoteFile is

julia> @macroexpand  @RemoteFile(somename, "file://~/myfile.txt", file="localname.txt")
:(somename = RemoteFiles.RemoteFile("file://~/myfile.txt"; file = "localname.txt", dir = "..."))

arguably just using

somename = RemoteFile("file://~/myfile.txt"; file = "localname.txt")

would be clearer? (There is the issue of __source__ but that would be solved by dropping that, x-ref: #13)

Similarly for @RemoteFileSet, why not just

rfs = RemoteFileSet("Some description",
  set1 = RemoteFile("file://~/myfile.txt"; file = "localname.txt"),
  set2 = RemoteFile("file://~/myfile.txt"; file = "localname.txt")
  )
helgee commented 4 years ago

I believe getting the source location was the only reason for using macros but I do not really remember.

This would work:

rfs = RemoteFileSet(
    "Some description",
    set1 => RemoteFile("file://~/myfile.txt"; file = "localname.txt"),
    set2 => RemoteFile("file://~/myfile.txt"; file = "localname.txt"),
)
mauro3 commented 4 years ago

The version i posted (using = not =>) actually works. As I'm not using the automatic "source", I just use the non-macro version. Maybe worth to add that to the docs?