From: Sam S. <sd...@gn...> - 2011-05-03 15:29:30
|
> * Zach Beane <knpu@knpu.pbz> [2011-05-03 10:41:59 -0400]: > Sam Steingold <sd...@gn...> writes: > >> "foo*" is a valid (although uncommon) pathname on most modern OSes but >> it cannot be handled by clisp easily. >> proposal: user variable *accept-wild-pathname* which will treat wild >> pathname as non-wild in OPEN, DELETE-FILE et al.: > > Some other CLs handle this by interpreting a precding #\\ as a desire to > inhibit processing the following character as a wildcard. Deleting the > file in your example would look like: (delete-file #p"foo\\*"). > > This has the effect that the namestring of the pathname does not map > exactly to the underlying filename. SBCL provides a NATIVE-NAMESTRING > function to get it instead. I think my solution is simpler, cleaner, and more ANSI-compliant. Your solution adds an extra (non-standard, i.e., non-compliant!) quoting rule. Consider this: (let ((*accept-wild-pathname* t)) (dolist (f (directory "foo*")) (print f) (with-open-file (s "foo*") (print (read-line s))))) #P"/.../foo*" "Tue May 3 11:21:32 EDT 2011" Your solution requires me to quote the return values from DIRECTORY so that this would work: (dolist (f (directory "foo*")) (print f) (with-open-file (s "foo*") (print (read-line s)))) It also requires a un-quote function in case I want to pass a pathname from DIRECTORY to an outside program. I think the simplicity wins. BTW, should the strict *ANSI* mode set this to NIL? I think it should, so the name must end with -ANSI* So, it should be *wild-pathnames-ansi*, right? -- Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X 11.0.60900031 http://camera.org http://honestreporting.com http://ffii.org http://www.memritv.org http://memri.org http://dhimmi.com Murphy's Law was probably named after the wrong guy. |