Re: [racket-users] Re: How to differentiate between files and directories?

2016-07-21 Thread WarGrey Gyoudmon Ju
Maybe you can work with (namespace-mapped-symbols) and
(namespace-variable-value),
All field accessors are procedures with name starts with "struct-name-", no
duplicates in the entire application.

On Fri, Jul 22, 2016 at 3:59 AM, David Storrs 
wrote:

> So there's no way to query the interface of a struct?
>
>
> On Thursday, July 21, 2016, Jon Zeppieri  wrote:
>
>>
>>
>> On Thu, Jul 21, 2016 at 2:44 PM, David Storrs 
>> wrote:
>>>
>>>
>>>
>>> In a related question, is there a way to introspect a struct to find
>>> out what its fields are?
>>>
>>>
>> If you mean the field values: yes, but only if the struct is transparent
>> or prefab or if you have the proper inspector, which you probably do not.
>> You can generally try struct->vector and see if you get anything useful.
>>
>> If you mean the field names: I don't think so; I don't think they exist
>> at runtime.
>>
>> - Jon
>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: How to differentiate between files and directories?

2016-07-21 Thread David Storrs
Okay. Thanks for the help, all.

On Thursday, July 21, 2016, Jon Zeppieri  wrote:

>
>
> On Thu, Jul 21, 2016 at 3:59 PM, David Storrs  > wrote:
>
>> So there's no way to query the interface of a struct?
>>
>>
>>
> Not in general, no. -J
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: How to differentiate between files and directories?

2016-07-21 Thread Jon Zeppieri
On Thu, Jul 21, 2016 at 3:59 PM, David Storrs 
wrote:

> So there's no way to query the interface of a struct?
>
>
>
Not in general, no. -J

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: How to differentiate between files and directories?

2016-07-21 Thread David Storrs
So there's no way to query the interface of a struct?

On Thursday, July 21, 2016, Jon Zeppieri  wrote:

>
>
> On Thu, Jul 21, 2016 at 2:44 PM, David Storrs  > wrote:
>>
>>
>>
>> In a related question, is there a way to introspect a struct to find
>> out what its fields are?
>>
>>
> If you mean the field values: yes, but only if the struct is transparent
> or prefab or if you have the proper inspector, which you probably do not.
> You can generally try struct->vector and see if you get anything useful.
>
> If you mean the field names: I don't think so; I don't think they exist at
> runtime.
>
> - Jon
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to differentiate between files and directories?

2016-07-21 Thread Jon Zeppieri
On Thu, Jul 21, 2016 at 2:44 PM, David Storrs 
wrote:
>
>
>
> In a related question, is there a way to introspect a struct to find
> out what its fields are?
>
>
If you mean the field values: yes, but only if the struct is transparent or
prefab or if you have the proper inspector, which you probably do not. You
can generally try struct->vector and see if you get anything useful.

If you mean the field names: I don't think so; I don't think they exist at
runtime.

- Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: How to differentiate between files and directories?

2016-07-21 Thread David Storrs
Hi Stephen,

Yep, I saw file-exists?, thanks. Like I said, I don't want to check the
disk twice (once when getting the list of paths with (in-directory), then
again with file-exists?). I don't care if the file actually exists on disk,
I care if this path is describing a file or a directory. I'm hoping to be
able to do something like, e.g., use (fold-files) or (find-files)
to process just files or just directories.

On Thursday, July 21, 2016, Stephen De Gabrielle 
wrote:

>
> http://docs.racket-lang.org/reference/Filesystem.html#%28def._%28%28quote._~23~25kernel%29._file-exists~3f%29%29
>
> in http://docs.racket-lang.org/reference/Filesystem.html
>
>
>
> (file-exists?
> 
>  path) → boolean?
> 
> (link-exists?
> 
>  path) → boolean?
> 
>
> (directory-exists?
> 
>  path) → boolean?
> 
>
>   path : path-string?
> 
>
> Returns #t if path refers to a directory, #f otherwise.
>
>
> On Thu, Jul 21, 2016 at 7:44 PM, David Storrs  > wrote:
>
>> Silly question: given a <#path>, how do I tell if it's to a file,
>> directory, link, etc?  I'd like to know this in general, although the
>> proximate issue is that I would like to use (in-directory) to process
>> all the files in a directory, but I need a way to ignore everything
>> that isn't a file.
>>
>> I saw 'file-exists?' but I don't want to check the disk twice, I just
>> want to know what type it is.  That information should have been
>> available when the path was constructed.
>>
>>
>> In a related question, is there a way to introspect a struct to find
>> out what its fields are?
>>
>>
>> Dave
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to differentiate between files and directories?

2016-07-21 Thread Jon Zeppieri
On Thu, Jul 21, 2016 at 2:44 PM, David Storrs 
wrote:

>
>
> I saw 'file-exists?' but I don't want to check the disk twice, I just
> want to know what type it is.  That information should have been
> available when the path was constructed.
>
>
Constructing a path doesn't require checking the filesystem, because a path
might not actually refer to anything extant. E.g.,

> (string->path "/foo/bar")
#

(There is nothing on my filesystem at /foo/bar.)

- Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How to differentiate between files and directories?

2016-07-21 Thread Stephen De Gabrielle
http://docs.racket-lang.org/reference/Filesystem.html#%28def._%28%28quote._~23~25kernel%29._file-exists~3f%29%29

in http://docs.racket-lang.org/reference/Filesystem.html



(file-exists?

 path) → boolean?

(link-exists?

 path) → boolean?


(directory-exists?

 path) → boolean?


  path : path-string?


Returns #t if path refers to a directory, #f otherwise.


On Thu, Jul 21, 2016 at 7:44 PM, David Storrs 
wrote:

> Silly question: given a <#path>, how do I tell if it's to a file,
> directory, link, etc?  I'd like to know this in general, although the
> proximate issue is that I would like to use (in-directory) to process
> all the files in a directory, but I need a way to ignore everything
> that isn't a file.
>
> I saw 'file-exists?' but I don't want to check the disk twice, I just
> want to know what type it is.  That information should have been
> available when the path was constructed.
>
>
> In a related question, is there a way to introspect a struct to find
> out what its fields are?
>
>
> Dave
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] How to differentiate between files and directories?

2016-07-21 Thread David Storrs
Silly question: given a <#path>, how do I tell if it's to a file,
directory, link, etc?  I'd like to know this in general, although the
proximate issue is that I would like to use (in-directory) to process
all the files in a directory, but I need a way to ignore everything
that isn't a file.

I saw 'file-exists?' but I don't want to check the disk twice, I just
want to know what type it is.  That information should have been
available when the path was constructed.


In a related question, is there a way to introspect a struct to find
out what its fields are?


Dave

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.