On Tue, Apr 10, 2018 at 1:18 PM, Neil Van Dyke <n...@neilvandyke.org> wrote:
> Good catch; I agree that it would be better if `gzip` returned the target
> path, in all cases.
>
> There is another change I'd make to that signature: currently, arg
> `out-file` is optional, of type `path-string?`, defaulting to
> `(path-add-extensionin-file".gz"#".")`.  In a backward-compatible way, I'd
> instead make it optional with type `(or/c #f path-string?)`,  and defaulting
> to `#f`, with an `#f` value then resulting in
> `(path-add-extensionin-file".gz"#".")` behavior.  That way, code calling
> `gzip` can pass in the "use the default" value.  This pattern becomes more
> useful when there is more than one optional argument (whether or not it uses
> keywords), but it's helpful even with just the one optional argument.  It
> also keeps the signatures in the documentation a little simpler.
>
> This might be getting into the "art" side of API design.  We can come up
> with some good stylistic guidelines for API design, probably including
> guidelines that cover the above, but not comprehensive guidelines.

Aside from I/O, I can't think of too many cases where (void) is the
intuitively correct or most useful return value, but it is extremely
common throughout the built-in Racket functions.  I'm not sure where
you're drawing the lines on 'API design' vs 'comprehensive
guidelines', but I'd sure like it if the guideline "Always return
something useful unless there's a really good reason not to" got
included.


Relatedly, the 'gunzip' function from file/gunzip
(https://docs.racket-lang.org/file/gunzip.html) has this signature:

(gunzip file [output-name-filter]) → void?
  file : path-string?
  output-name-filter : (string? boolean? . -> . path-string?)
   = (lambda (file archive-supplied?) file)

This seems to be incorrect.  The output-name-filter is getting a path?
instead of a string? for its lead argument.  Am I missing something?


>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to