This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: File objects, path object, filepath objects, strings
- From: Per Bothner <per at bothner dot com>
- To: Ethan Herdrick <info at reatlas dot com>
- Cc: kawa at sourceware dot org
- Date: Wed, 30 Apr 2008 12:43:45 -0700
- Subject: Re: File objects, path object, filepath objects, strings
- References: <91f48dbf0804300054h395bba28sc2356d293fc06bcf@mail.gmail.com>
Ethan Herdrick wrote:
There are:
1) Java File objects,
2) Kawa filepath objects, which are said to be wrappers around Java File objects
3) Kawa path objects, which are... ?
4) strings which can be paths.
When should I use each type? What is the purpose of filepath and path
objects?
They provide a layer of abstraction, so you can use the same API to
work with both file names and URI/URLs. They also provide the
mechanism so that that you can use URLs most places standard
Scheme requires filenames:
#|kawa:3|# (define p (open-input-file "http://bothner.com"))
#|kawa:6|# (read-line p)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head>
The string "http://bothner.com" is automatically coerced to a path,
either a filepath or a URI, respectively.
It appears that the path objects are accepted by Java when a
java.io.File is called for, which is very handy.
Not really, as you note in your follow-up. But many Scheme
functions take general paths or objects that can be coerced to a path.
> It appears that
functions that take filepath and path objects generally take strings,
too.. Is this true?
Yes - as if they were coerced by (path arg).
--
--Per Bothner
per@bothner.com http://per.bothner.com/