Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 41 of 41 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nathan Rajlich  
View profile   Translate to Translated (View Original)
 More options Aug 22 2012, 5:10 pm
From: Nathan Rajlich <nat...@tootallnate.net>
Date: Wed, 22 Aug 2012 14:10:42 -0700
Local: Wed, Aug 22 2012 5:10 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?
Checking "err.code" for "ENOENT" is the most cross-platform and
backwards compatible way to check for the existence of the file.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Isaac Schlueter  
View profile  
 More options Aug 22 2012, 5:32 pm
From: Isaac Schlueter <i...@izs.me>
Date: Wed, 22 Aug 2012 14:32:43 -0700
Local: Wed, Aug 22 2012 5:32 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?
Yeah, Jimb, I'm not sure I know what you mean by "undocumented error
code values".  Node does assume some familiarity with Posix error code
values, but that's a very long and well-documented tradition.

Actually, your gist is a perfect example of why fs.exists is a)
unnecessary, and b) almost always the wrong idea.  In the first case,
if the file exists, but is not readable, then the fs.exists() will
return false, and your program will act as if the file is *missing*,
which is incorrect.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jimb Esser  
View profile  
 More options Aug 22 2012, 6:27 pm
From: Jimb Esser <wastel...@gmail.com>
Date: Wed, 22 Aug 2012 15:27:53 -0700 (PDT)
Local: Wed, Aug 22 2012 6:27 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?

I can find no reference in the Node documentation to "ENOENT" other than in
regards to DNS functions, no description at all in the File System
documentation on what the error objects are (other than examples using them
as booleans or opaque types to be displayed or thrown), nothing even saying
an "Error" type has a "code" member you can reliably do anything with.  I
would not call that "well-documented".  Coming from Windows-land, having
never seen "ENOENT" before, I just assumed that was an internal libuv
identifier or something.

At least in any case I tested, if a file exists and is not readable,
fs.exists returns "true", as I'd expect.  There are probably some cases
(perhaps if the file is in a location you do not have access to, as opposed
to the fairly common case of just being unable to access a file) where the
current fs.exists would return "false", but that's just a really good
argument that the current fs.exists should only return false if stat
returned an error *and* that error was "ENOENT" or whichever set of error
codes indicates non-existence, not that the API is flawed.  Abstracting
away exactly which behaviors or error codes indicate "existence" is useful.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan Milon  
View profile   Translate to Translated (View Original)
 More options Aug 22 2012, 6:34 pm
From: Dan Milon <danmi...@gmail.com>
Date: Thu, 23 Aug 2012 01:34:14 +0300
Local: Wed, Aug 22 2012 6:34 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?
Isaac, i am curious why you believe fs.exists should stay as is.
I found your previous mail kind of "autarchic". Some
communication/reasoning will surely make each side understand better the
pros/cons.

danmilon.

On 08/23/2012 12:32 AM, Isaac Schlueter wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Gonzįlez  
View profile  
 More options Aug 22 2012, 6:45 pm
From: Scott Gonzįlez <scott.gonza...@gmail.com>
Date: Wed, 22 Aug 2012 18:45:03 -0400
Local: Wed, Aug 22 2012 6:45 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?

On Wed, Aug 22, 2012 at 6:34 PM, Dan Milon <danmi...@gmail.com> wrote:
> Isaac, i am curious why you believe fs.exists should stay as is.

https://groups.google.com/forum/#!msg/nodejs/oqlT9ZtUZd0/XicWJx6mC4oJ

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stewart Mckinney  
View profile  
 More options Aug 22 2012, 11:30 pm
From: Stewart Mckinney <lordma...@gmail.com>
Date: Wed, 22 Aug 2012 23:30:30 -0400
Local: Wed, Aug 22 2012 11:30 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?

Why not just decorate fs.exists with arguments.caller.length and call it a
day? It seems like there are arguments on both sides here to accept the new
standard and the old tradition. Eventually phasing out the old tradition
has to happen ( especially since you know, not 1.0 or anything here ), but
i'm just curious if there's any resistance to that interim solution right
now. Seems like that could work, and polymorphism is not necessarily a
forsaken tradition in programming.

Also,

Why does GMail think that polymorphism is not a word? Seriously?

On Wed, Aug 22, 2012 at 6:45 PM, Scott Gonzįlez <scott.gonza...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt  
View profile  
 More options Aug 22 2012, 11:32 pm
From: Matt <hel...@gmail.com>
Date: Wed, 22 Aug 2012 23:32:16 -0400
Local: Wed, Aug 22 2012 11:32 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?

In javascript you can't know how many arguments a callback takes. Only how
many arguments were passed to a function.

On Wed, Aug 22, 2012 at 11:30 PM, Stewart Mckinney <lordma...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stewart Mckinney  
View profile  
 More options Aug 22 2012, 11:36 pm
From: Stewart Mckinney <lordma...@gmail.com>
Date: Wed, 22 Aug 2012 23:36:59 -0400
Local: Wed, Aug 22 2012 11:36 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?

Ah, nevermind. Realized why. :/

On Wed, Aug 22, 2012 at 11:30 PM, Stewart Mckinney <lordma...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathan Rajlich  
View profile   Translate to Translated (View Original)
 More options Aug 22 2012, 11:58 pm
From: Nathan Rajlich <nat...@tootallnate.net>
Date: Wed, 22 Aug 2012 20:58:31 -0700
Local: Wed, Aug 22 2012 11:58 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?
callback.length


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathan Rajlich  
View profile   Translate to Translated (View Original)
 More options Aug 22 2012, 11:59 pm
From: Nathan Rajlich <nat...@tootallnate.net>
Date: Wed, 22 Aug 2012 20:59:42 -0700
Local: Wed, Aug 22 2012 11:59 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?
Also, somebody really should turn this thread into a pull request ;)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikeal Rogers  
View profile  
 More options Aug 23 2012, 12:49 am
From: Mikeal Rogers <mikeal.rog...@gmail.com>
Date: Wed, 22 Aug 2012 21:49:31 -0700
Local: Thurs, Aug 23 2012 12:49 am
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?
This suggested gained a lot of +1's so i want to talk about it a moment.

I don't think it's suitable to *remove* APIs that still exist from the docs or hide them from being enumerable.

There are just too many node programs out there now and people who want to understand existing code need to read the documentation for an API that *is still active* should be able to find and view it and to debug that API via test code in the repl which making non-enumerable makes annoying.

This just isn't the grown up way to handle a mistake or a deprecation.

We need to call out in the docs that 1) this exists and is still available 2) it should not be used 3) why it should not be used and links to doing things the "right" way. Pretending it doesn't exist when it still does is like pretending we never made this mistake even though it still works in node. Let's take responsibility for this and do what's best for all of the existing and future users of node.

-Mikeal

On Aug 20, 2012, at August 20, 20128:53 AM, Tim Caswell <t...@creationix.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Isaac Schlueter  
View profile  
 More options Aug 23 2012, 11:12 am
From: Isaac Schlueter <i...@izs.me>
Date: Thu, 23 Aug 2012 08:12:30 -0700
Local: Thurs, Aug 23 2012 11:12 am
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?
Scott Gonzalez posted a good link about deprecation.  I copied it to a
wiki page.  This is the official policy:
https://github.com/joyent/node/wiki/deprecation

I'd accept a pull request that explains the oddness of fs.exists in
the documentation.  Making it non-enumerable or removing it from the
docs is a bad idea, on further consideration.

I'd also accept a pull request that documents all the Posix error
codes, though really, that should probably be part of the libuv
documentation.  (But writing docs for libuv is a much larger pull
request.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rektide  
View profile   Translate to Translated (View Original)
 More options Aug 23 2012, 4:34 pm
From: rektide <rekt...@voodoowarez.com>
Date: Thu, 23 Aug 2012 13:34:24 -0700 (PDT)
Local: Thurs, Aug 23 2012 4:34 pm
Subject: Re: Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?

I would really really appreciate it if Node were to consistently get behind
err being the first param, even when it's nonsensical.

Readline.question could stand being made from answer => void to err,answer
=> void as well.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruno Jouhier  
View profile   Translate to Translated (View Original)
 More options Aug 23 2012, 4:45 pm
From: Bruno Jouhier <bjouh...@gmail.com>
Date: Thu, 23 Aug 2012 13:45:42 -0700 (PDT)
Local: Thurs, Aug 23 2012 4:45 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?

fs: stability 3 (Stable) => Backwards compatibility is guaranteed.

There was an opportunity to fix it when moving it from path to fs. But now
it's too late!

Well, that's just life!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dennis Kehrig  
View profile   Translate to Translated (View Original)
 More options Aug 23 2012, 6:02 pm
From: Dennis Kehrig <mailn...@denniskehrig.de>
Date: Thu, 23 Aug 2012 15:02:25 -0700 (PDT)
Local: Thurs, Aug 23 2012 6:02 pm
Subject: Re: [nodejs] Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?

Hey group,

Bruno Jouhier, 2012-08-23 22:45:

> fs: stability 3 (Stable) => Backwards compatibility is guaranteed.

How about this:

if (callback.length > 1) {
    callback(err, res);

} else {
    callback(res);
}

Would that be okay? Might be an issue if the callback is declared
without parameters and uses the arguments variable instead. With the
code above old code would continue to work, but new code using only the
arguments array would be surprised by only getting one parameter.

Greetings,

Dennis


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mscdex  
View profile   Translate to Translated (View Original)
 More options Aug 23 2012, 6:23 pm
From: mscdex <msc...@gmail.com>
Date: Thu, 23 Aug 2012 15:23:20 -0700 (PDT)
Local: Thurs, Aug 23 2012 6:23 pm
Subject: Re: Why `fs.exists` has signature `(exists)` instead of `(err, exists)` ?
On Aug 23, 4:45 pm, Bruno Jouhier <bjouh...@gmail.com> wrote:

> fs: stability 3 (Stable) => Backwards compatibility is guaranteed.

> There was an opportunity to fix it when moving it from path to fs. But now
> it's too late!

> Well, that's just life!

As previously suggested, we could still add a note to fs.exists'
description to point people to fs.stat and let them know that
fs.exists shouldn't be used (and why) or at least that there can be
gotchas.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »