Re: File API taming

[email protected]
Newsgroups gmane.comp.lang.e.general
Message-ID <[email protected]>
On Thu, Mar 19, 2009 at 5:31 PM, Kevin Reid <[email protected]> wrote:
> Insofar as this is part of The Web, perhaps we should (pretend, if
> necessary) that files have MIME types, er, media types? Namely, have
> "media type" be a visible attribute of a file object, even if in
> implementation it results from its name extension inside the parent
> directory?

Agreed. So given a directory 'd', the operation --

  var f = d.get('foo.txt')

returns a file that answers to --

  f.getMediaType()

which may either be initialized by the directory 'd' upon creation,
based on the file name, or it may be an intrinsic property of the file
in some other way.

The asymmetry, however, is that *asking* a file to change its own
media type is no longer the same: In one case, the file itself has
that authority; and in the other case, the file has to consult its
directory saying, "please rename me from 'foo.txt' to 'foo.doc'".

That said, the directory 'd' could, if desired, initialize 'f' with a
function that closes over  'd' and does the renaming, without giving
'f' direct access to 'd'.

Does that sound reasonable?

Ihab

-- 
Ihab A.B. Awad, Palo Alto, CA
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.