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
Message from discussion RFC reqiure.paths behaviour
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
 
Kris Kowal  
View profile  
 More options May 28 2009, 12:45 pm
From: Kris Kowal <cowbertvon...@gmail.com>
Date: Thu, 28 May 2009 09:45:06 -0700
Local: Thurs, May 28 2009 12:45 pm
Subject: Re: [serverjs] Re: RFC reqiure.paths behaviour

On Thu, May 28, 2009 at 1:24 AM, Hannes Wallnoefer <hann...@gmail.com> wrote:
> I actually like "path" and think "file" and "fileName" have their own
> problem of hinting to the pure file name.

Alright, module.path.

>>> And I'm not quite sure how to build up a ID
>>> for a module that isn't in the search path. Say i have:
>>> my_serverjs_interpreter /opt/my_app/my_app.js
> This is why I think it would be better if require.main contained the
> program path. I think it is safer to assume that the main program has
> a path than a module id, and checking if a module is the main program
> would still be simple:

I think that it's okay to use the absolute path as the id for scripts,
as long as absolute paths are not used as ids within modules.  When
possible, it would be better to reconstruct the id of a module within
the search path, but I haven't done so yet, and I understand that it's
onerous.  It would be troublesome for the require.main to be the path
though for modules that do not have paths.  Also, while Ash Berlin's
idea of using a URI has merit, I would like to leave open the
possibility of a later standard that extends the module identifier
domain to include URL's.  Doing so right now would leave too many open
variables and more discussion than is necessary in the short term.

> if (require.main == module.path) { ... }

> Admitted, this introduces the risk of getting confused by
> non-canonical paths, but I think it would be easy to guarantee that if
> require.main and module.path use non-canonical paths, at least they
> use the same one.

I agree to the extent that for practical purposes (beyond the
specification) that absolute paths are an acceptable strict-superset
of module identifiers, and that URI's would be an acceptable
strict-superset thereof when need arises and the time comes for
carving out that namespace in excruciating detail.

> In Helma NG, the directory containing the main script is added to the
> front of the module search path by default, and the modules directory
> in the helma-ng home directory to the end. Thus, applications
> consisting of a single app directory can be run without worrying about
> the module search path. You only have to set the module search path if
> your application consists of several script repositories, or you're
> using libraries that aren't installed in helma-ng's modules directory.
> I think this is working pretty well for us.

Python does something similar, and I think that it causes problems in
the very long term.  I'd recommend that scripts use relative id's to
refer to neighboring resources instead of top-level id's.  Otherwise
you run into the problem where your application's name space may mask
a module on the top-level identifier space.  For example, if your
application has an "file" module, the standard library's "file" module
would become inaccessible.

Kris Kowal


 
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.