From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: port-filename and path canonicalization Date: Tue, 20 Apr 2010 18:57:07 +0200 Message-ID: <87iq7mrrj0.fsf@gnu.org> References: <878w8jyr3w.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1271783000 5409 80.91.229.12 (20 Apr 2010 17:03:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 20 Apr 2010 17:03:20 +0000 (UTC) Cc: guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Apr 20 19:03:18 2010 connect(): No such file or directory Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O4Gqt-0007hP-J0 for guile-devel@m.gmane.org; Tue, 20 Apr 2010 19:03:13 +0200 Original-Received: from localhost ([127.0.0.1]:40056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4Gqs-0005mR-4X for guile-devel@m.gmane.org; Tue, 20 Apr 2010 13:03:10 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4GlB-0003tN-OK for guile-devel@gnu.org; Tue, 20 Apr 2010 12:57:17 -0400 Original-Received: from [140.186.70.92] (port=59096 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4Gl7-0003rZ-7F for guile-devel@gnu.org; Tue, 20 Apr 2010 12:57:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4Gl5-0004cM-65 for guile-devel@gnu.org; Tue, 20 Apr 2010 12:57:13 -0400 Original-Received: from mail4-relais-sop.national.inria.fr ([192.134.164.105]:36541) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4Gl4-0004bx-WF for guile-devel@gnu.org; Tue, 20 Apr 2010 12:57:11 -0400 X-IronPort-AV: E=Sophos;i="4.52,243,1270418400"; d="scan'208";a="61002418" Original-Received: from laptop-147-210-128-170.labri.fr (HELO nixey) ([147.210.128.170]) by mail4-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 20 Apr 2010 18:57:09 +0200 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 1 =?iso-8859-1?Q?Flor=E9al?= an 218 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: (Andy Wingo's message of "Tue, 20 Apr 2010 11:42:58 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10272 Archived-At: Hi, Andy Wingo writes: > On Tue 20 Apr 2010 01:12, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > >> Andy Wingo writes: >> >>> I recently added a global fluid, %file-port-name-canonicalization, which >>> defaults to #f. But if it's 'absolute, the port name of a file port will >>> be canonicalized to the absolute path; or, if it's 'relative, the port >>> name is the canonical name of the file, relative to the %load-path, or >>> the file name as given otherwise. >>> >>> The intention was to allow the user to control (port-filename P), so >>> that the user could find e.g. the absolute path corresponding to that >>> port at the time that it was made. >> >> My feeling is that ports shouldn=E2=80=99t have to deal with paths becau= se >> that=E2=80=99s a separate concern. The %file-port-name-canonicalization= fluid >> seems like an inelegant hack to me. >> >> When applications have special requirements about paths, then it should >> be up to the application logic to deal with that. IOW, applications are free to do: (open-input-file (canonicalize-path filename)) instead of: (open-input-file filename) And that=E2=80=99s all it takes at the application level. > 2. I think a fluid is still necessary, because a file being > compiled can do an `include' or `include-from-path', or even > `open-input-file' in a macro, and all these cases you would want the > same %file-port-name-canonicalization to take effect. Indeed, this one is tricky. I still think it=E2=80=99s application-specific, though. How about calling= the fluid, say, %compiler-file-name-canonicalization instead? :-) > 3. The only correct time to do a path canonicalization is when the file > is opened, because at another time, you might not be in the same current > directory, so relative paths would resolve incorrectly. Yes. > 4. The application-level code is nastier if it has to canonicalize, > because a relative canonicalization What do you mean by =E2=80=9Crelative canonicalization=E2=80=9D? (I have Glibc=E2=80=99s =E2=80=98canonicalize_file_name ()=E2=80=99 in mind= , which returns an absolute path, so I=E2=80=99m confused.) > cannot in general be passed to open-input-file. For example > > (open-input-file "../../module/ice-9/boot-9.scm") > > is not the same as > > (open-input-file "ice-9/boot-9.scm") Agreed. :-) > So you'd have to do a set-port-filename! on the port, mucking up your > code -- and how would you decide what to set? In N places you'd have to > duplicate fport_canonicalize_filename, and you'd probably have to make > scm_i_relativize_path public. I failed to get the transition at =E2=80=9CSo=E2=80=9D. :-) What does scm_i_relativize_path do? (It lacks a leading comment, hint hint. ;-)) Thanks for taking the time to explain! Ludo=E2=80=99.