file-error and reference condition for (namestring (make-pathname :type "ext"))

Bug #792154 reported by mon_key
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Wishlist
Unassigned

Bug Description

Please provide some documentation of pathname objects "(with no namestring)"
the behaviour is sometimes less than obvious.

*(make-pathname :type "bmp")
; => #<PATHNAME (with no namestring)
; :HOST #<SB-IMPL::UNIX-HOST {91684C1}>
; :DEVICE NIL
; :DIRECTORY NIL
; :NAME NIL
; :TYPE "bmp"
; :VERSION NIL>

The spec says the above is kosher.

,---- 19.1.2 Pathnames as Filenames
|
| The mapping of the pathname components into the concepts peculiar to
| each file system is implementation-defined. There exist conceivable
| pathnames for which there is no mapping to a syntactically valid
| filename in a particular implementation. An implementation may use
| various strategies in an attempt to find a mapping; for example, an
| implementation may quietly truncate filenames that exceed length
| limitations imposed by the underlying file system, or ignore certain
| pathname components for which the file system provides no support. If
| such a mapping cannot be found, an error of type ‘file-error’ is
| signaled.
|
`----

But, in so much as its implementation-defined it would be nice to know
how/when/why.

(namestring (make-pathname :type "bmp"))

Really, why signal a SIMPLE-ERROR around the NAMESTRING callpoint instead of
signaling a FILE-ERROR when MAKE-PATHNAME recieved a :type specifier a its sole
argument?

(namestring (make-pathname :name nil :type nil :version nil))

(namestring (merge-pathnames (make-pathname :type "bmp") (pathname "")))

(merge-pathnames (pathname "") (make-pathname :type "bmp"))

(merge-pathnames (make-pathname :type "bmp") (pathname ""))

(sb-ext:native-namestring (merge-pathnames (make-pathname :type "bmp") (pathname "")))

(sb-ext:native-pathname (make-pathname :directory "" :type "bmp"))

(sb-ext:native-pathname (make-pathname :directory ""))

(pathname-type (make-pathname :type "bmp"))

--
/s_P\

Tags: easy
Revision history for this message
Christophe Rhodes (csr21-cantab) wrote : Re: [Bug 792154] [NEW] document return value/rationale of: (make-pathname :type "ext")

 status wishlist
 done

mon_key <email address hidden> writes:

> Please provide some documentation of pathname objects "(with no namestring)"
> the behaviour is sometimes less than obvious.

Possibly, though the existence of pathnames with no namestrings is a
direct conclusion from the specification, so it's not clear what extra
information can be provided by documenting them. (In general, I don't
think the sbcl manual is the place for resolving every simple confusion
any user has ever had: there are perfectly good introductory CL texts,
some of which even discuss pathnames in some detail).

> Really, why signal a SIMPLE-ERROR around the NAMESTRING callpoint
> instead of signaling a FILE-ERROR when MAKE-PATHNAME recieved a :type
> specifier a its sole argument?

This is easy to answer: because the pathnames that have no namestrings
can be merged with other pathnames.

Christophe

Revision history for this message
Nikodemus Siivola (nikodemus) wrote : Re: document return value/rationale of: (make-pathname :type "ext")

There are two things in this area that /should/ be fixed, though.

1. We currently signal a SIMPLE-ERROR, not a FILE-ERROR -- which would give convenient access to the offending pathname, and is required by the spec.

2. We should make it a reference condition, pointing 19.1.2.

summary: - document return value/rationale of: (make-pathname :type "ext")
+ file-error and reference condition for (namestring (make-pathname :type
+ "ext"))
Changed in sbcl:
importance: Undecided → Wishlist
status: New → Triaged
tags: added: easy
Jan Moringen (scymtym)
Changed in sbcl:
status: Triaged → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.