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
(open :direction :probe ...) vs probe-file
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
Peter Seibel  
View profile  
 More options Jan 23 2004, 5:54 pm
Newsgroups: comp.lang.lisp
From: Peter Seibel <pe...@javamonkey.com>
Date: Fri, 23 Jan 2004 22:53:32 GMT
Local: Fri, Jan 23 2004 5:53 pm
Subject: (open :direction :probe ...) vs probe-file
Unless I've missed something, there's not a lot of difference between
(open file :direction :probe) and (probe-file file). Do folks have
particular stylistic preferences? (Or have I missed some distinction?)

-Peter

--
Peter Seibel                                      pe...@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp


 
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.
David Lichteblau  
View profile  
 More options Jan 23 2004, 7:25 pm
Newsgroups: comp.lang.lisp
From: David Lichteblau <dave-usen...@lichteblau.com>
Date: Sat, 24 Jan 2004 01:25:34 +0100
Local: Fri, Jan 23 2004 7:25 pm
Subject: Re: (open :direction :probe ...) vs probe-file

Peter Seibel <pe...@javamonkey.com> writes:
> Unless I've missed something, there's not a lot of difference between
> (open file :direction :probe) and (probe-file file). Do folks have
> particular stylistic preferences? (Or have I missed some distinction?)

OPEN could (must? should?) actually try to open the file for reading.
So there are cases where PROBE-FILE works, but OPEN signals a
"permission denied" error.

 
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.
Paul F. Dietz  
View profile  
 More options Jan 23 2004, 7:26 pm
Newsgroups: comp.lang.lisp
From: "Paul F. Dietz" <di...@dls.net>
Date: Fri, 23 Jan 2004 18:21:50 -0600
Local: Fri, Jan 23 2004 7:21 pm
Subject: Re: (open :direction :probe ...) vs probe-file

Peter Seibel wrote:
> Unless I've missed something, there's not a lot of difference between
> (open file :direction :probe) and (probe-file file). Do folks have
> particular stylistic preferences? (Or have I missed some distinction?)

OPEN can be instructed to create the file if necessary (:if-does-not-exist).

        Paul


 
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.
Peter Seibel  
View profile  
 More options Jan 23 2004, 9:39 pm
Newsgroups: comp.lang.lisp
From: Peter Seibel <pe...@javamonkey.com>
Date: Sat, 24 Jan 2004 02:38:55 GMT
Local: Fri, Jan 23 2004 9:38 pm
Subject: Re: (open :direction :probe ...) vs probe-file
"Paul F. Dietz" <di...@dls.net> writes:

> Peter Seibel wrote:

> > Unless I've missed something, there's not a lot of difference between
> > (open file :direction :probe) and (probe-file file). Do folks have
> > particular stylistic preferences? (Or have I missed some distinction?)

> OPEN can be instructed to create the file if necessary (:if-does-not-exist).

Yeah. I thought of that but you can also do the same thing with
:direction :output and not writing anything. Though maybe :probe is
better because it's clear that you didn't just forget to write
something? (Just thinking out loud.) Thanks though.

-Peter

--
Peter Seibel                                      pe...@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp


 
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.
Thomas F. Burdick  
View profile  
 More options Jan 24 2004, 3:16 am
Newsgroups: comp.lang.lisp
From: t...@famine.OCF.Berkeley.EDU (Thomas F. Burdick)
Date: 24 Jan 2004 00:16:50 -0800
Local: Sat, Jan 24 2004 3:16 am
Subject: Re: (open :direction :probe ...) vs probe-file

Peter Seibel <pe...@javamonkey.com> writes:
> Unless I've missed something, there's not a lot of difference between
> (open file :direction :probe) and (probe-file file). Do folks have
> particular stylistic preferences? (Or have I missed some distinction?)

Ak, I'd consider it aweful style to do something like:

  (let ((existsp (with-open-file (s file :direction :probe) s)))
    ...)

That's just confusing.  PROBE-FILE expresses your intention.
WITH-OPEN-FILE/OPEN expresses a different intention.  Hell, we have
both NULL and NOT, which are the exact same function, but it's
stylistically useful to have both.

--
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                              
   |     ) |                              
  (`-.  '--.)                              
   `. )----'                              


 
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.
Erik Naggum  
View profile  
 More options Jan 24 2004, 5:34 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 24 Jan 2004 10:34:25 +0000
Local: Sat, Jan 24 2004 5:34 am
Subject: Re: (open :direction :probe ...) vs probe-file
* Peter Seibel
| Unless I've missed something, there's not a lot of difference between
| (open file :direction :probe) and (probe-file file).

  Is «file» here intended to be «pathname»?  Note that both OPEN and
  PROBE-FILE accept pathname designators, not just pathnames.  Also,
  they differ remarkably in the type of the return value.

| Do folks have particular stylistic preferences?

  The two functions perform very different functions.  The intersection
  is actually rather uninteresting.  For instance, you may supply OPEN
  with :IF-DOES-NOT-EXIST.  OPEN returns a stream with a specified
  element-type that you should expect to be honored if you pass the same
  stream to a later OPEN call.  (Not that this expectation is satisfied
  everywhere, but at least you can provide the argument explicitly with
  :element-type (stream-element-type <stream>).)

| (Or have I missed some distinction?)

  I wonder if you are fully aware of the factors you chose to ignore in
  order to believe they are so similar.

--
Erik Naggum | Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.


 
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.
Peter Seibel  
View profile  
 More options Jan 24 2004, 9:01 am
Newsgroups: comp.lang.lisp
From: Peter Seibel <pe...@javamonkey.com>
Date: Sat, 24 Jan 2004 14:00:54 GMT
Local: Sat, Jan 24 2004 9:00 am
Subject: Re: (open :direction :probe ...) vs probe-file

Erik Naggum <e...@naggum.no> writes:
> * Peter Seibel
> | Unless I've missed something, there's not a lot of difference between
> | (open file :direction :probe) and (probe-file file).

>   Is «file» here intended to be «pathname»?  Note that both OPEN and
>   PROBE-FILE accept pathname designators, not just pathnames.  Also,
>   they differ remarkably in the type of the return value.

Yes, I should probably have said "filespec" or "pathspec". I realized
that the return type is different. But it doesn't seem there's much
one can (usefully) do with the stream returned by (open :direction
:probe ...) except observe that it is not null and later use it as a
pathname designator. I admit I hadn't thought of using it to carry
around the element-type information for later use.

> | Do folks have particular stylistic preferences?

>   The two functions perform very different functions.  The intersection
>   is actually rather uninteresting.  For instance, you may supply OPEN
>   with :IF-DOES-NOT-EXIST.  OPEN returns a stream with a specified
>   element-type that you should expect to be honored if you pass the same
>   stream to a later OPEN call.  (Not that this expectation is satisfied
>   everywhere, but at least you can provide the argument explicitly with
>   :element-type (stream-element-type <stream>).)

Hmmm. I never realized that passing a stream as a pathname designator
to OPEN *should* convey anything more than the name of the file that
the stream was associated with. I just reread the OPEN dictionary
entry and didn't see anything to suggest that; did I miss it or is it
somewhere else in the spec?

> | (Or have I missed some distinction?)

>   I wonder if you are fully aware of the factors you chose to ignore in
>   order to believe they are so similar.

Well, now I wonder too.

-Peter

--
Peter Seibel                                      pe...@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp


 
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.
Erik Naggum  
View profile  
 More options Jan 24 2004, 9:44 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 24 Jan 2004 14:44:30 +0000
Local: Sat, Jan 24 2004 9:44 am
Subject: Re: (open :direction :probe ...) vs probe-file
* Peter Seibel
| I admit I hadn't thought of using it to carry around the element-type
| information for later use.

  Not only that, it is useful to remember the external-format argument
  to be used to open a particular file.  The pathname is unable to carry
  all this information around.

| I never realized that passing a stream as a pathname designator to
| OPEN *should* convey anything more than the name of the file that the
| stream was associated with. I just reread the OPEN dictionary entry
| and didn't see anything to suggest that; did I miss it or is it
| somewhere else in the spec?

  No, it just falls in the category of my reasonable expectations, which
  may or may not be codified or shared by others.  Now I realize that I
  had written my own open that effectively did

  (open <stream> ... :element-type (stream-element-type <stream>)
                     :external-format (stream-external-format <stream>))

  in addition to figuring out the direction of the stream if :direction
  was not explicitly specified.

--
Erik Naggum | Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.


 
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.
Peter Seibel  
View profile  
 More options Jan 24 2004, 12:45 pm
Newsgroups: comp.lang.lisp
From: Peter Seibel <pe...@javamonkey.com>
Date: Sat, 24 Jan 2004 17:44:31 GMT
Local: Sat, Jan 24 2004 12:44 pm
Subject: Re: (open :direction :probe ...) vs probe-file

So that makes good sense, given that you wrote your own OPEN--I can
see why that would be a reasonable behavior. But it seems to me that
if some implementation's CL:OPEN did that, it would be non-conforming
because the spec does say what those parameters default to and it's
not information derived from the filespec argument. That is, I claim
that this:

  (let ((s (open #p"/tmp/foo.txt" :direction :probe :element-type '(unsigned-byte 8))))
    (with-open-file (in (open s)) (stream-element-type in)))

ought to evaluate to CHARACTER not (UNSIGNED-BYTE 8).[1]

-Peter

[1] Of course in Allegro this gets all messed up because of their
change to OPEN to support simple-streams: the default value for
element-type is (UNSIGNED-BYTE 8) instead of CHARACTER. But even in
Allegro if the :probe stream is given some other type, say
(UNSIGNED-BYTE 16), the :input stream is still element-type
(UNSIGNED-BYTE 8)

--
Peter Seibel                                      pe...@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp


 
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.
End of messages
« Back to Discussions « Newer topic     Older topic »