From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: port-filename and path canonicalization Date: Tue, 20 Apr 2010 11:42:58 +0200 Message-ID: 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 1271756750 30150 80.91.229.12 (20 Apr 2010 09:45:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 20 Apr 2010 09:45:50 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Apr 20 11:45:49 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 1O4A1b-0006PX-KW for guile-devel@m.gmane.org; Tue, 20 Apr 2010 11:45:47 +0200 Original-Received: from localhost ([127.0.0.1]:36548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4A1b-0007Ro-6T for guile-devel@m.gmane.org; Tue, 20 Apr 2010 05:45:47 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O49za-0006r0-Pj for guile-devel@gnu.org; Tue, 20 Apr 2010 05:43:43 -0400 Original-Received: from [140.186.70.92] (port=32805 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O49zY-0006q3-Am for guile-devel@gnu.org; Tue, 20 Apr 2010 05:43:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O49zW-0005s5-E7 for guile-devel@gnu.org; Tue, 20 Apr 2010 05:43:40 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:61450 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O49zW-0005rt-AP; Tue, 20 Apr 2010 05:43:38 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id B0ADCAB491; Tue, 20 Apr 2010 05:43:37 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=noJ3jdNNWVus 8c15FyKrgfo3YRk=; b=t5bTgJQOH4/0ZA3qctpEQVmhfw74cAgQYI9++F346366 xX8BgsJ2ZOFqJ6ZqCBKZ31+Gb7PUprPLUWbuGJgcgOswESrs0Bar3JnUBwYtR96Z /5qGPeppG4XQxydAi3NvCUsc8gUPWTu21krUBUkXPFB2gLzrsUQog3GGYv6AUEo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=nSoD9C 2OZoFdrMxu+pnfGAfaatV8ZVtZZ4PkJJsnxF3MuoVI3/2nKuxW3TwaKR1GNkPAht x6xS/BHSU1mMzbenXde5RNo3Vik229W6JgzGE3uUzp/CC3vC2W31lAFMCVBbq/Aj k10D6JWZnMwmBnDtArMIV+rsr3ZvZBjQ/VyV8= Original-Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id B758AAB48F; Tue, 20 Apr 2010 05:43:35 -0400 (EDT) Original-Received: from unquote (unknown [83.202.100.241]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id E3229AB48E; Tue, 20 Apr 2010 05:43:33 -0400 (EDT) In-Reply-To: <878w8jyr3w.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Tue, 20 Apr 2010 01:12:03 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) X-Pobox-Relay-ID: 30B5F2A2-4C61-11DF-A61E-D033EE7EF46B-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) 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:10266 Archived-At: Hi :) 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 because > 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. I am inclined to agree. A few complications cloud my view, though. 1. While ports do not have anything to do with file names / paths, *file* ports certainly do -- because not only do they use the given path to open the file, they set that path as the port's filename, providing the only means for reverse-mapping ports to filenames (which is the end goal here, reverse-mapping objects to filenames). 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. 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. 4. The application-level code is nastier if it has to canonicalize, because a relative canonicalization 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") 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. When I realized all of that I decided to go with the minimal correct solution, though it is a bit hacky. Applications are still free to do their own thing, as %file-port-name-canonicalization defaults to #f, but the useful 'absolute and 'relative behaviors are more convenient and robust. I'd be happy to have some cleaner solution, though. Do you have any ideas? Cheers, Andy --=20 http://wingolog.org/